Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️ Change the way IPAM is deployed with CAPM3 and Test changes made in IPAM and CAPM3 together #1459

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 28 additions & 30 deletions 03_launch_mgmt_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -425,20 +425,6 @@ apply_bm_hosts()
# CAPM3 deployment functions
# --------------------------

#
# Update the imports for the CAPM3 deployment files
#
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
}

get_component_image()
{
local orig_image=$1
Expand Down Expand Up @@ -468,13 +454,8 @@ update_component_image()

# shellcheck disable=SC2311
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 @@ -485,7 +466,7 @@ update_component_image()
make set-manifest-image
;;
"IPAM")
make set-manifest-image-ipam
make set-manifest-image
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how are we making sure that this make target is now called within the IPAM repository not CAPM3?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check function patch_IPAM() on line 521. Function update_component_image() is called from there after moving toip-address-managerdirectory. Also the last line of function patch_IPAM() returns the process back to the directory where the function was called from.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that makes sense, great
/approve

;;
"Ironic")
make set-manifest-image-ironic
Expand All @@ -508,12 +489,19 @@ update_component_image()
#
# Update the clusterctl deployment files to use local repositories
#
patch_clusterctl()
{
function patch_clusterctl(){

pushd "${CAPM3PATH}"
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 @@ -522,18 +510,27 @@ 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
}

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 @@ -564,7 +561,7 @@ 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 @@ -728,6 +725,7 @@ start_management_cluster
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"
17 changes: 12 additions & 5 deletions lib/releases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@ CAPIGOPROXY="https://proxy.golang.org/sigs.k8s.io/cluster-api/@v/list"

# Extract release version from release-branch name
if [[ "${CAPM3RELEASEBRANCH}" == release-* ]]; then
CAPM3_RELEASE_PREFIX="${CAPM3RELEASEBRANCH#release-}"
RELEASE_PREFIX="${CAPM3RELEASEBRANCH#release-}"
else
CAPM3_RELEASE_PREFIX=""
RELEASE_PREFIX=""
fi

# Fetch CAPI version that coresponds to CAPM3_RELEASE_PREFIX release version
if [[ "${CAPM3_RELEASE_PREFIX}" =~ ^(1\.7|1\.8|1\.9)$ ]]; then
export CAPM3RELEASE="v${CAPM3_RELEASE_PREFIX}.99"
CAPI_RELEASE_PREFIX="v${CAPM3_RELEASE_PREFIX}."
if [[ "${RELEASE_PREFIX}" =~ ^(1\.7|1\.8|1\.9)$ ]]; then
export CAPM3RELEASE="v${RELEASE_PREFIX}.99"
export IPAMRELEASE="v${RELEASE_PREFIX}.99"
CAPI_RELEASE_PREFIX="v${RELEASE_PREFIX}."
else
export CAPM3RELEASE="${CAPM3RELEASE:-"v1.10.99"}"
export IPAMRELEASE="${IPAMRELEASE:-"v1.9.99"}"
CAPI_RELEASE_PREFIX="${CAPI_RELEASE_PREFIX:-"v1.9."}"
fi
export CAPIRELEASE="${CAPIRELEASE:-$(get_latest_release_from_goproxy "${CAPIGOPROXY}" "${CAPI_RELEASE_PREFIX}")}"
Expand All @@ -54,3 +56,8 @@ if [[ -z "${CAPM3RELEASE}" ]]; then
echo "Failed to fetch CAPM3 release from GOPROXY"
exit 1
fi

if [[ -z "${IPAMRELEASE}" ]]; then
echo "Failed to fetch IPAM release from GOPROXY"
exit 1
fi
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