summaryrefslogtreecommitdiff
path: root/roles/kubernetes/kubeadm
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2022-08-19 20:11:31 +0200
committerChristian Pointner <equinox@spreadspace.org>2022-08-19 20:11:31 +0200
commit393eaa17c0d22c8f5e979bf3d04fe94d1b4e8980 (patch)
tree60c2026f1942bf44dcf91186dca9e4d6ccaa057d /roles/kubernetes/kubeadm
parentkubernetes/kubeadm: fix upload-certs for secondary control-plane nodes if cus... (diff)
kubernetes/kubeadm: properly wait for new nodes to join the cluster
Diffstat (limited to 'roles/kubernetes/kubeadm')
-rw-r--r--roles/kubernetes/kubeadm/control-plane/tasks/secondary.yml13
-rw-r--r--roles/kubernetes/kubeadm/worker/tasks/main.yml9
2 files changed, 17 insertions, 5 deletions
diff --git a/roles/kubernetes/kubeadm/control-plane/tasks/secondary.yml b/roles/kubernetes/kubeadm/control-plane/tasks/secondary.yml
index 7c2f490f..aaa4d94e 100644
--- a/roles/kubernetes/kubeadm/control-plane/tasks/secondary.yml
+++ b/roles/kubernetes/kubeadm/control-plane/tasks/secondary.yml
@@ -55,8 +55,11 @@
content: "{{ kubeadm_join.stderr }}\n"
dest: /etc/kubernetes/kubeadm-join.errors
- # TODO: acutally check if node has registered
-- name: give the new control-plane node(s) a moment to register
- when: kubeadm_join is changed
- pause: # noqa 503
- seconds: 5
+- name: wait for new control-plane node to register
+ delegate_to: "{{ groups['_kubernetes_primary_controlplane_node_'] | first }}"
+ command: "kubectl --kubeconfig /etc/kubernetes/admin.conf get nodes -o name {{ kubernetes_node_name }}"
+ changed_when: False
+ register: kubectl_node_get
+ until: kubectl_node_get.rc == 0
+ retries: 30
+ dely: 2
diff --git a/roles/kubernetes/kubeadm/worker/tasks/main.yml b/roles/kubernetes/kubeadm/worker/tasks/main.yml
index b6694ede..422f27c7 100644
--- a/roles/kubernetes/kubeadm/worker/tasks/main.yml
+++ b/roles/kubernetes/kubeadm/worker/tasks/main.yml
@@ -27,3 +27,12 @@
copy:
content: "{{ kubeadm_join.stderr }}\n"
dest: /etc/kubernetes/kubeadm-join.errors
+
+- name: wait for new worker node to register
+ delegate_to: "{{ groups['_kubernetes_primary_controlplane_node_'] | first }}"
+ command: "kubectl --kubeconfig /etc/kubernetes/admin.conf get nodes -o name {{ kubernetes_node_name }}"
+ changed_when: False
+ register: kubectl_node_get
+ until: kubectl_node_get.rc == 0
+ retries: 30
+ delay: 2