Skip to content

Commit

Permalink
Test IPAM and CAPM3 changes together because tests don't pass alone d…
Browse files Browse the repository at this point in the history
…ue to namespace name change

Signed-off-by: peppi-lotta <[email protected]>
  • Loading branch information
peppi-lotta committed Nov 1, 2024
1 parent 45a403e commit 1f16610
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 26 deletions.
49 changes: 26 additions & 23 deletions 03_launch_mgmt_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions 04_verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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-metal3ipam:ipam-system:1"
BRIDGES="provisioning external"
EXPTD_CONTAINERS="httpd-infra registry vbmc sushy-tools"

Expand Down
6 changes: 6 additions & 0 deletions config_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 4 additions & 0 deletions lib/releases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/roles/run_tests/tasks/move.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/roles/run_tests/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}"
Expand Down

0 comments on commit 1f16610

Please sign in to comment.