Add the namespace in wait-for-pods role

Specify the namespace for waiting, so no need to change the context

Change-Id: I4b961bdc8c740e20d6b72200f0161d2f5c5c2c19
This commit is contained in:
okozachenko 2020-05-27 21:36:56 +03:00
parent 7a5c335cc6
commit 4b390f2d40
2 changed files with 11 additions and 6 deletions

View File

@ -1,4 +1,9 @@
Wait for all pods to become Ready Wait for all pods to become Ready
This role scans the current namespace for all pods and ensures that all of This role scans the current namespace for all pods and ensures that all of
them are in a Ready state. them are in a Ready state.
.. zuul:rolevar:: wait_for_pods_namespace
Name of the specified namespace. If not specified explicitly,
then use the namespace in the current context.

View File

@ -6,11 +6,11 @@
- name: Wait for all StatefulSets to become ready - name: Wait for all StatefulSets to become ready
block: block:
- name: Retrieve all StatefulSets - name: Retrieve all StatefulSets
command: kubectl get statefulset -o name command: kubectl get statefulset {% if wait_for_pods_namespace is defined %}-n {{ wait_for_pods_namespace }}{% endif %} -o name
register: _statefulsets register: _statefulsets
- name: Ensure the number of ready replicas matches the replicas - name: Ensure the number of ready replicas matches the replicas
shell: kubectl get {{ zj_sts_item }} -ogo-template='{{ '{{' }}eq .status.replicas .status.readyReplicas{{ '}}' }}' shell: kubectl get {{ zj_sts_item }} {% if wait_for_pods_namespace is defined %}-n {{ wait_for_pods_namespace }}{% endif %} -ogo-template='{{ '{{' }}eq .status.replicas .status.readyReplicas{{ '}}' }}'
register: _is_ready register: _is_ready
until: _is_ready.stdout == 'true' until: _is_ready.stdout == 'true'
retries: 60 retries: 60
@ -23,11 +23,11 @@
- name: Wait for all DaemonSets to become ready - name: Wait for all DaemonSets to become ready
block: block:
- name: Retrieve all DaemonSets - name: Retrieve all DaemonSets
command: kubectl get daemonset -o name command: kubectl get daemonset {% if wait_for_pods_namespace is defined %}-n {{ wait_for_pods_namespace }}{% endif %} -o name
register: _daemonsets register: _daemonsets
- name: Ensure the ready number matches the scheduled number - name: Ensure the ready number matches the scheduled number
shell: kubectl get {{ zj_ds_item }} -ogo-template='{{ '{{' }}eq .status.currentNumberScheduled .status.numberReady{{ '}}' }}' shell: kubectl get {{ zj_ds_item }} {% if wait_for_pods_namespace is defined %}-n {{ wait_for_pods_namespace }}{% endif %} -ogo-template='{{ '{{' }}eq .status.currentNumberScheduled .status.numberReady{{ '}}' }}'
register: _is_ready register: _is_ready
until: _is_ready.stdout == 'true' until: _is_ready.stdout == 'true'
retries: 60 retries: 60
@ -37,4 +37,4 @@
loop_var: zj_ds_item loop_var: zj_ds_item
- name: Wait for all pods to become ready - name: Wait for all pods to become ready
command: kubectl wait --for=condition=Ready --timeout=120s pod --all command: kubectl wait {% if wait_for_pods_namespace is defined %}-n {{ wait_for_pods_namespace }}{% endif %} --for=condition=Ready --timeout=120s pod --all