From aa3a6c489e7aedba8f20905dc400777afe1a2a75 Mon Sep 17 00:00:00 2001 From: Vladimir Kozhukalov Date: Mon, 26 Aug 2024 14:54:59 -0500 Subject: [PATCH] Add Kubespray compute-kit job We would like to make sure OSH charts work with K8s clusters managed by third party tools not only with the K8s cluster deployed by OSH deploy-env role Depends-On: I4ffc6653070dbbc6f0766b278acf0ebe2b4ae1e1 Depends-On: I92c73606ed9b9161f39ea1971b3a7db7593982ff Change-Id: If9bd4720bea951a56cfd6d4f80be37bd17bcb149 --- Makefile | 2 +- .../component/compute-kit/compute-kit.sh | 2 +- .../gate/playbooks/deploy-env-kubespray.yaml | 144 ++++++++++++++++++ tools/gate/playbooks/deploy-env.yaml | 3 - tools/gate/playbooks/prepare-hosts.yaml | 3 + zuul.d/2024.1.yaml | 12 ++ zuul.d/base.yaml | 39 ++++- zuul.d/nodesets.yaml | 28 ++++ zuul.d/project.yaml | 1 + 9 files changed, 228 insertions(+), 6 deletions(-) create mode 100644 tools/gate/playbooks/deploy-env-kubespray.yaml diff --git a/Makefile b/Makefile index e28af88add..6b8d007046 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ SHELL := /bin/bash HELM := helm TASK := build -EXCLUDES := helm-toolkit doc tests tools logs tmp zuul.d releasenotes +EXCLUDES := helm-toolkit doc tests tools logs tmp zuul.d releasenotes roles CHARTS := helm-toolkit $(filter-out $(EXCLUDES), $(patsubst %/.,%,$(wildcard */.))) .PHONY: $(EXCLUDES) $(CHARTS) diff --git a/tools/deployment/component/compute-kit/compute-kit.sh b/tools/deployment/component/compute-kit/compute-kit.sh index d20e1a411f..bda341eabe 100755 --- a/tools/deployment/component/compute-kit/compute-kit.sh +++ b/tools/deployment/component/compute-kit/compute-kit.sh @@ -95,7 +95,7 @@ helm upgrade --install neutron ${OSH_HELM_REPO}/neutron \ ${OSH_EXTRA_HELM_ARGS_NEUTRON} #NOTE: Wait for deploy -helm osh wait-for-pods openstack +helm osh wait-for-pods openstack 1200 #NOTE: Validate Deployment info export OS_CLOUD=openstack_helm diff --git a/tools/gate/playbooks/deploy-env-kubespray.yaml b/tools/gate/playbooks/deploy-env-kubespray.yaml new file mode 100644 index 0000000000..38ead36325 --- /dev/null +++ b/tools/gate/playbooks/deploy-env-kubespray.yaml @@ -0,0 +1,144 @@ +- hosts: all + become: true + gather_facts: true + tasks: + - name: Install prerequisites + include_role: + name: deploy-env + tasks_from: prerequisites + + - name: Create loopback devices + include_role: + name: deploy-env + tasks_from: loopback_devices + when: + - loopback_setup + - inventory_hostname in (groups['k8s_cluster'] | default([])) + +- hosts: primary + become: false + gather_facts: true + vars: + home_dir: /home/zuul + ansible_user: zuul + tasks: + - name: Clone Kubespray repo + shell: | + set -x + git clone https://github.com/kubernetes-sigs/kubespray.git + cd kubespray + git checkout -b release-2.25 + git reset --hard v2.25.0 + args: + chdir: "{{ home_dir }}" + + - name: Install Kubespray Python dependencies + become: true + pip: + chdir: "{{ home_dir }}/kubespray" + requirements: requirements.txt + + - name: Prepare Kubespray inventory (not Zuul job inventory) + shell: | + #!/bin/bash + set -x + python3 contrib/inventory_builder/inventory.py {{ groups['k8s_cluster'] | map('extract', hostvars, ['ansible_default_ipv4', 'address']) | join(' ') }} + args: + chdir: "{{ home_dir }}/kubespray" + environment: + KUBE_MASTERS: "1" + + - name: Prepare Kubespray variables + shell: | + #!/bin/bash + set -x + tee inventory/sample/group_vars/all/xxx.yaml <- + {% raw %}{{ ansible_hostname }}{% endraw %} + + EOF + args: + chdir: "{{ home_dir }}/kubespray" + + - name: Deploy Kubernetes + shell: | + #!/bin/bash + set -x + ansible-playbook -i inventory/sample/hosts.yaml --become --become-user=root cluster.yml + args: + chdir: /home/zuul/kubespray + + - name: Copy kubectl config to localhost (will be used in the following tasks) + synchronize: + mode: pull + src: /home/zuul/kubespray/inventory/sample/artifacts/admin.conf + dest: /tmp/kube_config + +- hosts: primary + become: true + gather_facts: true + tasks: + - name: Install Docker + include_role: + name: deploy-env + tasks_from: containerd + + - name: Install and configure Kubectl and Helm + include_role: + name: deploy-env + tasks_from: k8s_client + + - name: Deploy Metallb on K8s + include_role: + name: deploy-env + tasks_from: metallb + + - name: Create Openstack Metallb endpoint + include_role: + name: deploy-env + tasks_from: openstack_metallb_endpoint + +- hosts: all + become: true + gather_facts: true + tasks: + - name: Create client-to-cluster wireguard tunnel + include_role: + name: deploy-env + tasks_from: client_cluster_tunnel + + - name: Install Docker + include_role: + name: deploy-env + tasks_from: containerd + when: + - openstack_provider_gateway_setup + - inventory_hostname in (groups['k8s_control_plane'] | default([])) + + - name: Deploy Openstack provider gateway + include_role: + name: deploy-env + tasks_from: openstack_provider_gateway + when: + - openstack_provider_gateway_setup + - inventory_hostname in (groups['k8s_control_plane'] | default([])) diff --git a/tools/gate/playbooks/deploy-env.yaml b/tools/gate/playbooks/deploy-env.yaml index 0dad41a7b9..13e1302216 100644 --- a/tools/gate/playbooks/deploy-env.yaml +++ b/tools/gate/playbooks/deploy-env.yaml @@ -2,7 +2,4 @@ become: true gather_facts: true roles: - - ensure-python - - ensure-pip - - clear-firewall - deploy-env diff --git a/tools/gate/playbooks/prepare-hosts.yaml b/tools/gate/playbooks/prepare-hosts.yaml index 3ebc3ae7b1..0c3556f5ba 100644 --- a/tools/gate/playbooks/prepare-hosts.yaml +++ b/tools/gate/playbooks/prepare-hosts.yaml @@ -1,3 +1,6 @@ - hosts: all roles: - start-zuul-console + - ensure-python + - ensure-pip + - clear-firewall diff --git a/zuul.d/2024.1.yaml b/zuul.d/2024.1.yaml index 8688cbecf0..d729122bfd 100644 --- a/zuul.d/2024.1.yaml +++ b/zuul.d/2024.1.yaml @@ -77,6 +77,18 @@ container_distro_version: jammy feature_gates: metallb +- job: + name: openstack-helm-compute-kit-kubespray-2024-1-ubuntu_jammy + parent: openstack-helm-compute-kit-kubespray + nodeset: openstack-helm-1node-3nodes-ubuntu_jammy + vars: + metallb_setup: true + osh_params: + openstack_release: "2024.1" + container_distro_name: ubuntu + container_distro_version: jammy + feature_gates: metallb + - job: name: openstack-helm-compute-kit-cilium-metallb-2024-1-ubuntu_jammy parent: openstack-helm-compute-kit diff --git a/zuul.d/base.yaml b/zuul.d/base.yaml index e9ba2f2af1..ea95910de3 100644 --- a/zuul.d/base.yaml +++ b/zuul.d/base.yaml @@ -69,6 +69,17 @@ run_helm_tests: "no" openstack_provider_gateway_setup: true +- job: + name: openstack-helm-deploy-kubespray + parent: openstack-helm-deploy + abstract: true + run: + - tools/gate/playbooks/deploy-env-kubespray.yaml + - tools/gate/playbooks/run-scripts.yaml + vars: + metallb_setup: true + kube_version_kubespray: "v1.29.5" + - job: name: openstack-helm-compute-kit parent: openstack-helm-deploy @@ -79,7 +90,33 @@ - ./tools/deployment/common/prepare-charts.sh - ./tools/deployment/common/setup-client.sh - ./tools/deployment/common/ingress.sh - - ./tools/deployment/component/common/rabbitmq.sh + - export VOLUME_HELM_ARGS="--set volume.enabled=false"; ./tools/deployment/component/common/rabbitmq.sh + - ./tools/deployment/component/common/mariadb.sh + - ./tools/deployment/component/common/memcached.sh + - ./tools/deployment/component/keystone/keystone.sh + - ./tools/deployment/component/heat/heat.sh + - export GLANCE_BACKEND=local; ./tools/deployment/component/glance/glance.sh + - ./tools/deployment/component/compute-kit/openvswitch.sh + - ./tools/deployment/component/compute-kit/libvirt.sh + - ./tools/deployment/component/compute-kit/compute-kit.sh + - export OSH_TEST_TIMEOUT=1200;./tools/deployment/common/run-helm-tests.sh neutron + - ./tools/deployment/common/run-helm-tests.sh nova + - ./tools/deployment/common/run-helm-tests.sh glance + - ./tools/deployment/common/run-helm-tests.sh keystone + - ./tools/deployment/common/use-it.sh + - ./tools/deployment/common/force-cronjob-run.sh + +- job: + name: openstack-helm-compute-kit-kubespray + parent: openstack-helm-deploy-kubespray + abstract: true + vars: + gate_scripts: + - ./tools/deployment/common/prepare-k8s.sh + - ./tools/deployment/common/prepare-charts.sh + - ./tools/deployment/common/setup-client.sh + - ./tools/deployment/common/ingress.sh + - export VOLUME_HELM_ARGS="--set volume.enabled=false"; ./tools/deployment/component/common/rabbitmq.sh - ./tools/deployment/component/common/mariadb.sh - ./tools/deployment/component/common/memcached.sh - ./tools/deployment/component/keystone/keystone.sh diff --git a/zuul.d/nodesets.yaml b/zuul.d/nodesets.yaml index 2055217deb..04d54f6c52 100644 --- a/zuul.d/nodesets.yaml +++ b/zuul.d/nodesets.yaml @@ -146,6 +146,34 @@ nodes: - node-2 +- nodeset: + name: openstack-helm-1node-3nodes-ubuntu_jammy + nodes: + - name: primary + label: ubuntu-jammy + - name: node-1 + label: ubuntu-jammy + - name: node-2 + label: ubuntu-jammy + - name: node-3 + label: ubuntu-jammy + groups: + - name: primary + nodes: + - primary + - name: k8s_cluster + nodes: + - node-1 + - node-2 + - node-3 + - name: k8s_control_plane + nodes: + - node-1 + - name: k8s_nodes + nodes: + - node-2 + - node-3 + - nodeset: name: openstack-helm-1node-32GB-ubuntu_jammy nodes: diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index adde73f864..630fc98213 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -43,6 +43,7 @@ - openstack-helm-compute-kit-flannel-metallb-2024-1-ubuntu_jammy # 1 node + 2 nodes - openstack-helm-horizon-2024-1-ubuntu_jammy # 1 node - openstack-helm-tacker-2024-1-ubuntu_jammy + - openstack-helm-compute-kit-kubespray-2024-1-ubuntu_jammy gate: jobs: - openstack-helm-lint