Skip to content

Commit

Permalink
fix waiting for pods to be created/ready
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Troppmann committed May 25, 2021
1 parent b0fafb7 commit 23e50c4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions deploy/hcloud-k8s/roles/postgres/tasks/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
helm --kubeconfig {{ kubeconfig }} install -n {{ namespace.postgres }} postgresql bitnami/postgresql -f {{ k8s_install_dir.path }}/values.yaml --version {{ helm_chart_version.postgres }} --wait
- name: wait for pods become created
shell: "kubectl get pod --namespace={{ namespace.postgres }} --selector k8s-app=postgresql --output=jsonpath='{.items[*].metadata.name}'"
shell: "kubectl get pod -n {{ namespace.postgres }} --selector 'app.kubernetes.io/instance=postgresql' --output=jsonpath='{.items[*].metadata.name}'"
register: pods_created
until: item in pods_created.stdout
retries: 20
delay: 15
with_items:
- postgres
- postgresql-postgresql-0

- name: wait for pods become ready
shell: "kubectl wait -n {{ namespace.postgres }} --for=condition=Ready pods --selector k8s-app=postgresql --timeout=600s"
shell: "kubectl wait -n {{ namespace.postgres }} --for=condition=Ready pods --selector 'app.kubernetes.io/instance=postgresql' --timeout=600s"
register: pods_ready

- debug:
Expand Down
13 changes: 13 additions & 0 deletions deploy/hcloud-k8s/roles/termine/tasks/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,16 @@
- name: deploy k8s manifests
shell: |-
kubectl --kubeconfig {{ kubeconfig }} apply -f {{ k8s_install_dir.path }}/
- name: wait for pods become created
shell: "kubectl get pod --selector app=termine --output=jsonpath='{.items[*].metadata.name}'"
register: pods_created
until: item in pods_created.stdout
retries: 20
delay: 15
with_items:
- termine

- name: wait for pods become ready
shell: "kubectl wait --for=condition=Ready pods --selector app=termine --timeout=600s"
register: pods_ready

0 comments on commit 23e50c4

Please sign in to comment.