Skip to content

Commit

Permalink
Templates: Set provider ID directly via kubelet
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
lentzi90 and tormath1 committed Jun 13, 2023
1 parent ed24d87 commit b7055ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
14 changes: 5 additions & 9 deletions kustomize/v1alpha7/flatcar/patch-flatcar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
---
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions templates/cluster-template-flatcar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
---
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit b7055ab

Please sign in to comment.