|
1 | 1 | --- |
2 | | -- name: Create test namespace |
3 | | - command: "{{ bin_dir }}/kubectl create namespace test" |
4 | | - changed_when: false |
5 | | - |
6 | | -- name: Run 2 agnhost pods in test ns |
7 | | - command: |
8 | | - cmd: "{{ bin_dir }}/kubectl apply --namespace test -f -" |
9 | | - stdin: | |
10 | | - apiVersion: apps/v1 |
11 | | - kind: Deployment |
12 | | - metadata: |
13 | | - name: agnhost |
14 | | - spec: |
15 | | - replicas: 2 |
16 | | - selector: |
17 | | - matchLabels: |
18 | | - app: agnhost |
19 | | - template: |
20 | | - metadata: |
21 | | - labels: |
22 | | - app: agnhost |
23 | | - spec: |
24 | | - containers: |
25 | | - - name: agnhost |
26 | | - image: {{ test_image_repo }}:{{ test_image_tag }} |
27 | | - command: ['/agnhost', 'netexec', '--http-port=8080'] |
28 | | - securityContext: |
29 | | - allowPrivilegeEscalation: false |
30 | | - capabilities: |
31 | | - drop: ['ALL'] |
32 | | - runAsUser: 1000 |
33 | | - runAsNonRoot: true |
34 | | - seccompProfile: |
35 | | - type: RuntimeDefault |
36 | | - changed_when: false |
37 | | - |
38 | | -- name: Check that all pods are running and ready |
| 2 | +- name: Run the hydrophone checks |
39 | 3 | vars: |
40 | | - pods: "{{ (pods_json.stdout | from_json)['items'] }}" |
| 4 | + networking_check: "\\[sig-network\\] Networking Granular Checks.+\\[Conformance\\]" |
41 | 5 | block: |
42 | | - - name: Check Deployment is ready |
43 | | - command: "{{ bin_dir }}/kubectl rollout status deploy --namespace test agnhost --timeout=180s" |
44 | | - changed_when: false |
45 | | - - name: Get pod names |
46 | | - command: "{{ bin_dir }}/kubectl get pods -n test -o json" |
47 | | - changed_when: false |
48 | | - register: pods_json |
49 | | - |
50 | | - - name: Check pods IP are in correct network |
51 | | - assert: |
52 | | - that: pods |
53 | | - | selectattr('status.phase', '==', 'Running') |
54 | | - | selectattr('status.podIP', 'ansible.utils.in_network', kube_pods_subnet) |
55 | | - | length == 2 |
56 | | - |
57 | | - - name: Curl between pods is working |
58 | | - command: "{{ bin_dir }}/kubectl -n test exec {{ item[0].metadata.name }} -- curl {{ item[1].status.podIP | ansible.utils.ipwrap}}:8080" |
59 | | - with_nested: |
60 | | - - "{{ pods }}" |
61 | | - - "{{ pods }}" |
62 | | - loop_control: |
63 | | - label: "{{ item[0].metadata.name + ' --> ' + item[1].metadata.name }}" |
| 6 | + - name: Run the networking granular checks |
| 7 | + command: "{{ hydrophone_path }} --focus=\"{{ networking_check }}\" --parallel {{ hydrophone_parallel }}" |
64 | 8 | rescue: |
65 | 9 | - name: List pods cluster-wide |
66 | 10 | command: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide" |
|
0 commit comments