Skip to content

Commit

Permalink
Add Fake K8s API sever (FKAS) image
Browse files Browse the repository at this point in the history
Signed-off-by: Mohammed Boukhalfa <[email protected]>
  • Loading branch information
mboukhalfa committed Oct 22, 2024
1 parent 523a720 commit 60e6614
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion 01_prepare_host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ case "${CONTAINER_RUNTIME}" in
esac
# TODO (mboukhalfa) fake images
if [[ "${NODES_PLATFORM}" == "fake" ]]; then
echo Skipping image prepulling on fake nodes platform
echo "Skipping image prepulling on fake nodes platform"
else
# pre-pull node and container images
# shellcheck disable=SC1091
Expand Down
7 changes: 4 additions & 3 deletions 02_configure_host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,10 @@ if [[ "${BUILD_IRONIC_IMAGE_LOCALLY:-}" == "true" ]] || [[ -n "${IRONIC_LOCAL_IM
IRONIC_IMAGE="${REGISTRY}/localimages/$(basename "${IRONIC_LOCAL_IMAGE}")"
export IRONIC_IMAGE
fi
VBMC_IMAGE=${VBMC_LOCAL_IMAGE:-${VBMC_IMAGE}}
SUSHY_TOOLS_IMAGE=${SUSHY_TOOLS_LOCAL_IMAGE:-${SUSHY_TOOLS_IMAGE}}
FAKE_IPA_IMAGE=${FAKE_IPA_LOCAL_IMAGE:-${FAKE_IPA_IMAGE}}
VBMC_IMAGE="${VBMC_LOCAL_IMAGE:-${VBMC_IMAGE}}"
SUSHY_TOOLS_IMAGE="${SUSHY_TOOLS_LOCAL_IMAGE:-${SUSHY_TOOLS_IMAGE}}"
FAKE_IPA_IMAGE="${FAKE_IPA_LOCAL_IMAGE:-${FAKE_IPA_IMAGE}}"
FKAS_IMAGE="${FKAS_LOCAL_IMAGE:-${FKAS_IMAGE}}"

# Pushing images to local registry
for IMAGE_VAR in $(env | grep -v "_LOCAL_IMAGE=" | grep "_IMAGE=" | grep -o "^[^=]*") ; do
Expand Down
27 changes: 10 additions & 17 deletions 03_launch_mgmt_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,6 @@ EOF
echo "IRONIC_KERNEL_PARAMS=console=ttyS0" | sudo tee -a "${IRONIC_DATA_DIR}/ironic_bmo_configmap.env"
fi

# TODO (mboukhalfa) enable heartbeating and ironic TLS
if [[ "${NODES_PLATFORM}" == "fake" ]]; then
echo "OS_AGENT__REQUIRE_TLS=false" | sudo tee -a "${IRONIC_DATA_DIR}/ironic_bmo_configmap.env"
fi

if [ -n "${DHCP_IGNORE:-}" ]; then
echo "DHCP_IGNORE=${DHCP_IGNORE}" | sudo tee -a "${IRONIC_DATA_DIR}/ironic_bmo_configmap.env"
fi
Expand Down Expand Up @@ -227,18 +222,16 @@ EOF
#
# Launch and configure fakeIPA
#
function launch_fakeIPA() {
launch_fake_ipa() {
# Create a folder to host fakeIPA config and certs
mkdir -p /opt/metal3-dev-env/fake-ipa
if [[ "${EPHEMERAL_CLUSTER}" == "kind" ]]; then
if [[ "${IRONIC_TLS_SETUP}" == "true" ]]; then
cp "${IRONIC_CACERT_FILE}" "/opt/metal3-dev-env/fake-ipa/ironic-ca.crt"
fi
else
mkdir -p "${WORKING_DIR}/fake-ipa"
if [[ "${EPHEMERAL_CLUSTER}" == "kind" ]] && [[ "${IRONIC_TLS_SETUP}" == "true" ]]; then
cp "${IRONIC_CACERT_FILE}" "${WORKING_DIR}/fake-ipa/ironic-ca.crt"
elif [[ "${IRONIC_TLS_SETUP}" == "true" ]]; then
# wait for ironic to be running to ensure ironic-cert is created
kubectl -n baremetal-operator-system wait --for=condition=available deployment/baremetal-operator-ironic --timeout=900s
# Extract ironic-cert to be used inside fakeIPA for TLS
kubectl -n legacy get secret -n baremetal-operator-system ironic-cert -o json -o=jsonpath="{.data.ca\.crt}" | base64 -d > /opt/metal3-dev-env/fake-ipa/ironic-ca.crt
kubectl get secret -n baremetal-operator-system ironic-cert -o json -o=jsonpath="{.data.ca\.crt}" | base64 -d > "${WORKING_DIR}/fake-ipa/ironic-ca.crt"
fi
# Create fake IPA custom config
cat << EOF > "${WORKING_DIR}/fake-ipa/config.py"
Expand Down Expand Up @@ -581,15 +574,15 @@ if [ "${EPHEMERAL_CLUSTER}" != "tilt" ]; then
# then dev-env will create the bmh files but do not apply them
if [[ "${SKIP_APPLY_BMH:-false}" == "true" ]]; then
pushd "${BMOPATH}"
list_nodes | make_bm_hosts
list_nodes | make_bm_hosts
popd
else
apply_bm_hosts "$NAMESPACE"
apply_bm_hosts "${NAMESPACE}"
fi
# if fake platform (no VMs) run FakeIPA
if [[ "${NODES_PLATFORM}" == "fake" ]]; then
launch_fakeIPA
launch_fake_ipa
fi
elif [ "${EPHEMERAL_CLUSTER}" == "tilt" ]; then
source tilt-setup/deploy_tilt_env.sh
. tilt-setup/deploy_tilt_env.sh
fi
11 changes: 6 additions & 5 deletions 04_verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ source lib/images.sh
if [ "${EPHEMERAL_CLUSTER}" == "tilt" ]; then
exit 0
fi
# TODO (mboukhalfa) Skip verification related to virsh
if [[ "${NODES_PLATFORM}" == "fake" ]]; then
echo "Skipping virsh nodes verification on fake vm platform"
exit 0
fi

check_bm_hosts() {
local FAILS_CHECK="${FAILS}"
Expand Down Expand Up @@ -250,6 +245,12 @@ echo ""
iterate check_k8s_entity deployments "${EXPTD_DEPLOYMENTS}"
iterate check_k8s_rs "${EXPTD_RS}"

# Skip verification related to virsh when running with fakeIPA
if [[ "${NODES_PLATFORM}" == "fake" ]]; then
echo "Skipping virsh nodes verification on fake vm platform"
exit 0
fi

# Verify the baremetal hosts
## Fetch the BM CRs
RESULT_STR="Fetch Baremetalhosts"
Expand Down
1 change: 1 addition & 0 deletions lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export CONTAINER_REGISTRY="${CONTAINER_REGISTRY:-quay.io}"
export VBMC_IMAGE="${VBMC_IMAGE:-${CONTAINER_REGISTRY}/metal3-io/vbmc}"
export SUSHY_TOOLS_IMAGE="${SUSHY_TOOLS_IMAGE:-${CONTAINER_REGISTRY}/metal3-io/sushy-tools}"
export FAKE_IPA_IMAGE="${FAKE_IPA_IMAGE:-${CONTAINER_REGISTRY}/metal3-io/fake-ipa}"
export FKAS_IMAGE="${FKAS_IMAGE:-${CONTAINER_REGISTRY}/metal3-io/metal3-fkas}"

# CAPM3 and IPAM controller images
if [[ "${CAPM3RELEASEBRANCH}" = "release-1.6" ]]; then
Expand Down
1 change: 1 addition & 0 deletions vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ assured that they are persisted.
| VBMC_IMAGE | Container image for vbmc container | | "$CONTAINER_REGISTRY/metal3-io/vbmc" |
| SUSHY_TOOLS_IMAGE | Container image for sushy-tools container | | "$CONTAINER_REGISTRY/metal3-io/sushy-tools" |
| FAKE_IPA_IMAGE | Container image for fakeIPA container | | "$CONTAINER_REGISTRY/metal3-io/fake-ipa" |
| FKAS_IMAGE | Container image for fkas container | | "$CONTAINER_REGISTRY/metal3-io/metal3-fkas" |
| CAPM3_VERSION | Version of Cluster API provider Metal3 | "v1beta1" | "v1beta1" |
| CAPI_VERSION | Version of Cluster API | "v1beta1" | "v1beta1" |
| CLUSTER_APIENDPOINT_IP | API endpoint IP for target cluster | "x.x.x.x" | "${EXTERNAL_SUBNET_VX}.249" |
Expand Down
5 changes: 1 addition & 4 deletions vm-setup/roles/common/tasks/write_ironic_nodes_tasks.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
---
# Generate the ironic node inventory files. Note that this
# task *must* occur after the above vm tasks, because if
# `vm_nodes` is defined the template depends on the
# `node_mac_map` variable.
# Generate the ironic node inventory files.
- name: Write ironic node json files
template:
src: ../templates/ironic_nodes.json.j2
Expand Down

0 comments on commit 60e6614

Please sign in to comment.