diff options
Diffstat (limited to 'roles/onap-chaos-tests/tasks/pod-delete-sdnc.yaml')
-rw-r--r-- | roles/onap-chaos-tests/tasks/pod-delete-sdnc.yaml | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/roles/onap-chaos-tests/tasks/pod-delete-sdnc.yaml b/roles/onap-chaos-tests/tasks/pod-delete-sdnc.yaml new file mode 100644 index 0000000..d46fdd1 --- /dev/null +++ b/roles/onap-chaos-tests/tasks/pod-delete-sdnc.yaml @@ -0,0 +1,76 @@ +--- +- name: Get compute node list + community.kubernetes.k8s_info: + kind: Node + label_selectors: "! node-role.kubernetes.io/master" + register: kubernetes_computer_node_list + +- name: Set Fact first compute node Internal IP + ansible.builtin.set_fact: + first_node_ip: "{{ item.address }}" + when: "'Hostname' in item.type" + with_items: + "{{ (kubernetes_computer_node_list.resources | first).status.addresses }}" + +- name: Set Compute for the drain chaos + ansible.builtin.set_fact: + compute_chaos: "{{ first_node_ip }}" + when: compute_chaos is not defined + +- name: Prepare rbac file for drain experiment + ansible.builtin.template: + src: drain-rbac.yaml.j2 + dest: /tmp/drain-rbac.yaml + mode: 0600 + +- name: Prepare chaos file for drain experiment + ansible.builtin.template: + src: drain-chaos.yaml.j2 + dest: /tmp/drain-chaos.yaml + mode: 0600 + +- name: Apply drain rbac + community.kubernetes.k8s: + state: present + src: /tmp/drain-rbac.yaml + +- name: Cordon the Chosen node + ansible.builtin.shell: "kubectl cordon {{ compute_chaos }}" + +- name: Apply chaos drain experiment + community.kubernetes.k8s: + state: present + src: /tmp/drain-chaos.yaml + +- name: wait for the end of chaos + run_once: true + community.kubernetes.k8s_info: + kind: ChaosEngine + api_version: litmuschaos.io/v1alpha1 + name: onap-chaos + namespace: "{{ onap_namespace }}" + register: chaosengine_status + changed_when: + &chaos_test chaosengine_status is defined and + chaosengine_status.resources[0].status.engineStatus == "completed" + until: *chaos_test + retries: 5 + delay: 120 + +- name: get results + run_once: true + community.kubernetes.k8s_info: + kind: ChaosResult + api_version: litmuschaos.io/v1alpha1 + name: onap-chaos-node-drain + namespace: "{{ onap_namespace }}" + register: chaosresult_drain + changed_when: + &chaos_result chaosresult_drain is defined and + chaosresult_drain.resources[0].status.experimentStatus.verdict == "Pass" + until: *chaos_result + retries: 5 + delay: 10 + +- name: Uncordon the Chosen node + ansible.builtin.shell: "kubectl uncordon {{ compute_chaos }}" |