
This refactors the code inside helm-template which waits for all pods to become Ready to move inside it's own seperate role instead which can be used for other tasks. Change-Id: Ibb234c46c49fe656cf918a7a4af115e0d26f23f0
21 lines
973 B
YAML
21 lines
973 B
YAML
# NOTE(mnaser): When a StatefulSet is deployed, it creates the pods one
|
|
# by one, which means the `kubectl wait` can race if it
|
|
# is ran before the other pods are created. We instead
|
|
# check for all the StatefulSets here manually instead
|
|
# and then use the second check below to do a "confirmation"
|
|
- name: Wait for all StatefulSets to become ready
|
|
block:
|
|
- name: Retrieve all StatefulSets
|
|
command: kubectl get statefulset -o name
|
|
register: _statefulsets
|
|
|
|
- name: Ensure the number of ready replicas matches the replicas
|
|
shell: kubectl get {{ item }} -ogo-template='{{ '{{' }}eq .status.replicas .status.readyReplicas{{ '}}' }}'
|
|
register: _is_ready
|
|
until: _is_ready.stdout == 'true'
|
|
retries: 60
|
|
delay: 5
|
|
loop: "{{ _statefulsets.stdout_lines }}"
|
|
|
|
- name: Wait for all pods to become ready
|
|
command: kubectl wait --for=condition=Ready --timeout=120s pod --all |