From 92f736bc0cd7733f55be01d7c8579f6757cb1dcb Mon Sep 17 00:00:00 2001 From: Mike Kolesnik Date: Sun, 10 Dec 2023 17:14:51 +0200 Subject: [PATCH] Rename `GLOBALNET` to `OVERLAPPING` To better support external projects, rename the flag to a more neutral one which actually reflects the type of deployment. The old flag (when sent via `using=`) is still respected, to not break existing Submariner projects. Signed-off-by: Mike Kolesnik --- Makefile.clusters | 6 +++--- Makefile.inc | 11 ++++++++--- scripts/shared/clusters.sh | 2 +- scripts/shared/deploy.sh | 11 ++++++++++- scripts/shared/lib/clusters_kind | 4 +--- scripts/shared/lib/deploy_bundle | 2 +- scripts/shared/lib/deploy_funcs | 2 +- scripts/shared/lib/deploy_helm | 4 ++-- scripts/shared/lib/deploy_operator | 2 +- scripts/shared/lib/utils | 12 +++++------- scripts/shared/resources/bundle/broker.yaml | 2 +- 11 files changed, 34 insertions(+), 24 deletions(-) diff --git a/Makefile.clusters b/Makefile.clusters index d7d2eb3b7..e58e34c0d 100644 --- a/Makefile.clusters +++ b/Makefile.clusters @@ -14,7 +14,7 @@ K8S_VERSION ?= 1.25 METALLB_VERSION ?= 0.13.5 OLM_VERSION ?= v0.18.3 PROVIDER ?= kind -export AIR_GAPPED DUAL_STACK GLOBALNET K8S_VERSION LOAD_BALANCER METALLB_VERSION OLM OLM_VERSION PROMETHEUS PROVIDER +export AIR_GAPPED DUAL_STACK K8S_VERSION LOAD_BALANCER METALLB_VERSION OLM OLM_VERSION OVERLAPPING PROMETHEUS PROVIDER ### PROCESSING `using=` ### @@ -38,8 +38,8 @@ ifneq (,$(filter dual-stack,$(_using))) DUAL_STACK = true endif -ifneq (,$(filter globalnet,$(_using))) -GLOBALNET = true +ifneq (,$(filter overlapping,$(_using))) +OVERLAPPING = true endif ifneq (,$(filter prometheus,$(_using))) diff --git a/Makefile.inc b/Makefile.inc index 8098e41b5..2d8be4f06 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -9,7 +9,7 @@ DEBUG_PRINT ?= true PARALLEL ?= true PROVIDER ?= kind TIMEOUT ?= 5m -export AIR_GAPPED DEBUG_PRINT GLOBALNET PARALLEL PLUGIN PRELOAD_IMAGES PROVIDER SETTINGS TEST_ARGS TIMEOUT +export AIR_GAPPED DEBUG_PRINT OVERLAPPING PARALLEL PLUGIN PRELOAD_IMAGES PROVIDER SETTINGS TEST_ARGS TIMEOUT # Specific to `deploy` CABLE_DRIVER ?= libreswan @@ -74,8 +74,13 @@ ifneq (,$(filter lighthouse,$(_using))) LIGHTHOUSE = true endif +# Support existing Submariner flag ifneq (,$(filter globalnet,$(_using))) -GLOBALNET = true +OVERLAPPING = true +endif + +ifneq (,$(filter overlapping,$(_using))) +OVERLAPPING = true endif ifneq (,$(filter helm,$(_using))) @@ -127,7 +132,7 @@ ifeq ($(AIR_GAPPED),true) override PRELOAD_IMAGES = $(EXTRA_PRELOAD_IMAGES) nettest \ $(foreach image,gateway operator route-agent,submariner-$(image)) -ifeq ($(GLOBALNET),true) +ifeq ($(OVERLAPPING),true) override PRELOAD_IMAGES += submariner-globalnet endif ifeq ($(LIGHTHOUSE),true) diff --git a/scripts/shared/clusters.sh b/scripts/shared/clusters.sh index d1ea8cd9f..cca69b81c 100755 --- a/scripts/shared/clusters.sh +++ b/scripts/shared/clusters.sh @@ -3,7 +3,7 @@ set -em -o pipefail source "${SCRIPTS_DIR}/lib/utils" -print_env AIR_GAPPED GLOBALNET K8S_VERSION OLM OLM_VERSION PARALLEL PROMETHEUS PROVIDER SETTINGS TIMEOUT +print_env AIR_GAPPED K8S_VERSION OLM OLM_VERSION OVERLAPPING PARALLEL PROMETHEUS PROVIDER SETTINGS TIMEOUT source "${SCRIPTS_DIR}/lib/debug_functions" ### Functions ### diff --git a/scripts/shared/deploy.sh b/scripts/shared/deploy.sh index c37f84e4a..dfa837cb9 100755 --- a/scripts/shared/deploy.sh +++ b/scripts/shared/deploy.sh @@ -3,7 +3,7 @@ set -em source "${SCRIPTS_DIR}/lib/utils" -print_env CABLE_DRIVER DEPLOYTOOL GLOBALNET IMAGE_TAG LIGHTHOUSE PARALLEL PLUGIN PRELOAD_IMAGES SETTINGS TIMEOUT +print_env CABLE_DRIVER DEPLOYTOOL OVERLAPPING IMAGE_TAG LIGHTHOUSE PARALLEL PLUGIN PRELOAD_IMAGES SETTINGS TIMEOUT source "${SCRIPTS_DIR}/lib/debug_functions" source "${SCRIPTS_DIR}/lib/deploy_funcs" @@ -99,10 +99,19 @@ function install_bundle() { echo "[INFO](${cluster}) Bundle ${bundle} installed" } +function declare_global_cidrs() { + declare -gA global_CIDRs + + for cluster in "${clusters[@]}"; do + global_CIDRs[$idx]="242.254.${cluster_number[$cluster]}.0/24" + done +} + ### Main ### load_settings declare_cidrs +[[ "$OVERLAPPING" != "true" ]] || declare_global_cidrs declare_kubeconfig # Always import nettest image on kind, to be able to test connectivity and other things diff --git a/scripts/shared/lib/clusters_kind b/scripts/shared/lib/clusters_kind index 9fa282503..e869a07de 100755 --- a/scripts/shared/lib/clusters_kind +++ b/scripts/shared/lib/clusters_kind @@ -166,9 +166,7 @@ function air_gap_iptables() { function deploy_load_balancer() { local kind_ip start_ip end_ip net_addr kind_ip=$(docker network inspect -f '{{.IPAM.Config}}' kind | awk '/.*/ { print $2 }') - net_addr=$(echo "${cluster_CIDRs[$cluster]}" | cut -f2 -d'.') - [[ "$GLOBALNET" != true ]] || net_addr=$(echo "${global_CIDRs[$cluster]}" | cut -f3 -d'.') - start_ip=$(echo "$kind_ip" | cut -f1-2 -d'.')."$net_addr".100 + start_ip=$(echo "$kind_ip" | cut -f1-2 -d'.')."${cluster_number[$cluster]}".100 end_ip=$(echo "$start_ip" | cut -f1-3 -d'.').250 kubectl apply -f "https://raw.githubusercontent.com/metallb/metallb/v${METALLB_VERSION}/config/manifests/metallb-native.yaml" diff --git a/scripts/shared/lib/deploy_bundle b/scripts/shared/lib/deploy_bundle index 5e3d7f682..cef311c59 100644 --- a/scripts/shared/lib/deploy_bundle +++ b/scripts/shared/lib/deploy_bundle @@ -53,7 +53,7 @@ function setup_broker() { # Enable the service-discovery component if defined local components="connectivity" components+=$([[ "${LIGHTHOUSE}" == "true" ]] && echo ", service-discovery" || echo "") - components+=$([[ "${GLOBALNET}" == "true" ]] && echo ", globalnet" || echo "") + components+=$([[ "${OVERLAPPING}" == "true" ]] && echo ", globalnet" || echo "") ### Create the Broker instance render_template "${RESOURCES_DIR}"/bundle/broker.yaml | kubectl apply -f - diff --git a/scripts/shared/lib/deploy_funcs b/scripts/shared/lib/deploy_funcs index 56472c128..56ca9218a 100644 --- a/scripts/shared/lib/deploy_funcs +++ b/scripts/shared/lib/deploy_funcs @@ -44,7 +44,7 @@ function get_svc_ip() { local svc_name=$1 local svc_ip - if [[ "${GLOBALNET}" = "true" ]]; then + if [[ "${OVERLAPPING}" = "true" ]]; then svc_ip=$(with_retries 30 get_globalip "${svc_name}") else svc_ip=$(kubectl --context="$cluster" get svc -l "app=${svc_name}" | awk 'FNR == 2 {print $3}') diff --git a/scripts/shared/lib/deploy_helm b/scripts/shared/lib/deploy_helm index a801da255..4066237af 100644 --- a/scripts/shared/lib/deploy_helm +++ b/scripts/shared/lib/deploy_helm @@ -70,14 +70,14 @@ function helm_install_subm() { --set broker.token="${submariner_broker_token}" \ --set broker.namespace="${BROKER_NAMESPACE}" \ --set broker.ca="${submariner_broker_ca}" \ - --set broker.globalnet="${GLOBALNET}" \ + --set broker.globalnet="${OVERLAPPING}" \ --set submariner.serviceDiscovery="${LIGHTHOUSE}" \ --set submariner.cableDriver="${CABLE_DRIVER}" \ --set submariner.clusterId="${cluster}" \ --set submariner.clusterCidr="${cluster_CIDRs[$cluster]}" \ --set submariner.serviceCidr="${service_CIDRs[$cluster]}" \ --set submariner.globalCidr="${global_CIDRs[$cluster]}" \ - --set serviceAccounts.globalnet.create="${GLOBALNET}" \ + --set serviceAccounts.globalnet.create="${OVERLAPPING}" \ --set serviceAccounts.lighthouseAgent.create="${LIGHTHOUSE}" \ --set serviceAccounts.lighthouseCoreDns.create="${LIGHTHOUSE}" \ --set submariner.natEnabled="false" \ diff --git a/scripts/shared/lib/deploy_operator b/scripts/shared/lib/deploy_operator index a56e6873f..58845df1e 100644 --- a/scripts/shared/lib/deploy_operator +++ b/scripts/shared/lib/deploy_operator @@ -28,7 +28,7 @@ function deploytool_prereqs() { function setup_broker() { local extra_flags=() - [[ "${GLOBALNET}" = true ]] && extra_flags+=(--globalnet) + [[ "${OVERLAPPING}" = true ]] && extra_flags+=(--globalnet) if [[ "${LIGHTHOUSE}" == true ]]; then extra_flags+=(--components 'service-discovery,connectivity') else diff --git a/scripts/shared/lib/utils b/scripts/shared/lib/utils index fb2aa951c..be9ccd369 100644 --- a/scripts/shared/lib/utils +++ b/scripts/shared/lib/utils @@ -164,14 +164,11 @@ function registry_running() { return $? } -function add_cluster_cidrs() { +function set_cluster_cidrs() { local val=$1 local idx=$2 - if [[ "${GLOBALNET}" == "true" ]]; then - val="0" - global_CIDRs[$idx]="242.254.${1}.0/24" - fi + [[ "$OVERLAPPING" != "true" ]] || val="0" cluster_CIDRs[$idx]="10.$((val+129)).0.0/16" service_CIDRs[$idx]="100.$((val+65)).0.0/16" @@ -183,11 +180,12 @@ function add_cluster_cidrs() { function declare_cidrs() { local DEBUG_PRINT=false # shellcheck disable=SC2034 # these variables are used elsewhere - declare -gA cluster_CIDRs cluster_IPv6_CIDRs service_CIDRs service_IPv6_CIDRs global_CIDRs + declare -gA cluster_number cluster_CIDRs cluster_IPv6_CIDRs service_CIDRs service_IPv6_CIDRs local cluster i=1 for cluster in "${clusters[@]}"; do - add_cluster_cidrs "$i" "$cluster" + cluster_number[$cluster]="$i" + set_cluster_cidrs "$i" "$cluster" i=$(("$i"+1)) done } diff --git a/scripts/shared/resources/bundle/broker.yaml b/scripts/shared/resources/bundle/broker.yaml index ff3ebcaaf..532263c44 100644 --- a/scripts/shared/resources/bundle/broker.yaml +++ b/scripts/shared/resources/bundle/broker.yaml @@ -7,5 +7,5 @@ metadata: spec: components: ["${components}"] defaultGlobalnetClusterSize: 8192 - globalnetEnabled: ${GLOBALNET} + globalnetEnabled: ${OVERLAPPING} globalnetCIDRRange: 169.254.0.0/16