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 <[email protected]>
  • Loading branch information
dtantsur committed Oct 30, 2024
1 parent 45a403e commit 76c7680
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 3 deletions.
96 changes: 96 additions & 0 deletions 03_launch_mgmt_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,101 @@ EOF
popd
}

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

# FIXME(dtantsur): do not use my fork!
git clone -b config https://github.com/dtantsur/ironic-standalone-operator "${opdir}"

local openv="${IRONIC_DATA_DIR}/ironic-standalone-operator.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 > "${IRONIC_DATA_DIR}/ironic-standalone-operator.patch" <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
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 "${IRONIC_DATA_DIR}/ironic-standalone-operator.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_CIDR}"
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 @@ -557,6 +652,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
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 76c7680

Please sign in to comment.