Set proper role for worker node

Since it's not possible to self assign node labels such as role
it must be done after bootstrap process. [1]

[1] https://cluster-api.sigs.k8s.io/user/troubleshooting.html#labeling-nodes-with-reserved-labels-such-as-node-rolekubernetesio-fails-with-kubeadm-error-during-bootstrap
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>

Change-Id: I5163bcd4ddc8c74900904d8032b215406b4c513d
This commit is contained in:
Ruslan Aliev 2021-02-09 20:22:48 -06:00
parent 5647f5381e
commit 32c000eeba
2 changed files with 8 additions and 3 deletions

View File

@ -9,7 +9,7 @@ spec:
nodeRegistration:
name: '{{ ds.meta_data.name }}'
kubeletExtraArgs:
node-labels: 'metal3.io/uuid={{ ds.meta_data.uuid }},node-type=worker'
node-labels: 'metal3.io/uuid={{ ds.meta_data.uuid }}'
provider-id: 'metal3://{{ ds.meta_data.uuid }}'
feature-gates: "IPv6DualStack=true"
ntp:

View File

@ -18,6 +18,7 @@ set -xe
export TIMEOUT=${TIMEOUT:-3600}
export KUBECONFIG=${KUBECONFIG:-"$HOME/.airship/kubeconfig"}
export KUBECONFIG_TARGET_CONTEXT=${KUBECONFIG_TARGET_CONTEXT:-"target-cluster"}
WORKER_NODE="node03"
echo "Stop ephemeral node"
sudo virsh destroy air-ephemeral
@ -25,7 +26,11 @@ sudo virsh destroy air-ephemeral
node_timeout () {
end=$(($(date +%s) + $TIMEOUT))
while true; do
if (kubectl --request-timeout 20s --kubeconfig $KUBECONFIG --context $KUBECONFIG_TARGET_CONTEXT get $1 node03 | grep -qw $2) ; then
if (kubectl --request-timeout 20s --kubeconfig $KUBECONFIG --context $KUBECONFIG_TARGET_CONTEXT get $1 $WORKER_NODE | grep -qw $2) ; then
if [ "$1" = "node" ]; then
kubectl --kubeconfig $KUBECONFIG --context $KUBECONFIG_TARGET_CONTEXT label nodes $WORKER_NODE node-role.kubernetes.io/worker=""
fi
echo -e "\nGet $1 status"
kubectl --kubeconfig $KUBECONFIG --context $KUBECONFIG_TARGET_CONTEXT get $1
break
@ -42,7 +47,7 @@ node_timeout () {
}
echo "Deploy worker node"
airshipctl phase run workers-target --debug
airshipctl phase run workers-target --debug
echo "Waiting $TIMEOUT seconds for bmh to be in ready state."
node_timeout bmh ready