From 9801c105e41f5ca8e210de3422620f94afd9d271 Mon Sep 17 00:00:00 2001 From: "michal.gubricky" Date: Thu, 18 Jul 2024 14:18:47 +0200 Subject: [PATCH] Add shell script to patch configmap for kube-proxy Signed-off-by: michal.gubricky --- .../kubeadm-control-plane-template.yaml | 52 ++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/providers/openstack/scs/cluster-class/templates/kubeadm-control-plane-template.yaml b/providers/openstack/scs/cluster-class/templates/kubeadm-control-plane-template.yaml index 9949e3f9..58dced52 100644 --- a/providers/openstack/scs/cluster-class/templates/kubeadm-control-plane-template.yaml +++ b/providers/openstack/scs/cluster-class/templates/kubeadm-control-plane-template.yaml @@ -14,11 +14,11 @@ spec: extraArgs: cloud-provider: external bind-address: 0.0.0.0 - secure-port: 10257 + secure-port: "10257" scheduler: extraArgs: bind-address: 0.0.0.0 - secure-port: 10259 + secure-port: "10259" etcd: local: dataDir: /var/lib/etcd @@ -29,6 +29,54 @@ spec: election-timeout: "2500" heartbeat-interval: "250" snapshot-count: "6400" + files: + - content: | + --- + apiVersion: kubeproxy.config.k8s.io/v1alpha1 + kind: KubeProxyConfiguration + metricsBindAddress: "0.0.0.0:10249" + path: /etc/kube-proxy-config.yaml + - content: | + #!/usr/bin/env bash + + # + # (PK) I couldn't find a better/simpler way to conifgure it. See: + # https://github.com/kubernetes-sigs/cluster-api/issues/4512 + # + + set -o errexit + set -o nounset + set -o pipefail + + dir=$( cd "$( dirname "$${BASH_SOURCE[0]}" )" && pwd ) + readonly dir + + # Exit fast if already appended. + if [[ ! -f $${dir}/kube-proxy-config.yaml ]]; then + exit 0 + fi + + # kubeadm config is in different directory in Flatcar (/etc) and Ubuntu (/run/kubeadm). + kubeadm_file="/etc/kubeadm.yml" + if [[ ! -f $${kubeadm_file} ]]; then + kubeadm_file="/run/kubeadm/kubeadm.yaml" + fi + + # Run this script only if this is the init node. + if [[ ! -f $${kubeadm_file} ]]; then + exit 0 + fi + + # Append kube-proxy-config.yaml to kubeadm config and delete it + cat "$${dir}/kube-proxy-config.yaml" >> "$${kubeadm_file}" + rm "$${dir}/kube-proxy-config.yaml" + + echo success > /tmp/kube-proxy-patch + owner: root:root + path: /etc/kube-proxy-patch.sh + permissions: "0755" + preKubeadmCommands: + - bash /etc/kube-proxy-patch.sh initConfiguration: nodeRegistration: kubeletExtraArgs: