You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
599 B

  1. ---
  2. - hosts: node1
  3. tasks:
  4. - name: Get pod names
  5. shell: "/usr/local/bin/kubectl get pods -o json"
  6. register: pods
  7. - set_fact:
  8. pod_names: "{{ (pods.stdout | from_json)['items'] | map(attribute = 'metadata.name') | list }}"
  9. pod_ips: "{{ (pods.stdout | from_json)['items'] | map(attribute = 'status.podIP') | list }}"
  10. - name: Check pods IP are in correct network
  11. assert:
  12. that: item | ipaddr(kube_pods_subnet)
  13. with_items: pod_ips
  14. - name: Ping between pods is working
  15. shell: "/usr/local/bin/kubectl exec {{pod_names[0]}} -- ping -c 4 {{ pod_ips[1] }}"