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 Dec 5, 2024
1 parent b745d52 commit a4cec6b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 33 deletions.
56 changes: 26 additions & 30 deletions 03_launch_mgmt_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
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-metal3:metal3-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 @@ -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"
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 a4cec6b

Please sign in to comment.