From 88b82a241c9dfc5d78b32143bc93dcb888b73ba6 Mon Sep 17 00:00:00 2001 From: calvix Date: Tue, 21 Nov 2023 18:16:10 +0100 Subject: [PATCH] rework kubelet configuration to have a file instead of bash script (#427) rework kubelet configuration to have a file instead of bash script --- .../cluster-aws/files/etc/kubelet-configuration.yaml | 4 ++++ helm/cluster-aws/files/opt/kubelet-config.sh | 5 ----- helm/cluster-aws/templates/_control_plane.tpl | 1 - helm/cluster-aws/templates/_helpers.tpl | 12 +++++------- helm/cluster-aws/templates/_machine_pools.tpl | 2 -- 5 files changed, 9 insertions(+), 15 deletions(-) create mode 100644 helm/cluster-aws/files/etc/kubelet-configuration.yaml delete mode 100644 helm/cluster-aws/files/opt/kubelet-config.sh diff --git a/helm/cluster-aws/files/etc/kubelet-configuration.yaml b/helm/cluster-aws/files/etc/kubelet-configuration.yaml new file mode 100644 index 00000000..bb1cc9f9 --- /dev/null +++ b/helm/cluster-aws/files/etc/kubelet-configuration.yaml @@ -0,0 +1,4 @@ +apiVersion: kubelet.config.k8s.io/v1beta1 +kind: KubeletConfiguration +shutdownGracePeriod: 300s +shutdownGracePeriodCriticalPods: 60s diff --git a/helm/cluster-aws/files/opt/kubelet-config.sh b/helm/cluster-aws/files/opt/kubelet-config.sh deleted file mode 100644 index c38d3224..00000000 --- a/helm/cluster-aws/files/opt/kubelet-config.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -sed -i "s|shutdownGracePeriod: .*|shutdownGracePeriod: 5m|g" "/var/lib/kubelet/config.yaml" -sed -i "s|shutdownGracePeriodCriticalPods: .*|shutdownGracePeriodCriticalPods: 1m|g" "/var/lib/kubelet/config.yaml" -systemctl restart kubelet diff --git a/helm/cluster-aws/templates/_control_plane.tpl b/helm/cluster-aws/templates/_control_plane.tpl index 6794bb99..193405cb 100644 --- a/helm/cluster-aws/templates/_control_plane.tpl +++ b/helm/cluster-aws/templates/_control_plane.tpl @@ -245,7 +245,6 @@ spec: {{- include "flatcarKubeadmPreCommands" . | nindent 4 }} {{- if .Values.connectivity.proxy.enabled }}{{- include "proxyCommand" $ | nindent 4 }}{{- end }} postKubeadmCommands: - {{- include "kubeletConfigPostKubeadmCommands" . | nindent 4 }} {{- include "controlPlanePostKubeadmCommands" . | nindent 4 }} {{- if .Values.internal.migration.controlPlanePostKubeadmCommands -}} {{- toYaml .Values.internal.migration.controlPlanePostKubeadmCommands | nindent 4 }} diff --git a/helm/cluster-aws/templates/_helpers.tpl b/helm/cluster-aws/templates/_helpers.tpl index 2939c630..5b40b17a 100644 --- a/helm/cluster-aws/templates/_helpers.tpl +++ b/helm/cluster-aws/templates/_helpers.tpl @@ -128,14 +128,14 @@ giantswarm.io/prevent-deletion: "true" key: registry-config.toml {{- end -}} {{- define "kubeletConfigFiles" -}} -- path: /opt/kubelet-config.sh +- path: /etc/kubelet-configuration.yaml permissions: "0700" encoding: base64 - content: {{ $.Files.Get "files/opt/kubelet-config.sh" | b64enc }} + content: {{ .Files.Get "files/etc/kubelet-configuration.yaml" | b64enc }} - path: /etc/systemd/logind.conf.d/zzz-kubelet-graceful-shutdown.conf permissions: "0700" encoding: base64 - content: {{ $.Files.Get "files/etc/systemd/logind.conf.d/zzz-kubelet-graceful-shutdown.conf" | b64enc }} + content: {{ .Files.Get "files/etc/systemd/logind.conf.d/zzz-kubelet-graceful-shutdown.conf" | b64enc }} {{- end -}} {{- define "kubernetesFiles" -}} @@ -272,10 +272,6 @@ and is used to join the node to the teleport cluster. - /opt/control-plane-config.sh {{- end -}} -{{- define "kubeletConfigPostKubeadmCommands" -}} -- /bin/sh /opt/kubelet-config.sh -{{- end -}} - {{- define "sshUsers" -}} - name: giantswarm groups: sudo @@ -364,6 +360,8 @@ imageLookupOrg: "706635527432" {{- define "flatcarKubeadmPreCommands" -}} - envsubst < /etc/kubeadm.yml > /etc/kubeadm.yml.tmp - mv /etc/kubeadm.yml.tmp /etc/kubeadm.yml +- echo "---" >> /etc/kubeadm.yml +- cat /etc/kubelet-configuration.yaml >> /etc/kubeadm.yml {{- end -}} {{/* diff --git a/helm/cluster-aws/templates/_machine_pools.tpl b/helm/cluster-aws/templates/_machine_pools.tpl index d9afffc7..b7717bb5 100644 --- a/helm/cluster-aws/templates/_machine_pools.tpl +++ b/helm/cluster-aws/templates/_machine_pools.tpl @@ -139,8 +139,6 @@ spec: {{- include "flatcarKubeadmPreCommands" . | nindent 4 }} {{- include "sshPreKubeadmCommands" . | nindent 4 }} {{- if $.Values.connectivity.proxy.enabled }}{{- include "proxyCommand" $ | nindent 4 }}{{- end }} - postKubeadmCommands: - {{- include "kubeletConfigPostKubeadmCommands" . | nindent 4 }} users: {{- include "sshUsers" . | nindent 2 }} files: