diff --git a/03_launch_mgmt_cluster.sh b/03_launch_mgmt_cluster.sh index 4e44e6918..bad95c168 100755 --- a/03_launch_mgmt_cluster.sh +++ b/03_launch_mgmt_cluster.sh @@ -292,20 +292,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 -} - # # Update the CAPM3 and BMO manifests to use local images as defined in variables # @@ -334,9 +320,9 @@ function update_component_image(){ make set-manifest-image ;; "IPAM") - export MANIFEST_IMG_IPAM="${REGISTRY}/localimages/$TMP_IMAGE_NAME" - export MANIFEST_TAG_IPAM="$TMP_IMAGE_TAG" - make set-manifest-image-ipam + export MANIFEST_IMG="${REGISTRY}/localimages/${TMP_IMAGE_NAME}" + export MANIFEST_TAG="${TMP_IMAGE_TAG}" + make set-manifest-image ;; "Ironic") export MANIFEST_IMG="${REGISTRY}/localimages/${TMP_IMAGE_NAME}" @@ -370,6 +356,13 @@ function patch_clusterctl(){ mkdir -p "${CAPI_CONFIG_FOLDER}" touch "${CAPI_CONFIG_FOLDER}"/clusterctl.yaml + cat << EOF > "${CAPI_CONFIG_FOLDER}"/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 @@ -378,18 +371,27 @@ function patch_clusterctl(){ update_component_image CAPM3 "${CAPM3_IMAGE}" fi + make release-manifests + + rm -rf "${CAPI_CONFIG_FOLDER}"/overrides/infrastructure-metal3/"${CAPM3RELEASE}" + mkdir -p "${CAPI_CONFIG_FOLDER}"/overrides/infrastructure-metal3/"${CAPM3RELEASE}" + cp out/*.yaml "${CAPI_CONFIG_FOLDER}"/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_FOLDER}"/overrides/infrastructure-metal3/"${CAPM3RELEASE}" - mkdir -p "${CAPI_CONFIG_FOLDER}"/overrides/infrastructure-metal3/"${CAPM3RELEASE}" - cp out/*.yaml "${CAPI_CONFIG_FOLDER}"/overrides/infrastructure-metal3/"${CAPM3RELEASE}" + rm -rf "${CAPI_CONFIG_FOLDER}"/overrides/ipam-metal3ipam/"${IPAMRELEASE}" + mkdir -p "${CAPI_CONFIG_FOLDER}"/overrides/ipam-metal3ipam/"${IPAMRELEASE}" + cp out/*.yaml "${CAPI_CONFIG_FOLDER}"/overrides/ipam-metal3ipam/"${IPAMRELEASE}" popd } @@ -418,7 +420,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 @@ -554,6 +556,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 7ac98c625..3bda2c7c4 100644 --- a/config_example.sh +++ b/config_example.sh @@ -213,3 +213,9 @@ # To enable FakeIPA and run dev-env on a fake platform # export NODES_PLATFORM="fake" # export FAKE_IPA_IMAGE=192.168.111.1:5000/localimages/fake-ipa + +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/lib/releases.sh b/lib/releases.sh index d7e6ad07f..1cedcd911 100644 --- a/lib/releases.sh +++ b/lib/releases.sh @@ -72,18 +72,22 @@ CAPIRELEASEPATH="{https://api.github.com/repos/${CAPI_BASE_URL:-kubernetes-sigs/ if [ "${CAPM3RELEASEBRANCH}" = "release-1.6" ]; then # 1.6.99 points to the head of the release-1.6 branch. Local override for CAPM3 is created for this version. export CAPM3RELEASE="v1.6.99" + export IPAMRELEASE="v1.6.99" export CAPIRELEASE="${CAPIRELEASE:-$(get_latest_release "${CAPIRELEASEPATH}" "v1.6.")}" elif [ "${CAPM3RELEASEBRANCH}" = "release-1.7" ]; then # 1.7.99 points to the head of the release-1.7 branch. Local override for CAPM3 is created for this version. export CAPM3RELEASE="v1.7.99" + export IPAMRELEASE="v1.7.99" export CAPIRELEASE="${CAPIRELEASE:-$(get_latest_release "${CAPIRELEASEPATH}" "v1.7.")}" elif [ "${CAPM3RELEASEBRANCH}" = "release-1.8" ]; then # 1.8.99 points to the head of the release-1.8 branch. Local override for CAPM3 is created for this version. export CAPM3RELEASE="v1.8.99" + export IPAMRELEASE="v1.8.99" export CAPIRELEASE="${CAPIRELEASE:-$(get_latest_release "${CAPIRELEASEPATH}" "v1.8.")}" else # 1.9.99 points to the head of the main branch of CAPM3. Local override for CAPM3 is created for this version. export CAPM3RELEASE="v1.9.99" + export IPAMRELEASE="v1.9.99" export CAPIRELEASE="${CAPIRELEASE:-$(get_latest_release "${CAPIRELEASEPATH}" "v1.8.")}" fi 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 617d61b18..a7bd9e581 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) }}"