zuul-jobs/roles/helm-template/tasks/main.yaml
Mohammed Naser 8ae49163f3 helm-template: Add role to run 'helm template'
This role runs Helm template of a specific chart and then makes
sure that all resources become ready afterwards.

Change-Id: I62e160eac673d13bd1018b58fd36cae54e1482b4
2020-01-10 17:31:05 +00:00

40 lines
1.4 KiB
YAML

- name: Install dependencies
command: "helm dep up {{ helm_chart }}"
args:
chdir: "{{ zuul_work_dir }}"
- name: Print templated charts
command: "helm template -n zuul {{ helm_chart }}"
args:
chdir: "{{ zuul_work_dir }}"
- name: Deploy templated charts
shell: |
set -o pipefail
helm template -n {{ helm_release_name }} {{ helm_chart }} | kubectl apply -f-
args:
executable: /bin/bash
chdir: "{{ zuul_work_dir }}"
# 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