|
@ -3,13 +3,16 @@ |
|
|
hosts: kube_node |
|
|
hosts: kube_node |
|
|
tasks: |
|
|
tasks: |
|
|
- name: Test tunl0 routes |
|
|
- name: Test tunl0 routes |
|
|
shell: "set -o pipefail && ! /sbin/ip ro | grep '/{{ calico_pool_blocksize }} | default(26) via' | grep -v tunl0" |
|
|
|
|
|
args: |
|
|
|
|
|
executable: /bin/bash |
|
|
|
|
|
|
|
|
command: "/sbin/ip route" |
|
|
|
|
|
register: routes |
|
|
|
|
|
failed_when: routes.stdout_lines |
|
|
|
|
|
| select('contains', '/' ~ calico_pool_blocksize|d(26)) |
|
|
|
|
|
| select('contains', 'tunl0') | length == 0 |
|
|
when: |
|
|
when: |
|
|
- (calico_ipip_mode is defined and calico_ipip_mode != 'Never' or cloud_provider is defined) |
|
|
- (calico_ipip_mode is defined and calico_ipip_mode != 'Never' or cloud_provider is defined) |
|
|
- kube_network_plugin | default('calico') == 'calico' |
|
|
- kube_network_plugin | default('calico') == 'calico' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Advanced testcases for network |
|
|
- name: Advanced testcases for network |
|
|
hosts: k8s_cluster |
|
|
hosts: k8s_cluster |
|
|
vars: |
|
|
vars: |
|
@ -32,24 +35,14 @@ |
|
|
name: cluster-dump |
|
|
name: cluster-dump |
|
|
|
|
|
|
|
|
- name: Wait for netchecker server |
|
|
- name: Wait for netchecker server |
|
|
shell: "set -o pipefail && {{ bin_dir }}/kubectl get pods -o wide --namespace {{ netcheck_namespace }} | grep ^netchecker-server" |
|
|
|
|
|
args: |
|
|
|
|
|
executable: /bin/bash |
|
|
|
|
|
register: ncs_pod |
|
|
|
|
|
until: ncs_pod.stdout.find('Running') != -1 |
|
|
|
|
|
retries: 3 |
|
|
|
|
|
delay: 10 |
|
|
|
|
|
when: inventory_hostname == groups['kube_control_plane'][0] |
|
|
|
|
|
|
|
|
|
|
|
- name: Wait for netchecker agents |
|
|
|
|
|
shell: "set -o pipefail && {{ bin_dir }}/kubectl get pods -o wide --namespace {{ netcheck_namespace }} | grep '^netchecker-agent-.*Running'" |
|
|
|
|
|
args: |
|
|
|
|
|
executable: /bin/bash |
|
|
|
|
|
register: nca_pod |
|
|
|
|
|
until: nca_pod.stdout_lines | length >= groups['k8s_cluster'] | intersect(ansible_play_hosts) | length * 2 |
|
|
|
|
|
|
|
|
command: "{{ bin_dir }}/kubectl get pods --field-selector=status.phase==Running -o jsonpath-as-json={.items[*].metadata.name} --namespace {{ netcheck_namespace }}" |
|
|
|
|
|
register: pods_json |
|
|
|
|
|
until: |
|
|
|
|
|
- pods_json.stdout | from_json | select('match', 'netchecker-server.*') | length == 1 |
|
|
|
|
|
- (pods_json.stdout | from_json | select('match', 'netchecker-agent.*') | length) |
|
|
|
|
|
>= (groups['k8s_cluster'] | intersect(ansible_play_hosts) | length * 2) |
|
|
retries: 3 |
|
|
retries: 3 |
|
|
delay: 10 |
|
|
delay: 10 |
|
|
failed_when: false |
|
|
|
|
|
when: inventory_hostname == groups['kube_control_plane'][0] |
|
|
when: inventory_hostname == groups['kube_control_plane'][0] |
|
|
|
|
|
|
|
|
- name: Get netchecker pods |
|
|
- name: Get netchecker pods |
|
@ -60,7 +53,7 @@ |
|
|
with_items: |
|
|
with_items: |
|
|
- netchecker-agent |
|
|
- netchecker-agent |
|
|
- netchecker-agent-hostnet |
|
|
- netchecker-agent-hostnet |
|
|
when: not nca_pod is success |
|
|
|
|
|
|
|
|
when: not pods_json is success |
|
|
|
|
|
|
|
|
- debug: # noqa name[missing] |
|
|
- debug: # noqa name[missing] |
|
|
var: nca_pod.stdout_lines |
|
|
var: nca_pod.stdout_lines |
|
@ -99,7 +92,7 @@ |
|
|
- agents.content != '{}' |
|
|
- agents.content != '{}' |
|
|
|
|
|
|
|
|
- debug: # noqa name[missing] |
|
|
- debug: # noqa name[missing] |
|
|
var: ncs_pod |
|
|
|
|
|
|
|
|
var: pods_json |
|
|
run_once: true |
|
|
run_once: true |
|
|
|
|
|
|
|
|
- name: Get kube-proxy logs |
|
|
- name: Get kube-proxy logs |
|
@ -169,14 +162,9 @@ |
|
|
run_once: true |
|
|
run_once: true |
|
|
|
|
|
|
|
|
- name: Create macvlan network conf |
|
|
- name: Create macvlan network conf |
|
|
# We cannot use only shell: below because Ansible will render the text |
|
|
|
|
|
# with leading spaces, which means the shell will never find the string |
|
|
|
|
|
# EOF at the beginning of a line. We can avoid Ansible's unhelpful |
|
|
|
|
|
# heuristics by using the cmd parameter like this: |
|
|
|
|
|
shell: |
|
|
|
|
|
cmd: | |
|
|
|
|
|
set -o pipefail |
|
|
|
|
|
cat <<EOF | {{ bin_dir }}/kubectl create -f - |
|
|
|
|
|
|
|
|
command: |
|
|
|
|
|
cmd: "{{ bin_dir }}/kubectl create -f -" |
|
|
|
|
|
stdin: | |
|
|
apiVersion: "k8s.cni.cncf.io/v1" |
|
|
apiVersion: "k8s.cni.cncf.io/v1" |
|
|
kind: NetworkAttachmentDefinition |
|
|
kind: NetworkAttachmentDefinition |
|
|
metadata: |
|
|
metadata: |
|
@ -198,21 +186,7 @@ |
|
|
"gateway": "192.168.1.1" |
|
|
"gateway": "192.168.1.1" |
|
|
} |
|
|
} |
|
|
}' |
|
|
}' |
|
|
EOF |
|
|
|
|
|
executable: /bin/bash |
|
|
|
|
|
when: |
|
|
|
|
|
- inventory_hostname == groups['kube_control_plane'][0] |
|
|
|
|
|
- kube_network_plugin_multus | default(false) | bool |
|
|
|
|
|
|
|
|
|
|
|
- name: Annotate pod with macvlan network |
|
|
|
|
|
# We cannot use only shell: below because Ansible will render the text |
|
|
|
|
|
# with leading spaces, which means the shell will never find the string |
|
|
|
|
|
# EOF at the beginning of a line. We can avoid Ansible's unhelpful |
|
|
|
|
|
# heuristics by using the cmd parameter like this: |
|
|
|
|
|
shell: |
|
|
|
|
|
cmd: | |
|
|
|
|
|
set -o pipefail |
|
|
|
|
|
cat <<EOF | {{ bin_dir }}/kubectl create -f - |
|
|
|
|
|
|
|
|
--- |
|
|
apiVersion: v1 |
|
|
apiVersion: v1 |
|
|
kind: Pod |
|
|
kind: Pod |
|
|
metadata: |
|
|
metadata: |
|
@ -224,8 +198,6 @@ |
|
|
- name: samplepod |
|
|
- name: samplepod |
|
|
command: ["/bin/bash", "-c", "sleep 2000000000000"] |
|
|
command: ["/bin/bash", "-c", "sleep 2000000000000"] |
|
|
image: dougbtv/centos-network |
|
|
image: dougbtv/centos-network |
|
|
EOF |
|
|
|
|
|
executable: /bin/bash |
|
|
|
|
|
when: |
|
|
when: |
|
|
- inventory_hostname == groups['kube_control_plane'][0] |
|
|
- inventory_hostname == groups['kube_control_plane'][0] |
|
|
- kube_network_plugin_multus | default(false) | bool |
|
|
- kube_network_plugin_multus | default(false) | bool |
|
|