Skip to content

Commit

Permalink
feat: DNF5 support + upgrade deps (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
tibordp authored Nov 29, 2024
1 parent d2f8db3 commit dca4160
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 28 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ and check the access by viewing the created cluster nodes:
```cmd
$ kubectl get nodes --kubeconfig=kubeconfig.conf
NAME STATUS ROLES AGE VERSION
k8s-control-plane-0 Ready control-plane 31m v1.31.1
k8s-worker-0 Ready <none> 31m v1.31.1
k8s-worker-1 Ready <none> 31m v1.31.1
k8s-control-plane-0 Ready control-plane 31m v1.31.3
k8s-worker-0 Ready <none> 31m v1.31.3
k8s-worker-1 Ready <none> 31m v1.31.3
```

## Supported base images
Expand All @@ -83,6 +83,7 @@ The module should work on most major RPM and DEB distros. It been tested on thes
- Centos Stream 9 (`centos-stream-9`)
- Rocky Linux 9 (`rocky-9`)
- Fedora 40 (`fedora-40`)
- Fedora 41 (`fedora-41`)

Others may work as well, but have not been tested.

Expand Down
20 changes: 16 additions & 4 deletions modules/kubernetes-node/scripts/prepare-node.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,23 @@ install_prerequisites() {
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
EOF

addrepo() {
if dnf --version | grep -q dnf5; then
dnf -qy config-manager addrepo "--from-repofile=$1"
else
dnf -qy config-manager --add-repo "$1"
fi
}

if [ "$os_id" == "fedora" ]; then
dnf -qy config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
addrepo https://download.docker.com/linux/fedora/docker-ce.repo
dnf -qy install containerd.io ipvsadm wireguard-tools iproute-tc
elif [ "$(. /etc/os-release && echo $PLATFORM_ID)" = "platform:el9" ]; then
# Wireguard is installed by default on EL9-like systems
dnf -qy config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
addrepo https://download.docker.com/linux/centos/docker-ce.repo
dnf -qy install containerd.io ipvsadm wireguard-tools iproute-tc
else
dnf -qy config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
addrepo https://download.docker.com/linux/centos/docker-ce.repo
dnf -qy install elrepo-release epel-release
dnf -qy install containerd.io ipvsadm kmod-wireguard wireguard-tools iproute-tc
fi
Expand Down Expand Up @@ -124,7 +132,11 @@ install_kubernetes() {
fi

echo 'KUBELET_EXTRA_ARGS=--cloud-provider=external --node-ip=::' > /etc/sysconfig/kubelet
dnf -qy install kubelet-${kubernetes_version}-* kubeadm-${kubernetes_version}-* kubectl-${kubernetes_version}-* --disableexcludes=kubernetes
if dnf --version | grep -q dnf5; then
dnf -qy install kubelet-${kubernetes_version}-* kubeadm-${kubernetes_version}-* kubectl-${kubernetes_version}-* --setopt=disable_excludes=kubernetes
else
dnf -qy install kubelet-${kubernetes_version}-* kubeadm-${kubernetes_version}-* kubectl-${kubernetes_version}-* --disableexcludes=kubernetes
fi
systemctl enable --now containerd kubelet
fi
}
Expand Down
2 changes: 1 addition & 1 deletion modules/worker-node/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ variable "labels" {
variable "kubernetes_version" {
description = "Kubernetes version"
type = string
default = "1.31.1"
default = "1.31.3"

validation {
condition = can(regex("^1\\.([0-9]+)\\.([0-9]+)$", var.kubernetes_version))
Expand Down
8 changes: 3 additions & 5 deletions templates/hetzner_ccm.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ spec:
- key: "node-role.kubernetes.io/control-plane"
effect: NoSchedule
operator: Exists

- key: "node.kubernetes.io/not-ready"
effect: "NoExecute"
hostNetwork: true

containers:
- name: hcloud-cloud-controller-manager
command:
- "/bin/hcloud-cloud-controller-manager"
args:
- "--allow-untagged-cloud"
- "--cloud-provider=hcloud"
- "--route-reconciliation-period=30s"
Expand Down Expand Up @@ -90,7 +88,7 @@ spec:
%{ endif ~}
- name: HCLOUD_INSTANCES_ADDRESS_FAMILY
value: dualstack
image: docker.io/hetznercloud/hcloud-cloud-controller-manager:v1.20.0 # x-release-please-version
image: docker.io/hetznercloud/hcloud-cloud-controller-manager:v1.21.0 # x-releaser-pleaser-version
ports:
- name: metrics
containerPort: 8233
Expand Down
39 changes: 27 additions & 12 deletions templates/hetzner_csi.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ metadata:
app.kubernetes.io/name: hcloud-csi
app.kubernetes.io/instance: hcloud-csi
app.kubernetes.io/component: node
app: hcloud-csi
app: hcloud-csi
spec:
updateStrategy:
type: RollingUpdate
Expand All @@ -164,7 +164,7 @@ spec:
app.kubernetes.io/component: node
app: hcloud-csi
spec:

affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
Expand All @@ -174,6 +174,10 @@ spec:
operator: NotIn
values:
- "true"
- key: instance.hetzner.cloud/provided-by
operator: NotIn
values:
- robot
tolerations:
- effect: NoExecute
operator: Exists
Expand All @@ -186,7 +190,7 @@ spec:
initContainers:
containers:
- name: csi-node-driver-registrar
image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.11.1
image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.12.0
imagePullPolicy: IfNotPresent
args:
- --kubelet-registration-path=/var/lib/kubelet/plugins/csi.hetzner.cloud/socket
Expand All @@ -199,7 +203,7 @@ spec:
limits: {}
requests: {}
- name: liveness-probe
image: registry.k8s.io/sig-storage/livenessprobe:v2.13.1
image: registry.k8s.io/sig-storage/livenessprobe:v2.14.0
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /run/csi
Expand All @@ -208,7 +212,7 @@ spec:
limits: {}
requests: {}
- name: hcloud-csi-driver
image: docker.io/hetznercloud/hcloud-csi-driver:v2.9.0 # x-release-please-version
image: docker.io/hetznercloud/hcloud-csi-driver:v2.11.0 # x-releaser-pleaser-version
imagePullPolicy: IfNotPresent
command: [/bin/hcloud-csi-driver-node]
volumeMounts:
Expand Down Expand Up @@ -274,7 +278,7 @@ metadata:
app.kubernetes.io/name: hcloud-csi
app.kubernetes.io/instance: hcloud-csi
app.kubernetes.io/component: controller
app: hcloud-csi-controller
app: hcloud-csi-controller
spec:
replicas: 1
strategy:
Expand All @@ -291,13 +295,23 @@ spec:
app: hcloud-csi-controller
spec:
serviceAccountName: hcloud-csi-controller


affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- preference:
matchExpressions:
- key: instance.hetzner.cloud/provided-by
operator: In
values:
- cloud
weight: 1
securityContext:
fsGroup: 1001
initContainers:
containers:
- name: csi-attacher
image: registry.k8s.io/sig-storage/csi-attacher:v4.6.1
image: registry.k8s.io/sig-storage/csi-attacher:v4.7.0
imagePullPolicy: IfNotPresent
resources:
limits: {}
Expand All @@ -309,7 +323,7 @@ spec:
mountPath: /run/csi

- name: csi-resizer
image: registry.k8s.io/sig-storage/csi-resizer:v1.11.2
image: registry.k8s.io/sig-storage/csi-resizer:v1.12.0
imagePullPolicy: IfNotPresent
resources:
limits: {}
Expand All @@ -319,7 +333,7 @@ spec:
mountPath: /run/csi

- name: csi-provisioner
image: registry.k8s.io/sig-storage/csi-provisioner:v5.0.2
image: registry.k8s.io/sig-storage/csi-provisioner:v5.1.0
imagePullPolicy: IfNotPresent
resources:
limits: {}
Expand All @@ -332,7 +346,7 @@ spec:
mountPath: /run/csi

- name: liveness-probe
image: registry.k8s.io/sig-storage/livenessprobe:v2.13.1
image: registry.k8s.io/sig-storage/livenessprobe:v2.14.0
imagePullPolicy: IfNotPresent
resources:
limits: {}
Expand All @@ -342,7 +356,7 @@ spec:
name: socket-dir

- name: hcloud-csi-driver
image: docker.io/hetznercloud/hcloud-csi-driver:v2.9.0 # x-release-please-version
image: docker.io/hetznercloud/hcloud-csi-driver:v2.11.0 # x-releaser-pleaser-version
imagePullPolicy: IfNotPresent
command: [/bin/hcloud-csi-driver-controller]
env:
Expand Down Expand Up @@ -397,5 +411,6 @@ spec:
attachRequired: true
fsGroupPolicy: File
podInfoOnMount: true
seLinuxMount: true
volumeLifecycleModes:
- Persistent
2 changes: 1 addition & 1 deletion templates/wigglenet.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ spec:
serviceAccountName: wigglenet
containers:
- name: wigglenet
image: ghcr.io/tibordp/wigglenet:v0.4.2
image: ghcr.io/tibordp/wigglenet:v0.4.4
imagePullPolicy: IfNotPresent
env:
- name: NODE_NAME
Expand Down
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ variable "primary_ip_family" {
}

variable "kubernetes_version" {
description = "Version of Kubernetes to install (default: 1.31.1)"
description = "Version of Kubernetes to install (default: 1.31.3)"
type = string
default = "1.31.1"
default = "1.31.3"

validation {
condition = can(regex("^1\\.([0-9]+)\\.([0-9]+)$", var.kubernetes_version))
Expand Down

0 comments on commit dca4160

Please sign in to comment.