Skip to content

Commit 2cbc0d5

Browse files
committed
chore: Improve configuration and fix typos
- Fix typo: adverise_addresses -> advertise_addresses - Add health check to load balancer (10s interval, 5s timeout) - Upgrade KubeletConfiguration API to v1 (stable since K8s 1.28) - Fix variable quoting in cluster-join.sh - Update test script kubectl version to v1.34.1 - Fix typo in private_network example (pod_cidr_ipv6 -> pod_cidr_ipv4) - Fix ha_load_balancer example to use load_balancer_type
1 parent 3c01a5c commit 2cbc0d5

8 files changed

Lines changed: 21 additions & 12 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ If the node is already defunct, there are two cases to consider:
124124

125125
It is important to remove failed members from etcd even if quorum is still present as new control plane nodes will not be able to join until etcd cluster is healthy.
126126

127-
- etcd cluster no longer has quorum, e.g. a single control plane node is gone out of a 2-node cluster. In this case the etcd cluster will need to be rebuilt from snapshot, following the steps for [disaster recovery](https://etcd.io/docs/v3.4/op-guide/recovery/). Data loss may have occured.
127+
- etcd cluster no longer has quorum, e.g. a single control plane node is gone out of a 2-node cluster. In this case the etcd cluster will need to be rebuilt from snapshot, following the steps for [disaster recovery](https://etcd.io/docs/v3.6/op-guide/recovery/). Data loss may have occured.
128128

129129

130130
You may also need to manually remove the Node object, as the Hetzner Cloud Controller that is responsible for deleting defunct nodes may have been running on this very node (should not be an issue if `kubectl drain` was done first)
@@ -192,7 +192,8 @@ See [example](./examples/private_network.tf) for more details.
192192
Read these notes carefully before using this module in production.
193193

194194
- Control plane services that use host networking, such as etcd, kubelet and api-server bind on a public IP. This is not a problem per se since these components all use mTLS for communication, but appropriate Hetzner Firewall rules can be added (make sure to allow UDP port 24601 for Wireguard node-to-node tunnels)
195-
- Wigglenet is an experimental network plugin that I wrote for my personal use and has definitely not been battle tested. `NetworkPolicy` is supported as of v0.5.0.
195+
- Wigglenet is a custom network plugin with a smaller community than mainstream alternatives like Cilium or Calico. It has been used successfully for several years,
196+
though primarily in smaller-scale deployments. NetworkPolicy support was added in v0.5.0 and is relatively new, so don't use it as your only line of defense.
196197
- kubelet serving certificates are self-signed. This can be an issue for metrics-server. See [here for details and workarounds](https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-certs/#kubelet-serving-certs).
197198
- Some restrictions on day-2 operations. The following are supported seamlessly, but other changes will likely require the manual steps:
198199
- Node replacement (see notes above for control plane nodes)

control_plane.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ locals {
55

66
control_plane_endpoint = var.control_plane_endpoint != "" ? var.control_plane_endpoint : (local.use_load_balancer ? "[${hcloud_load_balancer.control_plane[0].ipv6}]" : "[${module.control_plane[0].ipv6_address}]")
77

8-
adverise_addresses = var.primary_ip_family == "ipv6" ? module.control_plane.*.ipv6_address : module.control_plane.*.ipv4_address
8+
advertise_addresses = var.primary_ip_family == "ipv6" ? module.control_plane.*.ipv6_address : module.control_plane.*.ipv4_address
99

1010
# If using IP as an apiserver endpoint, add also the IPv4 SAN to the TLS certificate
1111
apiserver_cert_sans = concat(var.control_plane_endpoint != "" ? [
@@ -59,7 +59,7 @@ resource "null_resource" "cluster_bootstrap" {
5959
apiserver_cert_sans = local.apiserver_cert_sans
6060
certificate_key = random_id.certificate_key.hex
6161
control_plane_endpoint = local.control_plane_endpoint
62-
advertise_address = local.adverise_addresses[0]
62+
advertise_address = local.advertise_addresses[0]
6363
pod_cidr_ipv4 = var.pod_cidr_ipv4
6464
service_cidr_ipv4 = var.service_cidr_ipv4
6565
service_cidr_ipv6 = var.service_cidr_ipv6
@@ -110,7 +110,7 @@ resource "null_resource" "control_plane_join" {
110110
ssh -i ${var.ssh_private_key_path} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
111111
root@${local.kubeadm_host} \
112112
'echo $(kubeadm token create --print-join-command --ttl=60m) \
113-
--apiserver-advertise-address ${local.adverise_addresses[count.index]} \
113+
--apiserver-advertise-address ${local.advertise_addresses[count.index]} \
114114
--control-plane \
115115
--certificate-key ${random_id.certificate_key.hex}' | \
116116
ssh -i ${var.ssh_private_key_path} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \

examples/ha_load_balancer.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module "cluster" {
3131
server_type = "cpx31"
3232
node_count = 3
3333

34-
control_plane_endpoint = "k8s.example.com"
34+
load_balancer_type = "lb11"
3535
}
3636

3737
module "workers" {

examples/private_network.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module "cluster" {
2929
location = "hel1"
3030
server_type = "cpx31"
3131

32-
# The default pod_cidr_ipv6 is 10.96.0.0/16. This can be customized,
32+
# The default pod_cidr_ipv4 is 10.96.0.0/16. This can be customized,
3333
# but it should be within the range of the private network. Also, it should
3434
# not overlap with the subnet specified below, as that subnet is used for nodes.
3535
# pod_cidr_ipv4 = "10.96.0.0/16"

loadbalancer.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ resource "hcloud_load_balancer_service" "control_plane" {
1515
listen_port = 6443
1616
destination_port = 6443
1717
protocol = "tcp"
18+
19+
health_check {
20+
protocol = "tcp"
21+
port = 6443
22+
interval = 10
23+
timeout = 5
24+
retries = 3
25+
}
1826
}
1927

2028
resource "hcloud_load_balancer_target" "control_plane_target" {

scripts/cluster-join.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ else
1515
kubeadm init --config cluster.yaml --upload-certs
1616
fi
1717

18-
mkdir -p $HOME/.kube
19-
cp -f /etc/kubernetes/admin.conf $HOME/.kube/config
20-
chown $(id -u):$(id -g) $HOME/.kube/config
18+
mkdir -p "$HOME/.kube"
19+
cp -f /etc/kubernetes/admin.conf "$HOME/.kube/config"
20+
chown "$(id -u):$(id -g)" "$HOME/.kube/config"

templates/kubeadm.yaml.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
kind: KubeletConfiguration
2-
apiVersion: kubelet.config.k8s.io/v1beta1
2+
apiVersion: kubelet.config.k8s.io/v1
33
cgroupDriver: systemd
44
---
55
kind: InitConfiguration

test/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ teardown_cluster() {
1717

1818
case "$1" in
1919
kubectl)
20-
curl -LO https://dl.k8s.io/release/v1.27.1/bin/linux/amd64/kubectl
20+
curl -LO https://dl.k8s.io/release/v1.34.1/bin/linux/amd64/kubectl
2121
chmod +x kubectl
2222
;;
2323
setup)

0 commit comments

Comments
 (0)