Skip to content

Commit

Permalink
Add ability to specify custom config
Browse files Browse the repository at this point in the history
Add an ability to specify custom config in the cluster config file,
which will be provider specific, and allow consuming projects to
customize the provider's configuration before deploying.

Currently, only 'kind' will be supported.

Signed-off-by: Mike Kolesnik <[email protected]>
  • Loading branch information
mkolesnik authored and tpantelis committed Jan 23, 2024
1 parent 94b5e3d commit 88783a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions scripts/shared/lib/clusters_kind
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,20 @@ function generate_cluster_yaml() {
local nodes
for node in ${cluster_nodes[${cluster}]}; do nodes="${nodes}"$'\n'"- role: $node"; done

local config_file
config_file="${RESOURCES_DIR}/${cluster}-config.yaml"

if [[ "$DUAL_STACK" ]]; then
service_cidr_ipv6="${service_IPv6_CIDRs[${cluster}]}"
pod_cidr_ipv6="${cluster_IPv6_CIDRs[${cluster}]}"
render_template "${RESOURCES_DIR}/kind-cluster-dual-stack-config.yaml" > "${RESOURCES_DIR}/${cluster}-config.yaml"
render_template "${RESOURCES_DIR}/kind-cluster-dual-stack-config.yaml" > "$config_file"
else
render_template "${RESOURCES_DIR}/kind-cluster-config.yaml" > "${RESOURCES_DIR}/${cluster}-config.yaml"
render_template "${RESOURCES_DIR}/kind-cluster-config.yaml" > "$config_file"
fi

if [[ -n "${cluster_custom_config[$cluster]}" ]]; then
# shellcheck disable=SC2016 # We intentionally don't expand the argument to eval-all as it's using yq syntax, not sh
echo "${cluster_custom_config[$cluster]}" | yq -i eval-all '. as $item ireduce ({}; . * $item )' "$config_file" -
fi
}

Expand Down
4 changes: 3 additions & 1 deletion scripts/shared/lib/utils
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function load_settings() {
local DEBUG_PRINT=false
expect_env SETTINGS "Deployment settings file"
declare -ga clusters
declare -gA cluster_cni cluster_nodes cluster_subm cluster_gateways
declare -gA cluster_cni cluster_nodes cluster_subm cluster_gateways cluster_custom_config

local cluster_count
cluster_count=$(_yq ".cluster-count")
Expand All @@ -242,6 +242,7 @@ function load_settings() {
cluster_subm["${cluster}"]=$(_yq ".clusters.${cluster}.submariner")
cluster_subm["${cluster}"]=$(_yq ".submariner")
cluster_gateways["${cluster}"]=$(_yq ".clusters.${cluster}.gateways // .gateways")
cluster_custom_config["${cluster}"]=$(_yq ".clusters.${cluster}.customConfig // .customConfig")
done

cat << EOM
Expand All @@ -252,6 +253,7 @@ Cluster settings::
nodes per cluster - $(typeset -p cluster_nodes | cut -f 2- -d=)
install submariner - $(typeset -p cluster_subm | cut -f 2- -d=)
label cluster gateways - $(typeset -p cluster_gateways | cut -f 2- -d=)
custom configuration - $(typeset -p cluster_custom_config | cut -f 2- -d=)
EOM
}

Expand Down

0 comments on commit 88783a9

Please sign in to comment.