mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-08 05:52:37 +00:00
select wait
This commit is contained in:
@@ -20,111 +20,111 @@
|
|||||||
assert:
|
assert:
|
||||||
that: (pod_list.resources | count) > 5
|
that: (pod_list.resources | count) > 5
|
||||||
|
|
||||||
- name: Include access_review.yml
|
# - name: Include access_review.yml
|
||||||
include_tasks:
|
# include_tasks:
|
||||||
file: tasks/access_review.yml
|
# file: tasks/access_review.yml
|
||||||
apply:
|
# apply:
|
||||||
tags: [ access_review, k8s ]
|
# tags: [ access_review, k8s ]
|
||||||
tags:
|
# tags:
|
||||||
- always
|
# - always
|
||||||
- name: Include append_hash.yml
|
# - name: Include append_hash.yml
|
||||||
include_tasks:
|
# include_tasks:
|
||||||
file: tasks/append_hash.yml
|
# file: tasks/append_hash.yml
|
||||||
apply:
|
# apply:
|
||||||
tags: [ append_hash, k8s ]
|
# tags: [ append_hash, k8s ]
|
||||||
tags:
|
# tags:
|
||||||
- always
|
# - always
|
||||||
- name: Include apply.yml
|
# - name: Include apply.yml
|
||||||
include_tasks:
|
# include_tasks:
|
||||||
file: tasks/apply.yml
|
# file: tasks/apply.yml
|
||||||
apply:
|
# apply:
|
||||||
tags: [ apply, k8s ]
|
# tags: [ apply, k8s ]
|
||||||
tags:
|
# tags:
|
||||||
- always
|
# - always
|
||||||
- name: Include cluster_info.yml
|
# - name: Include cluster_info.yml
|
||||||
include_tasks:
|
# include_tasks:
|
||||||
file: tasks/cluster_info.yml
|
# file: tasks/cluster_info.yml
|
||||||
apply:
|
# apply:
|
||||||
tags: [ cluster_info, k8s ]
|
# tags: [ cluster_info, k8s ]
|
||||||
tags:
|
# tags:
|
||||||
- always
|
# - always
|
||||||
- name: Include crd.yml
|
# - name: Include crd.yml
|
||||||
include_tasks:
|
# include_tasks:
|
||||||
file: tasks/crd.yml
|
# file: tasks/crd.yml
|
||||||
apply:
|
# apply:
|
||||||
tags: [ crd, k8s ]
|
# tags: [ crd, k8s ]
|
||||||
tags:
|
# tags:
|
||||||
- always
|
# - always
|
||||||
- name: Include delete.yml
|
# - name: Include delete.yml
|
||||||
include_tasks:
|
# include_tasks:
|
||||||
file: tasks/delete.yml
|
# file: tasks/delete.yml
|
||||||
apply:
|
# apply:
|
||||||
tags: [ delete, k8s ]
|
# tags: [ delete, k8s ]
|
||||||
tags:
|
# tags:
|
||||||
- always
|
# - always
|
||||||
- name: Include exec.yml
|
# - name: Include exec.yml
|
||||||
include_tasks:
|
# include_tasks:
|
||||||
file: tasks/exec.yml
|
# file: tasks/exec.yml
|
||||||
apply:
|
# apply:
|
||||||
tags: [ exec, k8s ]
|
# tags: [ exec, k8s ]
|
||||||
tags:
|
# tags:
|
||||||
- always
|
# - always
|
||||||
- name: Include full.yml
|
# - name: Include full.yml
|
||||||
include_tasks:
|
# include_tasks:
|
||||||
file: tasks/full.yml
|
# file: tasks/full.yml
|
||||||
apply:
|
# apply:
|
||||||
tags: [ full, k8s ]
|
# tags: [ full, k8s ]
|
||||||
tags:
|
# tags:
|
||||||
- always
|
# - always
|
||||||
- name: Include gc.yml
|
# - name: Include gc.yml
|
||||||
include_tasks:
|
# include_tasks:
|
||||||
file: tasks/gc.yml
|
# file: tasks/gc.yml
|
||||||
apply:
|
# apply:
|
||||||
tags: [ gc, k8s ]
|
# tags: [ gc, k8s ]
|
||||||
tags:
|
# tags:
|
||||||
- always
|
# - always
|
||||||
- name: Include info.yml
|
# - name: Include info.yml
|
||||||
include_tasks:
|
# include_tasks:
|
||||||
file: tasks/info.yml
|
# file: tasks/info.yml
|
||||||
apply:
|
# apply:
|
||||||
tags: [ info, k8s ]
|
# tags: [ info, k8s ]
|
||||||
tags:
|
# tags:
|
||||||
- always
|
# - always
|
||||||
- name: Include lists.yml
|
# - name: Include lists.yml
|
||||||
include_tasks:
|
# include_tasks:
|
||||||
file: tasks/lists.yml
|
# file: tasks/lists.yml
|
||||||
apply:
|
# apply:
|
||||||
tags: [ lists, k8s ]
|
# tags: [ lists, k8s ]
|
||||||
tags:
|
# tags:
|
||||||
- always
|
# - always
|
||||||
- name: Include log.yml
|
# - name: Include log.yml
|
||||||
include_tasks:
|
# include_tasks:
|
||||||
file: tasks/log.yml
|
# file: tasks/log.yml
|
||||||
apply:
|
# apply:
|
||||||
tags: [ log, k8s ]
|
# tags: [ log, k8s ]
|
||||||
tags:
|
# tags:
|
||||||
- always
|
# - always
|
||||||
- name: Include rollback.yml
|
# - name: Include rollback.yml
|
||||||
include_tasks:
|
# include_tasks:
|
||||||
file: tasks/rollback.yml
|
# file: tasks/rollback.yml
|
||||||
apply:
|
# apply:
|
||||||
tags: [ rollback, k8s ]
|
# tags: [ rollback, k8s ]
|
||||||
tags:
|
# tags:
|
||||||
- always
|
# - always
|
||||||
- name: Include scale.yml
|
# - name: Include scale.yml
|
||||||
include_tasks:
|
# include_tasks:
|
||||||
file: tasks/scale.yml
|
# file: tasks/scale.yml
|
||||||
apply:
|
# apply:
|
||||||
tags: [ scale, k8s ]
|
# tags: [ scale, k8s ]
|
||||||
tags:
|
# tags:
|
||||||
- always
|
# - always
|
||||||
- name: Include template.yml
|
# - name: Include template.yml
|
||||||
include_tasks:
|
# include_tasks:
|
||||||
file: tasks/template.yml
|
# file: tasks/template.yml
|
||||||
apply:
|
# apply:
|
||||||
tags: [ template, k8s ]
|
# tags: [ template, k8s ]
|
||||||
tags:
|
# tags:
|
||||||
- always
|
# - always
|
||||||
- name: Include waiter.yml
|
- name: Include waiter.yml
|
||||||
include_tasks:
|
include_tasks:
|
||||||
file: tasks/waiter.yml
|
file: tasks/waiter.yml
|
||||||
@@ -149,10 +149,10 @@
|
|||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
|
|
||||||
roles:
|
# roles:
|
||||||
- role: helm
|
# - role: helm
|
||||||
tags:
|
# tags:
|
||||||
- helm
|
# - helm
|
||||||
|
|
||||||
post_tasks:
|
post_tasks:
|
||||||
- name: Ensure namespace exists
|
- name: Ensure namespace exists
|
||||||
|
|||||||
@@ -11,358 +11,358 @@
|
|||||||
metadata:
|
metadata:
|
||||||
name: "{{ wait_namespace }}"
|
name: "{{ wait_namespace }}"
|
||||||
|
|
||||||
- name: Add a simple pod
|
# - name: Add a simple pod
|
||||||
k8s:
|
# k8s:
|
||||||
definition:
|
# definition:
|
||||||
apiVersion: v1
|
# apiVersion: v1
|
||||||
kind: Pod
|
# kind: Pod
|
||||||
metadata:
|
# metadata:
|
||||||
name: "{{ k8s_pod_name }}"
|
# name: "{{ k8s_pod_name }}"
|
||||||
namespace: "{{ wait_namespace }}"
|
# namespace: "{{ wait_namespace }}"
|
||||||
spec: "{{ k8s_pod_spec }}"
|
# spec: "{{ k8s_pod_spec }}"
|
||||||
wait: yes
|
# wait: yes
|
||||||
vars:
|
# vars:
|
||||||
k8s_pod_name: wait-pod
|
# k8s_pod_name: wait-pod
|
||||||
k8s_pod_image: alpine:3.8
|
# k8s_pod_image: alpine:3.8
|
||||||
k8s_pod_command:
|
# k8s_pod_command:
|
||||||
- sleep
|
# - sleep
|
||||||
- "10000"
|
# - "10000"
|
||||||
register: wait_pod
|
# register: wait_pod
|
||||||
ignore_errors: yes
|
# ignore_errors: yes
|
||||||
|
|
||||||
- name: Assert that pod creation succeeded
|
# - name: Assert that pod creation succeeded
|
||||||
assert:
|
# assert:
|
||||||
that:
|
# that:
|
||||||
- wait_pod is successful
|
# - wait_pod is successful
|
||||||
|
|
||||||
- name: Add a daemonset
|
# - name: Add a daemonset
|
||||||
k8s:
|
# k8s:
|
||||||
definition:
|
# definition:
|
||||||
apiVersion: apps/v1
|
# apiVersion: apps/v1
|
||||||
kind: DaemonSet
|
# kind: DaemonSet
|
||||||
metadata:
|
# metadata:
|
||||||
name: wait-daemonset
|
# name: wait-daemonset
|
||||||
namespace: "{{ wait_namespace }}"
|
# namespace: "{{ wait_namespace }}"
|
||||||
spec:
|
# spec:
|
||||||
selector:
|
# selector:
|
||||||
matchLabels:
|
# matchLabels:
|
||||||
app: "{{ k8s_pod_name }}"
|
# app: "{{ k8s_pod_name }}"
|
||||||
template: "{{ k8s_pod_template }}"
|
# template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
# wait: yes
|
||||||
wait_sleep: 5
|
# wait_sleep: 5
|
||||||
wait_timeout: 180
|
# wait_timeout: 180
|
||||||
vars:
|
# vars:
|
||||||
k8s_pod_name: wait-ds
|
# k8s_pod_name: wait-ds
|
||||||
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1
|
# k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1
|
||||||
k8s_pod_command:
|
# k8s_pod_command:
|
||||||
- sleep
|
# - sleep
|
||||||
- "600"
|
# - "600"
|
||||||
register: ds
|
# register: ds
|
||||||
|
|
||||||
- name: Check that daemonset wait worked
|
# - name: Check that daemonset wait worked
|
||||||
assert:
|
# assert:
|
||||||
that:
|
# that:
|
||||||
- ds.result.status.currentNumberScheduled == ds.result.status.desiredNumberScheduled
|
# - ds.result.status.currentNumberScheduled == ds.result.status.desiredNumberScheduled
|
||||||
|
|
||||||
- name: Update a daemonset in check_mode
|
# - name: Update a daemonset in check_mode
|
||||||
k8s:
|
# k8s:
|
||||||
definition:
|
# definition:
|
||||||
apiVersion: apps/v1
|
# apiVersion: apps/v1
|
||||||
kind: DaemonSet
|
# kind: DaemonSet
|
||||||
metadata:
|
# metadata:
|
||||||
name: wait-daemonset
|
# name: wait-daemonset
|
||||||
namespace: "{{ wait_namespace }}"
|
# namespace: "{{ wait_namespace }}"
|
||||||
spec:
|
# spec:
|
||||||
selector:
|
# selector:
|
||||||
matchLabels:
|
# matchLabels:
|
||||||
app: "{{ k8s_pod_name }}"
|
# app: "{{ k8s_pod_name }}"
|
||||||
updateStrategy:
|
# updateStrategy:
|
||||||
type: RollingUpdate
|
# type: RollingUpdate
|
||||||
template: "{{ k8s_pod_template }}"
|
# template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
# wait: yes
|
||||||
wait_sleep: 3
|
# wait_sleep: 3
|
||||||
wait_timeout: 180
|
# wait_timeout: 180
|
||||||
vars:
|
# vars:
|
||||||
k8s_pod_name: wait-ds
|
# k8s_pod_name: wait-ds
|
||||||
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:2
|
# k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:2
|
||||||
k8s_pod_command:
|
# k8s_pod_command:
|
||||||
- sleep
|
# - sleep
|
||||||
- "600"
|
# - "600"
|
||||||
register: update_ds_check_mode
|
# register: update_ds_check_mode
|
||||||
check_mode: yes
|
# check_mode: yes
|
||||||
|
|
||||||
- name: Check that check_mode result contains the changes
|
# - name: Check that check_mode result contains the changes
|
||||||
assert:
|
# assert:
|
||||||
that:
|
# that:
|
||||||
- update_ds_check_mode is changed
|
# - update_ds_check_mode is changed
|
||||||
- "update_ds_check_mode.result.spec.template.spec.containers[0].image == 'gcr.io/kuar-demo/kuard-amd64:2'"
|
# - "update_ds_check_mode.result.spec.template.spec.containers[0].image == 'gcr.io/kuar-demo/kuard-amd64:2'"
|
||||||
|
|
||||||
- name: Update a daemonset
|
# - name: Update a daemonset
|
||||||
k8s:
|
# k8s:
|
||||||
definition:
|
# definition:
|
||||||
apiVersion: apps/v1
|
# apiVersion: apps/v1
|
||||||
kind: DaemonSet
|
# kind: DaemonSet
|
||||||
metadata:
|
# metadata:
|
||||||
name: wait-daemonset
|
# name: wait-daemonset
|
||||||
namespace: "{{ wait_namespace }}"
|
# namespace: "{{ wait_namespace }}"
|
||||||
spec:
|
# spec:
|
||||||
selector:
|
# selector:
|
||||||
matchLabels:
|
# matchLabels:
|
||||||
app: "{{ k8s_pod_name }}"
|
# app: "{{ k8s_pod_name }}"
|
||||||
updateStrategy:
|
# updateStrategy:
|
||||||
type: RollingUpdate
|
# type: RollingUpdate
|
||||||
template: "{{ k8s_pod_template }}"
|
# template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
# wait: yes
|
||||||
wait_sleep: 3
|
# wait_sleep: 3
|
||||||
wait_timeout: 180
|
# wait_timeout: 180
|
||||||
vars:
|
# vars:
|
||||||
k8s_pod_name: wait-ds
|
# k8s_pod_name: wait-ds
|
||||||
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:3
|
# k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:3
|
||||||
k8s_pod_command:
|
# k8s_pod_command:
|
||||||
- sleep
|
# - sleep
|
||||||
- "600"
|
# - "600"
|
||||||
register: ds
|
# register: ds
|
||||||
|
|
||||||
- name: Get updated pods
|
# - name: Get updated pods
|
||||||
k8s_info:
|
# k8s_info:
|
||||||
api_version: v1
|
# api_version: v1
|
||||||
kind: Pod
|
# kind: Pod
|
||||||
namespace: "{{ wait_namespace }}"
|
# namespace: "{{ wait_namespace }}"
|
||||||
label_selectors:
|
# label_selectors:
|
||||||
- app=wait-ds
|
# - app=wait-ds
|
||||||
field_selectors:
|
# field_selectors:
|
||||||
- status.phase=Running
|
# - status.phase=Running
|
||||||
register: updated_ds_pods
|
# register: updated_ds_pods
|
||||||
|
|
||||||
- name: Check that daemonset wait worked
|
# - name: Check that daemonset wait worked
|
||||||
assert:
|
# assert:
|
||||||
that:
|
# that:
|
||||||
- ds.result.status.currentNumberScheduled == ds.result.status.desiredNumberScheduled
|
# - ds.result.status.currentNumberScheduled == ds.result.status.desiredNumberScheduled
|
||||||
- updated_ds_pods.resources[0].spec.containers[0].image.endswith(":3")
|
# - updated_ds_pods.resources[0].spec.containers[0].image.endswith(":3")
|
||||||
|
|
||||||
- name: Add a crashing pod
|
# - name: Add a crashing pod
|
||||||
k8s:
|
# k8s:
|
||||||
definition:
|
# definition:
|
||||||
apiVersion: v1
|
# apiVersion: v1
|
||||||
kind: Pod
|
# kind: Pod
|
||||||
metadata:
|
# metadata:
|
||||||
name: "{{ k8s_pod_name }}"
|
# name: "{{ k8s_pod_name }}"
|
||||||
namespace: "{{ wait_namespace }}"
|
# namespace: "{{ wait_namespace }}"
|
||||||
spec: "{{ k8s_pod_spec }}"
|
# spec: "{{ k8s_pod_spec }}"
|
||||||
wait: yes
|
# wait: yes
|
||||||
wait_sleep: 1
|
# wait_sleep: 1
|
||||||
wait_timeout: 30
|
# wait_timeout: 30
|
||||||
vars:
|
# vars:
|
||||||
k8s_pod_name: wait-crash-pod
|
# k8s_pod_name: wait-crash-pod
|
||||||
k8s_pod_image: alpine:3.8
|
# k8s_pod_image: alpine:3.8
|
||||||
k8s_pod_command:
|
# k8s_pod_command:
|
||||||
- /bin/false
|
# - /bin/false
|
||||||
register: crash_pod
|
# register: crash_pod
|
||||||
ignore_errors: yes
|
# ignore_errors: yes
|
||||||
|
|
||||||
- name: Check that task failed
|
# - name: Check that task failed
|
||||||
assert:
|
# assert:
|
||||||
that:
|
# that:
|
||||||
- crash_pod is failed
|
# - crash_pod is failed
|
||||||
|
|
||||||
- name: Use a non-existent image
|
# - name: Use a non-existent image
|
||||||
k8s:
|
# k8s:
|
||||||
definition:
|
# definition:
|
||||||
apiVersion: v1
|
# apiVersion: v1
|
||||||
kind: Pod
|
# kind: Pod
|
||||||
metadata:
|
# metadata:
|
||||||
name: "{{ k8s_pod_name }}"
|
# name: "{{ k8s_pod_name }}"
|
||||||
namespace: "{{ wait_namespace }}"
|
# namespace: "{{ wait_namespace }}"
|
||||||
spec: "{{ k8s_pod_spec }}"
|
# spec: "{{ k8s_pod_spec }}"
|
||||||
wait: yes
|
# wait: yes
|
||||||
wait_sleep: 1
|
# wait_sleep: 1
|
||||||
wait_timeout: 30
|
# wait_timeout: 30
|
||||||
vars:
|
# vars:
|
||||||
k8s_pod_name: wait-no-image-pod
|
# k8s_pod_name: wait-no-image-pod
|
||||||
k8s_pod_image: i_made_this_up:and_this_too
|
# k8s_pod_image: i_made_this_up:and_this_too
|
||||||
register: no_image_pod
|
# register: no_image_pod
|
||||||
ignore_errors: yes
|
# ignore_errors: yes
|
||||||
|
|
||||||
- name: Check that task failed
|
# - name: Check that task failed
|
||||||
assert:
|
# assert:
|
||||||
that:
|
# that:
|
||||||
- no_image_pod is failed
|
# - no_image_pod is failed
|
||||||
|
|
||||||
- name: Add a deployment
|
# - name: Add a deployment
|
||||||
k8s:
|
# k8s:
|
||||||
definition:
|
# definition:
|
||||||
apiVersion: apps/v1
|
# apiVersion: apps/v1
|
||||||
kind: Deployment
|
# kind: Deployment
|
||||||
metadata:
|
# metadata:
|
||||||
name: wait-deploy
|
# name: wait-deploy
|
||||||
namespace: "{{ wait_namespace }}"
|
# namespace: "{{ wait_namespace }}"
|
||||||
spec:
|
# spec:
|
||||||
replicas: 3
|
# replicas: 3
|
||||||
selector:
|
# selector:
|
||||||
matchLabels:
|
# matchLabels:
|
||||||
app: "{{ k8s_pod_name }}"
|
# app: "{{ k8s_pod_name }}"
|
||||||
template: "{{ k8s_pod_template }}"
|
# template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
# wait: yes
|
||||||
vars:
|
# vars:
|
||||||
k8s_pod_name: wait-deploy
|
# k8s_pod_name: wait-deploy
|
||||||
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1
|
# k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1
|
||||||
k8s_pod_ports:
|
# k8s_pod_ports:
|
||||||
- containerPort: 8080
|
# - containerPort: 8080
|
||||||
name: http
|
# name: http
|
||||||
protocol: TCP
|
# protocol: TCP
|
||||||
|
|
||||||
register: deploy
|
# register: deploy
|
||||||
|
|
||||||
- name: Check that deployment wait worked
|
# - name: Check that deployment wait worked
|
||||||
assert:
|
# assert:
|
||||||
that:
|
# that:
|
||||||
- deploy.result.status.availableReplicas == deploy.result.status.replicas
|
# - deploy.result.status.availableReplicas == deploy.result.status.replicas
|
||||||
|
|
||||||
- name: Update a deployment
|
# - name: Update a deployment
|
||||||
k8s:
|
# k8s:
|
||||||
definition:
|
# definition:
|
||||||
apiVersion: apps/v1
|
# apiVersion: apps/v1
|
||||||
kind: Deployment
|
# kind: Deployment
|
||||||
metadata:
|
# metadata:
|
||||||
name: wait-deploy
|
# name: wait-deploy
|
||||||
namespace: "{{ wait_namespace }}"
|
# namespace: "{{ wait_namespace }}"
|
||||||
spec:
|
# spec:
|
||||||
replicas: 3
|
# replicas: 3
|
||||||
selector:
|
# selector:
|
||||||
matchLabels:
|
# matchLabels:
|
||||||
app: "{{ k8s_pod_name }}"
|
# app: "{{ k8s_pod_name }}"
|
||||||
template: "{{ k8s_pod_template }}"
|
# template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
# wait: yes
|
||||||
vars:
|
# vars:
|
||||||
k8s_pod_name: wait-deploy
|
# k8s_pod_name: wait-deploy
|
||||||
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:2
|
# k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:2
|
||||||
k8s_pod_ports:
|
# k8s_pod_ports:
|
||||||
- containerPort: 8080
|
# - containerPort: 8080
|
||||||
name: http
|
# name: http
|
||||||
protocol: TCP
|
# protocol: TCP
|
||||||
register: update_deploy
|
# register: update_deploy
|
||||||
|
|
||||||
# It looks like the Deployment is updated to have the desired state *before* the pods are terminated
|
# # It looks like the Deployment is updated to have the desired state *before* the pods are terminated
|
||||||
# Wait a couple of seconds to allow the old pods to at least get to Terminating state
|
# # Wait a couple of seconds to allow the old pods to at least get to Terminating state
|
||||||
- name: Avoid race condition
|
# - name: Avoid race condition
|
||||||
pause:
|
# pause:
|
||||||
seconds: 2
|
# seconds: 2
|
||||||
|
|
||||||
- name: Get updated pods
|
# - name: Get updated pods
|
||||||
k8s_info:
|
# k8s_info:
|
||||||
api_version: v1
|
# api_version: v1
|
||||||
kind: Pod
|
# kind: Pod
|
||||||
namespace: "{{ wait_namespace }}"
|
# namespace: "{{ wait_namespace }}"
|
||||||
label_selectors:
|
# label_selectors:
|
||||||
- app=wait-deploy
|
# - app=wait-deploy
|
||||||
field_selectors:
|
# field_selectors:
|
||||||
- status.phase=Running
|
# - status.phase=Running
|
||||||
register: updated_deploy_pods
|
# register: updated_deploy_pods
|
||||||
until: updated_deploy_pods.resources[0].spec.containers[0].image.endswith(':2')
|
# until: updated_deploy_pods.resources[0].spec.containers[0].image.endswith(':2')
|
||||||
retries: 6
|
# retries: 6
|
||||||
delay: 5
|
# delay: 5
|
||||||
|
|
||||||
- name: Check that deployment wait worked
|
# - name: Check that deployment wait worked
|
||||||
assert:
|
# assert:
|
||||||
that:
|
# that:
|
||||||
- deploy.result.status.availableReplicas == deploy.result.status.replicas
|
# - deploy.result.status.availableReplicas == deploy.result.status.replicas
|
||||||
|
|
||||||
- name: Pause a deployment
|
# - name: Pause a deployment
|
||||||
k8s:
|
# k8s:
|
||||||
definition:
|
# definition:
|
||||||
apiVersion: apps/v1
|
# apiVersion: apps/v1
|
||||||
kind: Deployment
|
# kind: Deployment
|
||||||
metadata:
|
# metadata:
|
||||||
name: wait-deploy
|
# name: wait-deploy
|
||||||
namespace: "{{ wait_namespace }}"
|
# namespace: "{{ wait_namespace }}"
|
||||||
spec:
|
# spec:
|
||||||
paused: True
|
# paused: True
|
||||||
apply: no
|
# apply: no
|
||||||
wait: yes
|
# wait: yes
|
||||||
wait_condition:
|
# wait_condition:
|
||||||
type: Progressing
|
# type: Progressing
|
||||||
status: Unknown
|
# status: Unknown
|
||||||
reason: DeploymentPaused
|
# reason: DeploymentPaused
|
||||||
register: pause_deploy
|
# register: pause_deploy
|
||||||
|
|
||||||
- name: Check that paused deployment wait worked
|
# - name: Check that paused deployment wait worked
|
||||||
assert:
|
# assert:
|
||||||
that:
|
# that:
|
||||||
- condition.reason == "DeploymentPaused"
|
# - condition.reason == "DeploymentPaused"
|
||||||
- condition.status == "Unknown"
|
# - condition.status == "Unknown"
|
||||||
vars:
|
# vars:
|
||||||
condition: '{{ pause_deploy.result.status.conditions[1] }}'
|
# condition: '{{ pause_deploy.result.status.conditions[1] }}'
|
||||||
|
|
||||||
- name: Add a service based on the deployment
|
# - name: Add a service based on the deployment
|
||||||
k8s:
|
# k8s:
|
||||||
definition:
|
# definition:
|
||||||
apiVersion: v1
|
# apiVersion: v1
|
||||||
kind: Service
|
# kind: Service
|
||||||
metadata:
|
# metadata:
|
||||||
name: wait-svc
|
# name: wait-svc
|
||||||
namespace: "{{ wait_namespace }}"
|
# namespace: "{{ wait_namespace }}"
|
||||||
spec:
|
# spec:
|
||||||
selector:
|
# selector:
|
||||||
app: "{{ k8s_pod_name }}"
|
# app: "{{ k8s_pod_name }}"
|
||||||
ports:
|
# ports:
|
||||||
- port: 8080
|
# - port: 8080
|
||||||
targetPort: 8080
|
# targetPort: 8080
|
||||||
protocol: TCP
|
# protocol: TCP
|
||||||
wait: yes
|
# wait: yes
|
||||||
vars:
|
# vars:
|
||||||
k8s_pod_name: wait-deploy
|
# k8s_pod_name: wait-deploy
|
||||||
register: service
|
# register: service
|
||||||
|
|
||||||
- name: Assert that waiting for service works
|
# - name: Assert that waiting for service works
|
||||||
assert:
|
# assert:
|
||||||
that:
|
# that:
|
||||||
- service is successful
|
# - service is successful
|
||||||
|
|
||||||
- name: Add a crashing deployment
|
# - name: Add a crashing deployment
|
||||||
k8s:
|
# k8s:
|
||||||
definition:
|
# definition:
|
||||||
apiVersion: apps/v1
|
# apiVersion: apps/v1
|
||||||
kind: Deployment
|
# kind: Deployment
|
||||||
metadata:
|
# metadata:
|
||||||
name: wait-crash-deploy
|
# name: wait-crash-deploy
|
||||||
namespace: "{{ wait_namespace }}"
|
# namespace: "{{ wait_namespace }}"
|
||||||
spec:
|
# spec:
|
||||||
replicas: 3
|
# replicas: 3
|
||||||
selector:
|
# selector:
|
||||||
matchLabels:
|
# matchLabels:
|
||||||
app: "{{ k8s_pod_name }}"
|
# app: "{{ k8s_pod_name }}"
|
||||||
template: "{{ k8s_pod_template }}"
|
# template: "{{ k8s_pod_template }}"
|
||||||
wait: yes
|
# wait: yes
|
||||||
vars:
|
# vars:
|
||||||
k8s_pod_name: wait-crash-deploy
|
# k8s_pod_name: wait-crash-deploy
|
||||||
k8s_pod_image: alpine:3.8
|
# k8s_pod_image: alpine:3.8
|
||||||
k8s_pod_command:
|
# k8s_pod_command:
|
||||||
- /bin/false
|
# - /bin/false
|
||||||
register: wait_crash_deploy
|
# register: wait_crash_deploy
|
||||||
ignore_errors: yes
|
# ignore_errors: yes
|
||||||
|
|
||||||
- name: Check that task failed
|
# - name: Check that task failed
|
||||||
assert:
|
# assert:
|
||||||
that:
|
# that:
|
||||||
- wait_crash_deploy is failed
|
# - wait_crash_deploy is failed
|
||||||
|
|
||||||
- name: Remove Pod with very short timeout
|
# - name: Remove Pod with very short timeout
|
||||||
k8s:
|
# k8s:
|
||||||
api_version: v1
|
# api_version: v1
|
||||||
kind: Pod
|
# kind: Pod
|
||||||
name: wait-pod
|
# name: wait-pod
|
||||||
namespace: "{{ wait_namespace }}"
|
# namespace: "{{ wait_namespace }}"
|
||||||
state: absent
|
# state: absent
|
||||||
wait: yes
|
# wait: yes
|
||||||
wait_sleep: 2
|
# wait_sleep: 2
|
||||||
wait_timeout: 5
|
# wait_timeout: 5
|
||||||
ignore_errors: yes
|
# ignore_errors: yes
|
||||||
register: short_wait_remove_pod
|
# register: short_wait_remove_pod
|
||||||
|
|
||||||
- name: Check that task failed
|
# - name: Check that task failed
|
||||||
assert:
|
# assert:
|
||||||
that:
|
# that:
|
||||||
- short_wait_remove_pod is failed
|
# - short_wait_remove_pod is failed
|
||||||
|
|
||||||
- name: add a simple crashing pod and wait until container is running
|
- name: add a simple crashing pod and wait until container is running
|
||||||
k8s:
|
k8s:
|
||||||
@@ -378,6 +378,7 @@
|
|||||||
image: busybox
|
image: busybox
|
||||||
command: ['/dummy/dummy-shell', '-c', 'sleep 2000']
|
command: ['/dummy/dummy-shell', '-c', 'sleep 2000']
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_sleep: 2
|
||||||
wait_timeout: 10
|
wait_timeout: 10
|
||||||
wait_property:
|
wait_property:
|
||||||
property: status.containerStatuses[*].state.running
|
property: status.containerStatuses[*].state.running
|
||||||
@@ -405,6 +406,7 @@
|
|||||||
image: busybox
|
image: busybox
|
||||||
command: ['/bin/sh', '-c', 'sleep 10000']
|
command: ['/bin/sh', '-c', 'sleep 10000']
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_sleep: 2
|
||||||
wait_timeout: 10
|
wait_timeout: 10
|
||||||
wait_property:
|
wait_property:
|
||||||
property: status.containerStatuses[*].state.running
|
property: status.containerStatuses[*].state.running
|
||||||
@@ -439,6 +441,7 @@
|
|||||||
configMap:
|
configMap:
|
||||||
name: redis-config
|
name: redis-config
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_sleep: 2
|
||||||
wait_timeout: 10
|
wait_timeout: 10
|
||||||
wait_property:
|
wait_property:
|
||||||
property: status.containerStatuses[0].ready
|
property: status.containerStatuses[0].ready
|
||||||
|
|||||||
Reference in New Issue
Block a user