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

Merged
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
65 changes: 35 additions & 30 deletions 03_launch_mgmt_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ source lib/releases.sh
# shellcheck disable=SC1091
source lib/network.sh

# TODO: Once testing of 1.9 and older releases stop this and the file named
# 03_launch_mgmt_cluster_pre1.10.sh can be removed
if [[ "${IPAMRELEASE}" =~ ("v1.7.99"|"v1.8.99"|"v1.9.99")$ ]]; then
./03_launch_mgmt_cluster_pre_1_10.sh
exit 0
fi

# 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"
Expand Down Expand Up @@ -421,20 +428,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 @@ -464,13 +457,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 @@ -481,7 +469,7 @@ 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 @@ -504,12 +492,19 @@ update_component_image()
#
# Update the clusterctl deployment files to use local repositories
#
patch_clusterctl()
{
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 @@ -518,18 +513,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 @@ -560,7 +564,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 @@ -724,6 +728,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
Loading