From b7055ab80659d2c8156b35d2e1bf446a61c7edb1 Mon Sep 17 00:00:00 2001 From: Lennart Jern Date: Thu, 25 May 2023 14:42:55 +0300 Subject: [PATCH] Templates: Set provider ID directly via kubelet This commit sets the provider ID in the flatcar templates. To avoid issues with potential mismatches between node names and openstack servers we can configure the kubelet to set the provider ID. Otherwise, the cloud controller will try to match nodes and servers based on just the name. The names can differ because of special characters, like dots. When this happens, the cloud controller will be unable to match them and thus believe that the node has no underlying server. Co-authored-by: Mathieu Tortuyaux --- kustomize/v1alpha7/flatcar/patch-flatcar.yaml | 14 +++++--------- templates/cluster-template-flatcar.yaml | 5 +++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/kustomize/v1alpha7/flatcar/patch-flatcar.yaml b/kustomize/v1alpha7/flatcar/patch-flatcar.yaml index 02dacc00af..d487029c95 100644 --- a/kustomize/v1alpha7/flatcar/patch-flatcar.yaml +++ b/kustomize/v1alpha7/flatcar/patch-flatcar.yaml @@ -18,15 +18,12 @@ spec: nodeRegistration: name: $${COREOS_OPENSTACK_HOSTNAME} kubeletExtraArgs: - provider-id: null + provider-id: openstack:///$${COREOS_OPENSTACK_INSTANCE_UUID} initConfiguration: nodeRegistration: name: $${COREOS_OPENSTACK_HOSTNAME} kubeletExtraArgs: - # Fixme(lentzi90): This is here just to override the value set in the default - # kustomization. It will be replaced with a value that works for flatcar in - # https://github.com/kubernetes-sigs/cluster-api-provider-openstack/pull/1564 - provider-id: null + provider-id: openstack:///$${COREOS_OPENSTACK_INSTANCE_UUID} format: ignition ignition: containerLinuxConfig: @@ -48,6 +45,7 @@ spec: EnvironmentFile=/run/metadata/flatcar preKubeadmCommands: - export COREOS_OPENSTACK_HOSTNAME=$${COREOS_OPENSTACK_HOSTNAME%.*} + - export COREOS_OPENSTACK_INSTANCE_ID=$${COREOS_OPENSTACK_INSTANCE_ID%.*} - envsubst < /etc/kubeadm.yml > /etc/kubeadm.yml.tmp - mv /etc/kubeadm.yml.tmp /etc/kubeadm.yml --- @@ -62,12 +60,10 @@ spec: nodeRegistration: name: $${COREOS_OPENSTACK_HOSTNAME} kubeletExtraArgs: - # Fixme(lentzi90): This is here just to override the value set in the default - # kustomization. It will be replaced with a value that works for flatcar in - # https://github.com/kubernetes-sigs/cluster-api-provider-openstack/pull/1564 - provider-id: null + provider-id: openstack:///$${COREOS_OPENSTACK_INSTANCE_UUID} preKubeadmCommands: - export COREOS_OPENSTACK_HOSTNAME=$${COREOS_OPENSTACK_HOSTNAME%.*} + - export COREOS_OPENSTACK_INSTANCE_UUID=$${COREOS_OPENSTACK_INSTANCE_UUID%.*} - envsubst < /etc/kubeadm.yml > /etc/kubeadm.yml.tmp - mv /etc/kubeadm.yml.tmp /etc/kubeadm.yml format: ignition diff --git a/templates/cluster-template-flatcar.yaml b/templates/cluster-template-flatcar.yaml index c73cbd996c..64c3f27954 100644 --- a/templates/cluster-template-flatcar.yaml +++ b/templates/cluster-template-flatcar.yaml @@ -39,9 +39,11 @@ spec: nodeRegistration: kubeletExtraArgs: cloud-provider: external + provider-id: openstack:///$${COREOS_OPENSTACK_INSTANCE_ID} name: $${COREOS_OPENSTACK_HOSTNAME} preKubeadmCommands: - export COREOS_OPENSTACK_HOSTNAME=$${COREOS_OPENSTACK_HOSTNAME%.*} + - export COREOS_OPENSTACK_INSTANCE_ID=$${COREOS_OPENSTACK_INSTANCE_ID%.*} - envsubst < /etc/kubeadm.yml > /etc/kubeadm.yml.tmp - mv /etc/kubeadm.yml.tmp /etc/kubeadm.yml --- @@ -125,14 +127,17 @@ spec: nodeRegistration: kubeletExtraArgs: cloud-provider: external + provider-id: openstack:///$${COREOS_OPENSTACK_INSTANCE_ID} name: $${COREOS_OPENSTACK_HOSTNAME} joinConfiguration: nodeRegistration: kubeletExtraArgs: cloud-provider: external + provider-id: openstack:///$${COREOS_OPENSTACK_INSTANCE_ID} name: $${COREOS_OPENSTACK_HOSTNAME} preKubeadmCommands: - export COREOS_OPENSTACK_HOSTNAME=$${COREOS_OPENSTACK_HOSTNAME%.*} + - export COREOS_OPENSTACK_INSTANCE_ID=$${COREOS_OPENSTACK_INSTANCE_ID%.*} - envsubst < /etc/kubeadm.yml > /etc/kubeadm.yml.tmp - mv /etc/kubeadm.yml.tmp /etc/kubeadm.yml machineTemplate: