Skip to content

Commit

Permalink
WIP add support for ironic-standalone-operator
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Tantsur <dtantsur@protonmail.com>
  • Loading branch information
dtantsur committed Nov 6, 2024
1 parent 6229464 commit 60f36fd
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 3 deletions.
97 changes: 97 additions & 0 deletions 03_launch_mgmt_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,102 @@ EOF
popd
}

launch_ironic_via_operator() {
local opdir="${WORKING_DIR}/ironic-standalone-operator"

# TODO(dtantsur): find a better place to do this
git clone "${IRSOREPO}" "${opdir}"

local openv="${opdir}/config/manager/local.env"
if [ -n "${IRONIC_LOCAL_IMAGE:-}" ]; then
echo 'IRONIC_IMAGE="'"${IRONIC_LOCAL_IMAGE}"'"' >> "${openv}"
else
echo 'IRONIC_IMAGE="'"${IRONIC_IMAGE}"'"' >> "${openv}"
fi
if [ -n "${MARIADB_LOCAL_IMAGE:-}" ]; then
echo 'MARIADB_IMAGE="'"${MARIADB_LOCAL_IMAGE}"'"' >> "${openv}"
else
echo 'MARIADB_IMAGE="'"${MARIADB_IMAGE}"'"' >> "${openv}"
fi
# TODO(dtantsur): keepalive support
if [ -n "${IPA_DOWNLOADER_LOCAL_IMAGE:-}" ]; then
echo 'RAMDISK_DOWNLOADER_IMAGE="'"${IPA_DOWNLOADER_LOCAL_IMAGE}"'"' >> "${openv}"
else
echo 'RAMDISK_DOWNLOADER_IMAGE="'"${IPA_DOWNLOADER_IMAGE}"'"' >> "${openv}"
fi
# FIXME(dtantsur): temporary
cat "${openv}"

cat > "${opdir}/config/manager/local_env.patch" <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
namespace: system
spec:
template:
spec:
containers:
- name: manager
envFrom:
- configMapRef:
name: ironic-standalone-operator-config
EOF

make -C "${opdir}" kustomize
pushd "${opdir}/config/manager"
"${opdir}/bin/kustomize" edit add configmap ironic-standalone-operator-config --from-env-file "${openv}"
"${opdir}/bin/kustomize" edit add patch --path "${opdir}/config/manager/local_env.patch"
popd

make -C "${opdir}" install deploy
kubectl wait --for=condition=Available --timeout=60s \
-n ironic-standalone-operator-system deployment/ironic-standalone-operator-controller-manager

local ironic="${IRONIC_DATA_DIR}/ironic.yaml"
cat > "${ironic}" <<EOF
---
apiVersion: metal3.io/v1alpha1
kind: Ironic
metadata:
name: ironic
namespace: "${IRONIC_NAMESPACE}"
spec:
networking:
dhcp:
rangeBegin: "${CLUSTER_DHCP_RANGE_START}"
rangeEnd: "${CLUSTER_DHCP_RANGE_END}"
networkCIDR: "${BARE_METAL_PROVISIONER_NETWORK}"
interface: "${BARE_METAL_PROVISIONER_INTERFACE}"
ipAddress: "${CLUSTER_BARE_METAL_PROVISIONER_IP}"
ramdiskSSHKey: "${IRONIC_RAMDISK_SSH_KEY}"
EOF

if [[ "${NODES_PLATFORM}" == "libvirt" ]]; then
cat >> "${ironic}" <<EOF
ramdiskExtraKernelParams: "console=ttyS0"
EOF
fi

if [[ "${IRONIC_USE_MARIADB}" == "true" ]]; then
cat >> "${ironic}" <<EOF
databaseRef:
name: ironic-db
---
apiVersion: metal3.io/v1alpha1
kind: IronicDatabase
metadata:
name: ironic-db
namespace: "${IRONIC_NAMESPACE}"
spec: {}
EOF
fi

kubectl create -f "${ironic}"
kubectl wait --for=condition=Ready --timeout=180s \
-n "${IRONIC_NAMESPACE}" ironic/ironic
}

#
# Launch and configure fakeIPA
#
Expand Down Expand Up @@ -562,6 +658,7 @@ if [ "${EPHEMERAL_CLUSTER}" != "tilt" ]; then
launch_cluster_api_provider_metal3
BMO_NAME_PREFIX="${NAMEPREFIX}"
launch_baremetal_operator
launch_ironic_via_operator
launch_ironic

if [[ "${BMO_RUN_LOCAL}" != true ]]; then
Expand Down
3 changes: 3 additions & 0 deletions lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ export CAPM3_BASE_URL="${CAPM3_BASE_URL:-metal3-io/cluster-api-provider-metal3}"
export CAPM3REPO="${CAPM3REPO:-https://github.com/${CAPM3_BASE_URL}}"
export CAPM3RELEASEBRANCH="${CAPM3RELEASEBRANCH:-main}"

export IRSO_BASE_URL="${IRSO_BASE_URL:-metal3-io/ironic-standalone-operator}"
export IRSOREPO="${IRSOREPO:-https://github.com/${IRSO_BASE_URL}}"

if [[ "${CAPM3RELEASEBRANCH}" == "release-1.6" ]]; then
export CAPM3BRANCH="${CAPM3BRANCH:-release-1.6}"
export IPAMBRANCH="${IPAMBRANCH:-release-1.6}"
Expand Down
6 changes: 3 additions & 3 deletions lib/network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ else
fi

# Calculate DHCP range
network_address ironic_dhcp_range_start "$BARE_METAL_PROVISIONER_NETWORK" 10
network_address ironic_dhcp_range_end "$BARE_METAL_PROVISIONER_NETWORK" 100
network_address CLUSTER_DHCP_RANGE_START "$BARE_METAL_PROVISIONER_NETWORK" 10
network_address CLUSTER_DHCP_RANGE_END "$BARE_METAL_PROVISIONER_NETWORK" 100
# The nex range is for IPAM to know what is the pool that porovisioned noodes
# can get IP's from
network_address IPAM_PROVISIONING_POOL_RANGE_START "$BARE_METAL_PROVISIONER_NETWORK" 100
network_address IPAM_PROVISIONING_POOL_RANGE_END "$BARE_METAL_PROVISIONER_NETWORK" 200

export IPAM_PROVISIONING_POOL_RANGE_START
export IPAM_PROVISIONING_POOL_RANGE_END
export CLUSTER_DHCP_RANGE=${CLUSTER_DHCP_RANGE:-"$ironic_dhcp_range_start,$ironic_dhcp_range_end"}
export CLUSTER_DHCP_RANGE=${CLUSTER_DHCP_RANGE:-"$CLUSTER_DHCP_RANGE_START,$CLUSTER_DHCP_RANGE_END"}

EXTERNAL_SUBNET=${EXTERNAL_SUBNET:-""}
if [[ -n "${EXTERNAL_SUBNET}" ]]; then
Expand Down

0 comments on commit 60f36fd

Please sign in to comment.