From e20c8ae1fa898656223d148ee0cb5f7aa6b552dd Mon Sep 17 00:00:00 2001 From: Stanislav Egorov Date: Wed, 8 Jul 2020 21:53:41 -0700 Subject: [PATCH] Preparation for workers deployment Added air-worker VM Import kubeconfig and check cluster Initinfra and capi for target cluster Change-Id: Ib05f805b428a1eab20d62df67ac97670714eebd0 --- .../target/initinfra/kustomization.yaml | 7 +++ .../target/initinfra/patch_bmo_config.yaml | 10 +++++ playbooks/airship-airshipctl-build-gate.yaml | 4 ++ playbooks/airshipctl-gate-runner.yaml | 2 + roles/airship-libvirt-gate/defaults/main.yaml | 6 +++ .../tasks/build-infra.yaml | 43 +++++++++++++++++++ roles/airship-libvirt-gate/tests/vars.yaml | 2 + tools/deployment/30_deploy_controlplane.sh | 3 ++ .../31_deploy_initinfra_target_node.sh | 34 +++++++++++++++ .../deployment/32_cluster_init_target_node.sh | 29 +++++++++++++ zuul.d/jobs.yaml | 2 + 11 files changed, 142 insertions(+) create mode 100644 manifests/site/test-site/target/initinfra/kustomization.yaml create mode 100644 manifests/site/test-site/target/initinfra/patch_bmo_config.yaml create mode 100755 tools/deployment/31_deploy_initinfra_target_node.sh create mode 100755 tools/deployment/32_cluster_init_target_node.sh diff --git a/manifests/site/test-site/target/initinfra/kustomization.yaml b/manifests/site/test-site/target/initinfra/kustomization.yaml new file mode 100644 index 000000000..7493021a0 --- /dev/null +++ b/manifests/site/test-site/target/initinfra/kustomization.yaml @@ -0,0 +1,7 @@ +resources: + - ../../shared/clusterctl + - ../../../../function/baremetal-operator +patchesStrategicMerge: + - patch_bmo_config.yaml +commonLabels: + airshipit.org/stage: initinfra diff --git a/manifests/site/test-site/target/initinfra/patch_bmo_config.yaml b/manifests/site/test-site/target/initinfra/patch_bmo_config.yaml new file mode 100644 index 000000000..e14f78a65 --- /dev/null +++ b/manifests/site/test-site/target/initinfra/patch_bmo_config.yaml @@ -0,0 +1,10 @@ +--- +kind: ConfigMap +apiVersion: v1 +metadata: + labels: + name: ironic-vars +data: + PROVISIONING_IP: "10.23.25.102" + DHCP_RANGE: "10.23.25.200,10.23.25.250" + PROVISIONING_INTERFACE: "pxe0" diff --git a/playbooks/airship-airshipctl-build-gate.yaml b/playbooks/airship-airshipctl-build-gate.yaml index 0665f11a9..05acf2d4d 100644 --- a/playbooks/airship-airshipctl-build-gate.yaml +++ b/playbooks/airship-airshipctl-build-gate.yaml @@ -135,6 +135,10 @@ disk_format: qcow2 target_vms_count: 1 target_vm_nics: "{{ target_vm_nics }}" + worker_vm_memory_mb: 1024 + worker_vm_vcpus: 1 + worker_disk_size: 10G + worker_vms_count: 1 airship_gate_file_exchanger: servername: "localhost" ip: diff --git a/playbooks/airshipctl-gate-runner.yaml b/playbooks/airshipctl-gate-runner.yaml index fe95d0e4c..61c2c70c2 100644 --- a/playbooks/airshipctl-gate-runner.yaml +++ b/playbooks/airshipctl-gate-runner.yaml @@ -23,6 +23,8 @@ - ./tools/deployment/25_deploy_ephemeral_node.sh - ./tools/deployment/26_deploy_metal3_capi_ephemeral_node.sh - ./tools/deployment/30_deploy_controlplane.sh + - ./tools/deployment/31_deploy_initinfra_target_node.sh + - ./tools/deployment/32_cluster_init_target_node.sh - name: "Run gate scripts" include_role: diff --git a/roles/airship-libvirt-gate/defaults/main.yaml b/roles/airship-libvirt-gate/defaults/main.yaml index 6a354ea79..160dbca33 100644 --- a/roles/airship-libvirt-gate/defaults/main.yaml +++ b/roles/airship-libvirt-gate/defaults/main.yaml @@ -21,6 +21,8 @@ airship_gate_names: target_volume_prefix: "vol_target" ephemeral_volume: "vol_ephemeral" pool: airship + worker_vm_prefix: "air-worker" + worker_volume_prefix: "vol_worker" airship_gate_ipam: nat_network: @@ -79,6 +81,10 @@ airship_gate_flavors: target_disk_size: 10G disk_format: qcow2 target_vms_count: 3 + worker_vm_memory_mb: 1024 + worker_vm_vcpus: 1 + worker_disk_size: 10G + worker_vms_count: 1 airship_gate_libvirt_pools: - path: /var/lib/libvirt/airship diff --git a/roles/airship-libvirt-gate/tasks/build-infra.yaml b/roles/airship-libvirt-gate/tasks/build-infra.yaml index 5e695ae4e..9efc9952d 100644 --- a/roles/airship-libvirt-gate/tasks/build-infra.yaml +++ b/roles/airship-libvirt-gate/tasks/build-infra.yaml @@ -146,3 +146,46 @@ file_exchanger_group: "{{ airship_gate_file_exchanger.group | default(None) }}" file_exchanger_rbac: "{{ airship_gate_file_exchanger.rbac | default(None) }}" +- name: Create worker volumes + include_role: + name: libvirt-volume + vars: + libvirt_volume: + name: "{{ airship_gate_names.worker_volume_prefix }}-{{ vm_index }}" + size: "{{ chosen_flavor.worker_disk_size }}" + pool: "{{ airship_gate_names.pool }}" + format: "{{ chosen_flavor.disk_format }}" + volume_action: create + loop_control: + loop_var: vm_index + with_sequence: "start=1 end={{ chosen_flavor.worker_vms_count }}" + +- name: Create worker domains + include_role: + name: libvirt-domain + vars: + libvirt_domain: + enable_vnc: true + console_log_enabled: true + state: shutdown + name: "{{ airship_gate_names.worker_vm_prefix }}-{{ vm_index }}" + memory_mb: "{{ chosen_flavor.worker_vm_memory_mb }}" + vcpus: "{{ chosen_flavor.worker_vm_vcpus }}" + controllers: + - "sata" + volumes: + - name: "{{ airship_gate_names.worker_volume_prefix }}-{{ vm_index }}" + device: "disk" + target: sda + bus: sata + format: "{{ chosen_flavor.disk_format }}" + pool: "{{ airship_gate_names.pool }}" + interfaces: + - network: "{{ airship_gate_names.nat_network }}" + mac: "" + - network: "{{ airship_gate_names.provision_network }}" + mac: "" + loop_control: + loop_var: vm_index + with_sequence: "start=1 end={{ chosen_flavor.worker_vms_count }}" + diff --git a/roles/airship-libvirt-gate/tests/vars.yaml b/roles/airship-libvirt-gate/tests/vars.yaml index 0c49f2c9d..e0525a2a0 100644 --- a/roles/airship-libvirt-gate/tests/vars.yaml +++ b/roles/airship-libvirt-gate/tests/vars.yaml @@ -38,3 +38,5 @@ airship_gate_names: target_volume_prefix: "vol_target" ephemeral_volume: "vol_ephemeral" pool: airship + worker_vm_prefix: "air-target" + worker_volume_prefix: "vol_worker" diff --git a/tools/deployment/30_deploy_controlplane.sh b/tools/deployment/30_deploy_controlplane.sh index 103eef10a..08495fc3d 100755 --- a/tools/deployment/30_deploy_controlplane.sh +++ b/tools/deployment/30_deploy_controlplane.sh @@ -75,6 +75,9 @@ fi echo "Create kubeconfig" echo ${KUBECONFIG} | base64 -d > /tmp/targetkubeconfig +echo "Import target kubeconfig" +airshipctl config import /tmp/targetkubeconfig + echo "Check kubectl version" VERSION="" N=0 diff --git a/tools/deployment/31_deploy_initinfra_target_node.sh b/tools/deployment/31_deploy_initinfra_target_node.sh new file mode 100755 index 000000000..ce572bd10 --- /dev/null +++ b/tools/deployment/31_deploy_initinfra_target_node.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xe + +export KUBECONFIG=${KUBECONFIG:-"$HOME/.airship/kubeconfig"} + +# TODO need to run another config command after use-context to update kubeconfig +echo "Switch context to target cluster and set manifest" +airshipctl config use-context target-cluster-admin@target-cluster +airshipctl config set-context target-cluster-admin@target-cluster --manifest dummy_manifest + +echo "Waiting for all control pods to come up" +kubectl --kubeconfig $KUBECONFIG wait -n kube-system --for=condition=Ready pods --selector tier=control-plane --timeout=600s +kubectl --kubeconfig $KUBECONFIG --namespace metal3 get pods --selector tier=control-plane "--output=jsonpath={.items[*].metadata.name}" + +# TODO remove taint +kubectl --kubeconfig $KUBECONFIG taint node node01 node-role.kubernetes.io/master- + +echo "Deploy infra to cluster" +airshipctl phase apply initinfra --debug --wait-timeout 600s + +kubectl --kubeconfig $KUBECONFIG get pods --all-namespaces diff --git a/tools/deployment/32_cluster_init_target_node.sh b/tools/deployment/32_cluster_init_target_node.sh new file mode 100755 index 000000000..ba62c066d --- /dev/null +++ b/tools/deployment/32_cluster_init_target_node.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xe + +export KUBECONFIG=${KUBECONFIG:-"$HOME/.airship/kubeconfig"} + +# TODO need to run another config command after use-context to update kubeconfig +echo "Switch context to target cluster and set manifest" +airshipctl config use-context target-cluster-admin@target-cluster +airshipctl config set-context target-cluster-admin@target-cluster --manifest dummy_manifest + +echo "Deploy CAPI components" +airshipctl cluster init --debug + +echo "Waiting for pods to be ready" +kubectl --kubeconfig $KUBECONFIG wait --all-namespaces --for=condition=Ready pods --all --timeout=600s +kubectl --kubeconfig $KUBECONFIG get pods --all-namespaces diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index a3e228f2b..26cab9774 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -94,6 +94,8 @@ - ./tools/deployment/25_deploy_ephemeral_node.sh - ./tools/deployment/26_deploy_metal3_capi_ephemeral_node.sh - ./tools/deployment/30_deploy_controlplane.sh + - ./tools/deployment/31_deploy_initinfra_target_node.sh + - ./tools/deployment/32_cluster_init_target_node.sh serve_dir: /srv/iso serve_port: 8099 voting: false