89 lines
2.6 KiB
YAML
89 lines
2.6 KiB
YAML
- block:
|
|
|
|
- name: Wait for the specified ramp time before injecting chaos
|
|
wait_for: timeout="{{ ramp_time }}"
|
|
when: "ramp_time is defined and ramp_time != ''"
|
|
|
|
## RECORD EVENT FOR CHAOS INJECTION
|
|
- include_tasks: /utils/common/generate-kubernetes-chaos-events.yml
|
|
vars:
|
|
stage: "ChaosInject"
|
|
exp_pod_name: "{{ chaos_pod_name }}"
|
|
engine_ns: "{{ a_ns }}"
|
|
message: "Injecting {{ c_experiment }} chaos on application pod"
|
|
when: "c_engine is defined and c_engine != ''"
|
|
|
|
- name: Generate the powerfulseal deployment spec from template
|
|
template:
|
|
src: /chaoslib/powerfulseal/powerfulseal.j2
|
|
dest: powerfulseal.yml
|
|
|
|
- name: Setup powerfulseal to initiate random pod chaos
|
|
shell:
|
|
kubectl apply -f powerfulseal.yml -n {{ app_ns }}
|
|
args:
|
|
executable: /bin/bash
|
|
register: deployment_result
|
|
failed_when: "deployment_result.rc != 0"
|
|
|
|
- name: Confirm that powerfulseal pod is running
|
|
shell: >
|
|
kubectl get pod -l name=powerfulseal --no-headers -n {{ app_ns }}
|
|
args:
|
|
executable: /bin/bash
|
|
register: result
|
|
until: "'Running' in result.stdout"
|
|
delay: 2
|
|
retries: 90
|
|
|
|
- name: Wait for chaos duration
|
|
wait_for: timeout="{{ c_duration }}"
|
|
|
|
- name: Wait for the specified ramp time after injecting chaos
|
|
wait_for: timeout="{{ ramp_time }}"
|
|
when: "ramp_time is defined and ramp_time != ''"
|
|
|
|
- name: Tear down the powerfulseal deployment
|
|
shell:
|
|
kubectl delete -f powerfulseal.yml -n {{ app_ns }}
|
|
args:
|
|
executable: /bin/bash
|
|
register: result
|
|
failed_when: "result.rc != 0"
|
|
|
|
- name: Confirm that powerfulseal pod is cleaned up
|
|
k8s_facts:
|
|
kind: Deployment
|
|
label_selectors:
|
|
- name=powerfulseal
|
|
register: resource_deployment
|
|
until: "resource_deployment.resources | length < 1"
|
|
delay: 2
|
|
retries: 90
|
|
|
|
rescue:
|
|
|
|
- block:
|
|
|
|
- name: Tear down the powerfulseal deployment
|
|
shell: >
|
|
kubectl delete -f powerfulseal.yml -n {{ app_ns }}
|
|
args:
|
|
executable: /bin/bash
|
|
when: deployment_result.rc == 0
|
|
|
|
- name: Confirm that powerfulseal pod is cleaned up
|
|
k8s_facts:
|
|
kind: Deployment
|
|
label_selectors:
|
|
- name=powerfulseal
|
|
register: resource_deployment
|
|
until: "resource_deployment.resources | length < 1"
|
|
delay: 2
|
|
retries: 90
|
|
|
|
when: "deployment_result is defined"
|
|
|
|
- fail:
|
|
msg: "pod_failure_by_powerfulseal lib failed"
|
|
when: true |