diff --git a/03_launch_mgmt_cluster.sh b/03_launch_mgmt_cluster.sh index eee2852e4..b17cf0110 100755 --- a/03_launch_mgmt_cluster.sh +++ b/03_launch_mgmt_cluster.sh @@ -10,9 +10,6 @@ source lib/releases.sh # shellcheck disable=SC1091 source lib/network.sh -# Default CAPI_CONFIG_DIR to $HOME/.config directory if XDG_CONFIG_HOME not set -CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}" -export CAPI_CONFIG_DIR="${CONFIG_DIR}/cluster-api" export IRONIC_HOST="${CLUSTER_BARE_METAL_PROVISIONER_HOST}" export IRONIC_HOST_IP="${CLUSTER_BARE_METAL_PROVISIONER_IP}" export REPO_IMAGE_PREFIX="quay.io" @@ -394,19 +391,6 @@ function apply_bm_hosts() { # CAPM3 deployment functions # -------------------------- -# -# Update the imports for the CAPM3 deployment files -# -function update_capm3_imports(){ - pushd "${CAPM3PATH}" - - make kustomize - ./hack/tools/bin/kustomize build "${IPAMPATH}/config/default" > config/ipam/metal3-ipam-components.yaml - - sed -i -e "s#https://github.com/metal3-io/ip-address-manager/releases/download/v.*/ipam-components.yaml#metal3-ipam-components.yaml#" "config/ipam/kustomization.yaml" - popd -} - function get_component_image(){ local ORIG_IMAGE=$1 # Split the image IMAGE_NAME AND IMAGE_TAG, if any tag exist @@ -431,13 +415,8 @@ function update_component_image(){ local ORIG_IMAGE=$2 local TMP_IMAGE TMP_IMAGE="$(get_component_image "$ORIG_IMAGE")" - if [[ "${IMPORT}" == "IPAM" ]]; then - export MANIFEST_IMG_IPAM="${TMP_IMAGE%:*}" - export MANIFEST_TAG_IPAM="${TMP_IMAGE##*:}" - else - export MANIFEST_IMG="${TMP_IMAGE%:*}" - export MANIFEST_TAG="${TMP_IMAGE##*:}" - fi + export MANIFEST_IMG="${TMP_IMAGE%:*}" + export MANIFEST_TAG="${TMP_IMAGE##*:}" # NOTE: It is assumed that we are already in the correct directory to run make case "${IMPORT}" in @@ -448,7 +427,7 @@ function update_component_image(){ make set-manifest-image ;; "IPAM") - make set-manifest-image-ipam + make set-manifest-image ;; "Ironic") make set-manifest-image-ironic @@ -474,6 +453,13 @@ function patch_clusterctl(){ mkdir -p "${CAPI_CONFIG_DIR}" touch "${CAPI_CONFIG_DIR}"/clusterctl.yaml + cat << EOF > "${CAPI_CONFIG_DIR}"/clusterctl.yaml +providers: +- name: metal3ipam + url: https://github.com/metal3-io/ip-address-manager/releases/${IPAMRELEASE}/ipam-components.yaml + type: IPAMProvider +EOF + # At this point the images variables have been updated with update_images # Reflect the change in components files if [ -n "${CAPM3_LOCAL_IMAGE:-}" ]; then @@ -482,18 +468,27 @@ function patch_clusterctl(){ update_component_image CAPM3 "${CAPM3_IMAGE}" fi + make release-manifests + + rm -rf "${CAPI_CONFIG_DIR}"/overrides/infrastructure-metal3/"${CAPM3RELEASE}" + mkdir -p "${CAPI_CONFIG_DIR}"/overrides/infrastructure-metal3/"${CAPM3RELEASE}" + cp out/*.yaml "${CAPI_CONFIG_DIR}"/overrides/infrastructure-metal3/"${CAPM3RELEASE}" + popd +} + +function patch_ipam(){ + pushd "${IPAMPATH}" + if [ -n "${IPAM_LOCAL_IMAGE:-}" ]; then update_component_image IPAM "${IPAM_LOCAL_IMAGE}" else update_component_image IPAM "${IPAM_IMAGE}" fi - update_capm3_imports make release-manifests - - rm -rf "${CAPI_CONFIG_DIR}"/overrides/infrastructure-metal3/"${CAPM3RELEASE}" - mkdir -p "${CAPI_CONFIG_DIR}"/overrides/infrastructure-metal3/"${CAPM3RELEASE}" - cp out/*.yaml "${CAPI_CONFIG_DIR}"/overrides/infrastructure-metal3/"${CAPM3RELEASE}" + rm -rf "${CAPI_CONFIG_DIR}"/overrides/ipam-metal3ipam/"${IPAMRELEASE}" + mkdir -p "${CAPI_CONFIG_DIR}"/overrides/ipam-metal3ipam/"${IPAMRELEASE}" + cp out/*.yaml "${CAPI_CONFIG_DIR}"/overrides/ipam-metal3ipam/"${IPAMRELEASE}" popd } @@ -522,7 +517,7 @@ function launch_cluster_api_provider_metal3() { # shellcheck disable=SC2153 clusterctl init --core cluster-api:"${CAPIRELEASE}" --bootstrap kubeadm:"${CAPIRELEASE}" \ - --control-plane kubeadm:"${CAPIRELEASE}" --infrastructure=metal3:"${CAPM3RELEASE}" -v5 + --control-plane kubeadm:"${CAPIRELEASE}" --infrastructure=metal3:"${CAPM3RELEASE}" -v5 --ipam=metal3ipam:"${IPAMRELEASE}" if [ "${CAPM3_RUN_LOCAL}" == true ]; then touch capm3.out.log @@ -658,6 +653,7 @@ if [ "${EPHEMERAL_CLUSTER}" != "tilt" ]; then kubectl create namespace metal3 patch_clusterctl + patch_ipam launch_cluster_api_provider_metal3 BMO_NAME_PREFIX="${NAMEPREFIX}" launch_baremetal_operator diff --git a/04_verify.sh b/04_verify.sh index e0ffebd5e..bf4caf38b 100755 --- a/04_verify.sh +++ b/04_verify.sh @@ -200,10 +200,11 @@ EXPTD_DEPLOYMENTS="capm3-system:capm3-controller-manager \ capi-kubeadm-bootstrap-system:capi-kubeadm-bootstrap-controller-manager \ capi-kubeadm-control-plane-system:capi-kubeadm-control-plane-controller-manager \ baremetal-operator-system:baremetal-operator-controller-manager" -EXPTD_RS="cluster.x-k8s.io/provider:infrastructure-metal3:capm3-system:2 \ +EXPTD_RS="cluster.x-k8s.io/provider:infrastructure-metal3:capm3-system:1 \ cluster.x-k8s.io/provider:cluster-api:capi-system:1 \ cluster.x-k8s.io/provider:bootstrap-kubeadm:capi-kubeadm-bootstrap-system:1 \ - cluster.x-k8s.io/provider:control-plane-kubeadm:capi-kubeadm-control-plane-system:1" + cluster.x-k8s.io/provider:control-plane-kubeadm:capi-kubeadm-control-plane-system:1 \ + cluster.x-k8s.io/provider:ipam-metal3:metal3-ipam-system:1" BRIDGES="provisioning external" EXPTD_CONTAINERS="httpd-infra registry vbmc sushy-tools" diff --git a/config_example.sh b/config_example.sh index 35b7cc904..448452647 100644 --- a/config_example.sh +++ b/config_example.sh @@ -216,3 +216,9 @@ # Whether to use ironic-standalone-operator to deploy Ironic. # export USE_IRSO="true" + +export CAPM3REPO="https://github.com/Nordix/cluster-api-provider-metal3" +export CAPM3BRANCH="peppi-lotta/change-IPAM-namespace" + +export IPAMREPO="https://github.com/Nordix/metal3-ipam/" +export IPAMBRANCH="peppi-lotta/make-ipam-a-provider-for-capi" diff --git a/tests/roles/run_tests/tasks/move.yml b/tests/roles/run_tests/tasks/move.yml index ad3d78dca..4ff5dbd79 100644 --- a/tests/roles/run_tests/tasks/move.yml +++ b/tests/roles/run_tests/tasks/move.yml @@ -96,7 +96,7 @@ kubeconfig: "/tmp/kubeconfig-{{ CLUSTER_NAME }}.yaml" - name: Initialize Provider component in target cluster - shell: "clusterctl init --kubeconfig /tmp/kubeconfig-{{ CLUSTER_NAME }}.yaml --core cluster-api:{{ CAPIRELEASE }} --bootstrap kubeadm:{{ CAPIRELEASE }} --control-plane kubeadm:{{ CAPIRELEASE }} --infrastructure metal3:{{ CAPM3RELEASE }} -v 5" + shell: "clusterctl init --kubeconfig /tmp/kubeconfig-{{ CLUSTER_NAME }}.yaml --core cluster-api:{{ CAPIRELEASE }} --bootstrap kubeadm:{{ CAPIRELEASE }} --control-plane kubeadm:{{ CAPIRELEASE }} --infrastructure metal3:{{ CAPM3RELEASE }} -v 5 --ipam metal3ipam:{{ IPAMRELEASE }}" # Check for cert-manager pods on the target cluster - name: Check if cert-manager pods in running state diff --git a/tests/roles/run_tests/vars/main.yml b/tests/roles/run_tests/vars/main.yml index 27e84296c..9e7a75312 100644 --- a/tests/roles/run_tests/vars/main.yml +++ b/tests/roles/run_tests/vars/main.yml @@ -51,6 +51,7 @@ POD_CIDR: "{{ lookup('env', 'POD_CIDR') }}" SERVICE_CIDR: "10.96.0.0/12" CAPM3RELEASE: "{{ lookup('env', 'CAPM3RELEASE') | default('v1.1.2', true) }}" CAPIRELEASE: "{{ lookup('env', 'CAPIRELEASE') | default('v1.1.4', true) }}" +IPAMRELEASE: "{{ lookup('env', 'IPAMRELEASE') | default('v1.1.2', true) }}" SSH_PRIVATE_KEY: "{{ lookup('env', 'SSH_KEY') }}" SSH_PUB_KEY_CONTENT: "{{ lookup('file', '{{ HOME }}/.ssh/id_rsa.pub') }}" IMAGE_USERNAME: "{{ lookup('env', 'IMAGE_USERNAME') | default('metal3', true) }}"