diff --git a/playbooks/must-gather.yml b/playbooks/must-gather.yml new file mode 100644 index 000000000..27456b8d8 --- /dev/null +++ b/playbooks/must-gather.yml @@ -0,0 +1,5 @@ +--- +- name: Collect must-gather logs + hosts: bastion + roles: + - must-gather \ No newline at end of file diff --git a/playbooks/pod-affinity-test.yml b/playbooks/pod-affinity-test.yml new file mode 100644 index 000000000..633a11a38 --- /dev/null +++ b/playbooks/pod-affinity-test.yml @@ -0,0 +1,5 @@ +--- +- name: Run pod affinity and pause pod test + hosts: bastion + roles: + - pod-affinity-test \ No newline at end of file diff --git a/playbooks/roles/must-gather/defaults/main.yml b/playbooks/roles/must-gather/defaults/main.yml new file mode 100644 index 000000000..be2fa106b --- /dev/null +++ b/playbooks/roles/must-gather/defaults/main.yml @@ -0,0 +1,5 @@ +--- +#defaults file for playbooks/rokes/must-gather +must_gather_dest: /home/must_gather_logs +must_gather_archive: /home/must-gather-logs.tar.gz +#must_gather_local_path: ./must-gather-logs.tar.gz \ No newline at end of file diff --git a/playbooks/roles/must-gather/tasks/main.yml b/playbooks/roles/must-gather/tasks/main.yml new file mode 100644 index 000000000..8cc1d5fd6 --- /dev/null +++ b/playbooks/roles/must-gather/tasks/main.yml @@ -0,0 +1,30 @@ +--- +- name: Run oc adm must-gather + command: oc adm must-gather --dest-dir={{ must_gather_dest }} + args: + creates: "{{ must_gather_dest }}/cluster-scoped-resources" + register: must_gather_output + +- debug: + var: must_gather_output.stdout_lines + +- name: Set permissions for must-gather directory + file: + path: "{{ must_gather_dest }}" + owner: root + group: root + mode: '0755' + state: directory + +- name: Compress must-gather logs + command: tar -czf {{ must_gather_archive }} -C {{ must_gather_dest | dirname }} {{ must_gather_dest | basename }} + args: + creates: "{{ must_gather_archive }}" + +- name: Set permissions for must-gather tarball + file: + path: "{{ must_gather_archive }}" + owner: root + group: root + mode: '0644' + state: file diff --git a/playbooks/roles/pod-affinity-test/defaults/main.yml b/playbooks/roles/pod-affinity-test/defaults/main.yml new file mode 100644 index 000000000..e69de29bb diff --git a/playbooks/roles/pod-affinity-test/tasks/main.yml b/playbooks/roles/pod-affinity-test/tasks/main.yml new file mode 100644 index 000000000..b3413de81 --- /dev/null +++ b/playbooks/roles/pod-affinity-test/tasks/main.yml @@ -0,0 +1,86 @@ +--- +- name: Create PPC pod with affinity + kubernetes.core.k8s: + state: present + definition: + apiVersion: v1 + kind: Pod + metadata: + name: ppc-pod + namespace: default + spec: + affinity: + nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 70 + preference: + matchExpressions: + - key: kubernetes.io/arch + operator: In + values: + - ppc64le + - weight: 30 + preference: + matchExpressions: + - key: kubernetes.io/arch + operator: NotIn + values: + - ppc64le + containers: + - name: web + image: registry.redhat.io/ubi8/pause + +- name: Create x86 pod with anti-affinity + kubernetes.core.k8s: + state: present + definition: + apiVersion: v1 + kind: Pod + metadata: + name: x86-pod + namespace: default + spec: + affinity: + nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 30 + preference: + matchExpressions: + - key: kubernetes.io/arch + operator: In + values: + - ppc64le + - weight: 70 + preference: + matchExpressions: + - key: kubernetes.io/arch + operator: NotIn + values: + - ppc64le + containers: + - name: web + image: registry.redhat.io/ubi8/pause + +- name: Wait until pods are running + command: oc get pods -n default --no-headers + register: pod_status + until: "'Running' in pod_status.stdout" + retries: 10 + delay: 10 + +- name: Launch multiple pause pods + shell: | + for n in $(seq 1 60); do + oc run pause-pod-$n --image=ubi8/pause:8.8-9 -n default + done + +- name: Verify all pods running + command: oc get pods -n default -o wide + register: pause_pod_status + changed_when: false + +- debug: + msg: "{{ pause_pod_status.stdout_lines }}" + +- name: Cleanup - delete all pods + command: oc delete pods --all -n default \ No newline at end of file diff --git a/playbooks/roles/smoke-test/tasks/main.yml b/playbooks/roles/smoke-test/tasks/main.yml new file mode 100644 index 000000000..74cd13098 --- /dev/null +++ b/playbooks/roles/smoke-test/tasks/main.yml @@ -0,0 +1,79 @@ +--- +- name: Create and debug pods with node affinity + # hosts: bastion + tasks: + + - name: Create PPC pod with affinity (ppc64le) + kubernetes.core.k8s: + state: present + definition: + apiVersion: v1 + kind: Pod + metadata: + name: ppc-pod + namespace: default + spec: + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/arch + operator: In + values: [ppc64le] + containers: + - name: web + image: registry.redhat.io/ubi8/pause + + - name: Create x86 pod with affinity (amd64) + kubernetes.core.k8s: + state: present + definition: + apiVersion: v1 + kind: Pod + metadata: + name: x86-pod + namespace: default + spec: + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/arch + operator: In + values: [amd64] + containers: + - name: web + image: registry.redhat.io/ubi8/pause + + - name: Wait for both pods to be Running + shell: oc get pods ppc-pod x86-pod -n default --no-headers + register: pod_status + until: "'Running' in pod_status.stdout" + retries: 10 + delay: 10 + + - name: Show pod status + command: oc get pods -o wide -n default + register: pod_list + changed_when: false + + - debug: + msg: "{{ pod_list.stdout_lines }}" + + - name: Debug x86 pod (ls inside container) + shell: | + oc debug pod/x86-pod -n default -- ls + register: debug_x86 + + - debug: + msg: "{{ debug_x86.stdout_lines }}" + + - name: Debug ppc pod (ls inside container) + shell: | + oc debug pod/ppc-pod -n default -- ls + register: debug_ppc + + - debug: + msg: "{{ debug_ppc.stdout_lines }}" diff --git a/playbooks/smoke-test.yml b/playbooks/smoke-test.yml new file mode 100644 index 000000000..bc510e95e --- /dev/null +++ b/playbooks/smoke-test.yml @@ -0,0 +1,5 @@ +--- +- name: Deploy and verify arch-specific pods + hosts: bastion + roles: + - smoke-test