From 388eba7496780d262a193c33817f1a9c23b56bac Mon Sep 17 00:00:00 2001 From: Peter Mikus Date: Mon, 27 Oct 2025 14:27:26 +0100 Subject: [PATCH] feat(ansible): Calico bits Signed-off-by: Peter Mikus Change-Id: I30520f967d0261000842862b1bc09c153b943abd --- .../lf_inventory/host_vars/10.30.51.40.yaml | 18 +++- fdio.infra.ansible/roles/calico/defaults/main.yaml | 15 --- fdio.infra.ansible/roles/calico/tasks/cleanup.yaml | 13 +++ fdio.infra.ansible/roles/calico/tasks/deploy.yaml | 68 +++++++++++++ fdio.infra.ansible/roles/calico/tasks/execute.yaml | 26 +++++ fdio.infra.ansible/roles/calico/tasks/main.yaml | 113 ++------------------- fdio.infra.ansible/roles/calico/tasks/pre-set.yaml | 14 +++ .../roles/calico/templates/calico-vpp.yaml.j2 | 4 + 8 files changed, 150 insertions(+), 121 deletions(-) create mode 100644 fdio.infra.ansible/roles/calico/tasks/cleanup.yaml create mode 100644 fdio.infra.ansible/roles/calico/tasks/deploy.yaml create mode 100644 fdio.infra.ansible/roles/calico/tasks/execute.yaml create mode 100644 fdio.infra.ansible/roles/calico/tasks/pre-set.yaml diff --git a/fdio.infra.ansible/inventories/lf_inventory/host_vars/10.30.51.40.yaml b/fdio.infra.ansible/inventories/lf_inventory/host_vars/10.30.51.40.yaml index 83ba4aa8c3..59d5651e2a 100644 --- a/fdio.infra.ansible/inventories/lf_inventory/host_vars/10.30.51.40.yaml +++ b/fdio.infra.ansible/inventories/lf_inventory/host_vars/10.30.51.40.yaml @@ -64,4 +64,20 @@ docker_volumes: - source: "/etc/4xxx_dev0.conf" target: "/etc/4xxx_dev0.conf" - source: "/etc/4xxx_dev1.conf" - target: "/etc/4xxx_dev1.conf" \ No newline at end of file + target: "/etc/4xxx_dev1.conf" + +# Calico +calico_corelist_workers: "2,3,4,5,98,99,100,101" +calico_uplink_interfaces: + - interfaceName: "enp56s0np0" + vppDriver: "avf" + rx: 8 + rxMode: "polling" + pci: "0000:38:00.0" + ip_addr: "192.168.1.2/24" + - interfaceName: "enp58s0np0" + vppDriver: "avf" + rx: 8 + rxMode: "polling" + pci: "0000:3a:00.0" + ip_addr: "192.168.2.2/24" \ No newline at end of file diff --git a/fdio.infra.ansible/roles/calico/defaults/main.yaml b/fdio.infra.ansible/roles/calico/defaults/main.yaml index 4efbe63f7f..c51a09e65f 100644 --- a/fdio.infra.ansible/roles/calico/defaults/main.yaml +++ b/fdio.infra.ansible/roles/calico/defaults/main.yaml @@ -11,18 +11,3 @@ kubernetes_calico_resources: operator-crds.yaml: https://raw.githubusercontent.com/projectcalico/calico/v{{ kubernetes_calico_version }}/manifests/operator-crds.yaml calico_vpp_state: "present" - -calico_corelist_workers: "2,3,4,5,98,99,100,101" -calico_uplink_interfaces: - - interfaceName: "enp56s0np0" - vppDriver: "avf" - rx: 8 - rxMode: "polling" - pci: "0000:38:00.0" - ip_addr: "192.168.1.2/24" - - interfaceName: "enp58s0np0" - vppDriver: "avf" - rx: 8 - rxMode: "polling" - pci: "0000:3a:00.0" - ip_addr: "192.168.2.2/24" \ No newline at end of file diff --git a/fdio.infra.ansible/roles/calico/tasks/cleanup.yaml b/fdio.infra.ansible/roles/calico/tasks/cleanup.yaml new file mode 100644 index 0000000000..536b694aa7 --- /dev/null +++ b/fdio.infra.ansible/roles/calico/tasks/cleanup.yaml @@ -0,0 +1,13 @@ +--- +# file: tasks/cleanup.yaml + +- name: reset network interface + ansible.builtin.shell: | + python3 /opt/dpdk/usertools/dpdk-devbind.py -b none {{ item.pci }} --force + python3 /opt/dpdk/usertools/dpdk-devbind.py -b ice {{ item.pci }} + loop: "{{ calico_uplink_interfaces }}" + when: + - calico_sut is defined + - calico_vpp_state == "absent" + tags: + - calico-cleanup \ No newline at end of file diff --git a/fdio.infra.ansible/roles/calico/tasks/deploy.yaml b/fdio.infra.ansible/roles/calico/tasks/deploy.yaml new file mode 100644 index 0000000000..9f5acc9721 --- /dev/null +++ b/fdio.infra.ansible/roles/calico/tasks/deploy.yaml @@ -0,0 +1,68 @@ +--- +# file: tasks/deploy.yaml + +- name: download calico manifest to the cluster + ansible.builtin.get_url: + url: "{{ item.value }}" + dest: "/tmp/{{ item.key }}" + mode: "0664" + loop: "{{ kubernetes_calico_resources | dict2items }}" + when: + - calico_sut is defined + tags: + - calico-deploy + +- name: apply calico manifest to the cluster + kubernetes.core.k8s: + state: present + src: "/tmp/{{ item.key }}" + loop: "{{ kubernetes_calico_resources | dict2items }}" + when: + - calico_sut is defined + tags: + - calico-deploy + +- name: upload calico vpp manifest to the cluster + ansible.builtin.template: + dest: "/tmp/{{ item }}" + src: "{{ item }}.j2" + loop: + - "calico-vpp.yaml" + when: + - calico_sut is defined + tags: + - calico-deploy + +- name: apply calico vpp manifest to the cluster + kubernetes.core.k8s: + state: "{{ calico_vpp_state }}" + src: "/tmp/{{ item }}" + loop: + - "calico-vpp.yaml" + when: + - calico_sut is defined + tags: + - calico-deploy + +- name: get a list of all pods from any namespace + kubernetes.core.k8s_info: + kind: Pod + field_selectors: + - status.phase=Running + label_selectors: + - k8s-app=calico-vpp-node + register: pod_list + when: calico_sut is defined + tags: + - calico-info + +- name: register vpp pod name + ansible.builtin.set_fact: + calico_pod_name: "{{ item[0]['metadata']['name'] }}" + loop: + - "{{ pod_list['resources'] }}" + when: + - calico_sut is defined + - pod_list['resources'] | length > 0 + tags: + - calico-info \ No newline at end of file diff --git a/fdio.infra.ansible/roles/calico/tasks/execute.yaml b/fdio.infra.ansible/roles/calico/tasks/execute.yaml new file mode 100644 index 0000000000..94c2817950 --- /dev/null +++ b/fdio.infra.ansible/roles/calico/tasks/execute.yaml @@ -0,0 +1,26 @@ +--- +# file: tasks/execute.yaml + +- name: execute command on calico-vpp-pod + kubernetes.core.k8s_exec: + namespace: calico-vpp-dataplane + pod: "{{ calico_pod_name }}" + container: vpp + command: vppctl sh version + register: command_status + when: + - calico_pod_name is defined + - calico_sut is defined + - calico_vpp_state == "present" + tags: + - calico-execute + +- name: check last command status + ansible.builtin.debug: + msg: "{{ command_status.stdout }}" + when: + - calico_pod_name is defined + - calico_sut is defined + - calico_vpp_state == "present" + tags: + - calico-execute \ No newline at end of file diff --git a/fdio.infra.ansible/roles/calico/tasks/main.yaml b/fdio.infra.ansible/roles/calico/tasks/main.yaml index ebbc2a069a..61c042a848 100644 --- a/fdio.infra.ansible/roles/calico/tasks/main.yaml +++ b/fdio.infra.ansible/roles/calico/tasks/main.yaml @@ -1,115 +1,18 @@ --- # file: tasks/main.yaml -- name: pre-setup network interface - ansible.builtin.shell: | - ip l set dev {{ item.interfaceName }} up - ip a add {{ item.ip_addr }} dev {{ item.interfaceName }} - loop: "{{ calico_uplink_interfaces }}" - ignore_errors: True - when: - - calico_sut is defined - - calico_vpp_state == "present" +- import_tasks: pre-set.yaml tags: - - kubernetes-reset + - calico-pre-set -- name: download calico manifest to the cluster - ansible.builtin.get_url: - url: "{{ item.value }}" - dest: "/tmp/{{ item.key }}" - mode: "0664" - loop: "{{ kubernetes_calico_resources | dict2items }}" - when: - - calico_sut is defined +- import_tasks: deploy.yaml tags: - - kubernetes-calico + - calico-deploy -- name: apply calico manifest to the cluster - kubernetes.core.k8s: - state: present - src: "/tmp/{{ item.key }}" - loop: "{{ kubernetes_calico_resources | dict2items }}" - when: - - calico_sut is defined +- import_tasks: execute.yaml tags: - - kubernetes-calico + - calico-execute -- name: upload calico vpp manifest to the cluster - ansible.builtin.template: - dest: "/tmp/{{ item }}" - src: "{{ item }}.j2" - loop: - - "calico-vpp.yaml" - when: - - calico_sut is defined +- import_tasks: cleanup.yaml tags: - - kubernetes-calico - -- name: apply calico vpp manifest to the cluster - kubernetes.core.k8s: - state: "{{ calico_vpp_state }}" - src: "/tmp/{{ item }}" - loop: - - "calico-vpp.yaml" - when: - - calico_sut is defined - tags: - - kubernetes-calico - -- name: get a list of all pods from any namespace - kubernetes.core.k8s_info: - kind: Pod - field_selectors: - - status.phase=Running - label_selectors: - - k8s-app=calico-vpp-node - register: pod_list - when: calico_sut is defined - tags: - - kubernetes-info - -- name: register vpp pod name - ansible.builtin.set_fact: - calico_pod_name: "{{ item[0]['metadata']['name'] }}" - loop: - - "{{ pod_list['resources'] }}" - when: - - calico_sut is defined - - pod_list['resources'] | length > 0 - tags: - - kubernetes-info - -- name: execute command on calico-vpp-pod - kubernetes.core.k8s_exec: - namespace: calico-vpp-dataplane - pod: "{{ calico_pod_name }}" - container: vpp - command: vppctl sh version - register: command_status - when: - - calico_pod_name is defined - - calico_sut is defined - - calico_vpp_state == "present" - tags: - - kubernetes-info - -- name: check last command status - ansible.builtin.debug: - msg: "{{ command_status.stdout }}" - when: - - calico_pod_name is defined - - calico_sut is defined - - calico_vpp_state == "present" - tags: - - kubernetes-info - -- name: reset network interface - ansible.builtin.shell: | - python3 /opt/dpdk/usertools/dpdk-devbind.py -b none {{ item.pci }} --force - python3 /opt/dpdk/usertools/dpdk-devbind.py -b ice {{ item.pci }} - loop: "{{ calico_uplink_interfaces }}" - when: - - calico_sut is defined - - calico_vpp_state == "absent" - tags: - - kubernetes-reset \ No newline at end of file + - calico-cleanup \ No newline at end of file diff --git a/fdio.infra.ansible/roles/calico/tasks/pre-set.yaml b/fdio.infra.ansible/roles/calico/tasks/pre-set.yaml new file mode 100644 index 0000000000..c89252bfaa --- /dev/null +++ b/fdio.infra.ansible/roles/calico/tasks/pre-set.yaml @@ -0,0 +1,14 @@ +--- +# file: tasks/pre-set.yaml + +- name: pre-setup network interface + ansible.builtin.shell: | + ip l set dev {{ item.interfaceName }} up + ip a add {{ item.ip_addr }} dev {{ item.interfaceName }} + loop: "{{ calico_uplink_interfaces }}" + ignore_errors: True + when: + - calico_sut is defined + - calico_vpp_state == "present" + tags: + - calico-reset \ No newline at end of file diff --git a/fdio.infra.ansible/roles/calico/templates/calico-vpp.yaml.j2 b/fdio.infra.ansible/roles/calico/templates/calico-vpp.yaml.j2 index f5c7d7857f..7e724c930e 100644 --- a/fdio.infra.ansible/roles/calico/templates/calico-vpp.yaml.j2 +++ b/fdio.infra.ansible/roles/calico/templates/calico-vpp.yaml.j2 @@ -162,6 +162,10 @@ data: buffers { buffers-per-numa 131072 } + CALICOVPP_FEATURE_GATES: |- + { + "memifEnabled": true + } CALICOVPP_INITIAL_CONFIG: |- { "vppStartupSleepSeconds": 1, -- 2.16.6