From 95a85bec2a7888e36fe76f859ab346a84340d98f Mon Sep 17 00:00:00 2001 From: Vadim Khitrin Date: Sat, 26 Aug 2023 16:10:40 +0300 Subject: [PATCH] scripts: Add Additional Kustomization For Baremetal Deployment Adding an option to inject additional EDPM variables for baremetal deployments using Kustomize. The following variables were added: - EDPM_BAREMETAL_KERNEL_ARGS, uses `edpm-kernel` role to modify kernel arugments - EDPM_BAREMETAL_KERNEL_HUGEPAGES, uses `edpm-kernel` role to configure hugepages - EDPM_BAREMETAL_TUNED_PROFILE, uses `edpm_tuned` role to configure a tuned profile - EDPM_BAREMETAL_TUNED_ISOLATED_CORES, uses `edpm_tuned` role to configured tuned isolated cores - EDPM_BAREMETAL_NETWORK_CONFIG_OVERRIDE, uses `edpm_network_config` role to allow providing custom network configuration --- scripts/gen-edpm-baremetal-kustomize.sh | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/scripts/gen-edpm-baremetal-kustomize.sh b/scripts/gen-edpm-baremetal-kustomize.sh index acd58351b..690e4899d 100644 --- a/scripts/gen-edpm-baremetal-kustomize.sh +++ b/scripts/gen-edpm-baremetal-kustomize.sh @@ -51,12 +51,26 @@ if [ -z "$EDPM_BMH_NAMESPACE" ]; then echo "Please set EDPM_BMH_NAMESPACE"; exit 1 fi +# This statement is first since we don't want to start creating CR if provided file is not correct +if [ ! -z "$EDPM_BAREMETAL_NETWORK_CONFIG_OVERRIDE" ]; then + if [ ! -f "$EDPM_BAREMETAL_NETWORK_CONFIG_OVERRIDE" ]; then + echo "Please esnure file ${EDPM_BAREMETAL_NETWORK_CONFIG_OVERRIDE} exists" + exit 1 + fi + NETWORK_CONFIG_JSON=$(cat "${EDPM_BAREMETAL_NETWORK_CONFIG_OVERRIDE}" | jq -c -r . 2>/dev/null) + if [ ! "$NETWORK_CONFIG_JSON" ]; then + echo "Please esnure file ${EDPM_BAREMETAL_NETWORK_CONFIG_OVERRIDE} contains a valid JSON" + exit 1 + fi +fi + NAME=${KIND,,} if [ ! -d ${DEPLOY_DIR} ]; then mkdir -p ${DEPLOY_DIR} fi + pushd ${DEPLOY_DIR} cat <kustomization.yaml @@ -176,6 +190,51 @@ cat <>kustomization.yaml EOF fi +# Used for edpm_kernel role to provide additional kernel arguments +if [ ! -z "$EDPM_BAREMETAL_KERNEL_ARGS" ]; then +cat <>kustomization.yaml + - op: add + path: /spec/roles/edpm-compute/nodeTemplate/ansibleVars/edpm_kernel_args + value: ${EDPM_BAREMETAL_KERNEL_ARGS} +EOF +fi + +# Used for edpm_kernel role to configure huge pages +if [ ! -z "$EDPM_BAREMETAL_KERNEL_HUGEPAGES" ]; then +cat <>kustomization.yaml + - op: add + path: /spec/roles/edpm-compute/nodeTemplate/ansibleVars/edpm_kernel_hugepages + value: ${EDPM_BAREMETAL_KERNEL_HUGEPAGES} +EOF +fi + +# Used for edpm_tuned role to configure tuned profile +if [ ! -z "$EDPM_BAREMETAL_TUNED_PROFILE" ]; then +cat <>kustomization.yaml + - op: add + path: /spec/roles/edpm-compute/nodeTemplate/ansibleVars/edpm_tuned_profile + value: ${EDPM_BAREMETAL_TUNED_PROFILE} +EOF +fi + +# Used for edpm_tuned role to configure tuned profile +if [ ! -z "$EDPM_BAREMETAL_TUNED_ISOLATED_CORES" ]; then +cat <>kustomization.yaml + - op: add + path: /spec/roles/edpm-compute/nodeTemplate/ansibleVars/edpm_tuned_isolated_cores + value: ${EDPM_BAREMETAL_TUNED_ISOLATED_CORES} +EOF +fi + +# Used for edpm_network_config role to provide custom YAML file for network configuration +if [ ! -z "$NETWORK_CONFIG_JSON" ]; then +cat <>kustomization.yaml + - op: add + path: /spec/roles/edpm-compute/nodeTemplate/ansibleVars/edpm_network_config_override + value: '${NETWORK_CONFIG_JSON}' +EOF +fi + kustomization_add_resources popd