From cd221999d5efdc29acceff77e49ad0e408130152 Mon Sep 17 00:00:00 2001 From: okozachenko Date: Fri, 15 May 2020 19:52:01 +0300 Subject: [PATCH] Add DaemonSet check for wait-for-pods role To wait for pods are up which are managed by daemonset controller as well as statefulsets controller. This works even if there are not such controllers. Change-Id: Ib88a9023db6aac151bce71a2bb4ffbcea570e4f5 --- roles/wait-for-pods/tasks/main.yaml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/roles/wait-for-pods/tasks/main.yaml b/roles/wait-for-pods/tasks/main.yaml index 34b39f36a..7c150b335 100644 --- a/roles/wait-for-pods/tasks/main.yaml +++ b/roles/wait-for-pods/tasks/main.yaml @@ -10,14 +10,31 @@ register: _statefulsets - name: Ensure the number of ready replicas matches the replicas - shell: kubectl get {{ zj_item }} -ogo-template='{{ '{{' }}eq .status.replicas .status.readyReplicas{{ '}}' }}' + shell: kubectl get {{ zj_sts_item }} -ogo-template='{{ '{{' }}eq .status.replicas .status.readyReplicas{{ '}}' }}' register: _is_ready until: _is_ready.stdout == 'true' retries: 60 delay: 5 loop: "{{ _statefulsets.stdout_lines }}" loop_control: - loop_var: zj_item + loop_var: zj_sts_item + +# For the DaemonSet, very similar with StatefulSet +- name: Wait for all DaemonSets to become ready + block: + - name: Retrieve all DaemonSets + command: kubectl get daemonset -o name + register: _daemonsets + + - name: Ensure the ready number matches the scheduled number + shell: kubectl get {{ zj_ds_item }} -ogo-template='{{ '{{' }}eq .status.currentNumberScheduled .status.numberReady{{ '}}' }}' + register: _is_ready + until: _is_ready.stdout == 'true' + retries: 60 + delay: 5 + loop: "{{ _daemonsets.stdout_lines }}" + loop_control: + loop_var: zj_ds_item - name: Wait for all pods to become ready command: kubectl wait --for=condition=Ready --timeout=120s pod --all