Skip to content

Commit

Permalink
Rename GLOBALNET to OVERLAPPING
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mkolesnik committed Dec 11, 2023
1 parent 0935096 commit 92f736b
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 24 deletions.
6 changes: 3 additions & 3 deletions Makefile.clusters
Original file line number Diff line number Diff line change
Expand Up @@ -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=` ###

Expand All @@ -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)))
Expand Down
11 changes: 8 additions & 3 deletions Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion scripts/shared/clusters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
Expand Down
11 changes: 10 additions & 1 deletion scripts/shared/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions scripts/shared/lib/clusters_kind
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion scripts/shared/lib/deploy_bundle
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down
2 changes: 1 addition & 1 deletion scripts/shared/lib/deploy_funcs
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand Down
4 changes: 2 additions & 2 deletions scripts/shared/lib/deploy_helm
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
2 changes: 1 addition & 1 deletion scripts/shared/lib/deploy_operator
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions scripts/shared/lib/utils
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/shared/resources/bundle/broker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ metadata:
spec:
components: ["${components}"]
defaultGlobalnetClusterSize: 8192
globalnetEnabled: ${GLOBALNET}
globalnetEnabled: ${OVERLAPPING}
globalnetCIDRRange: 169.254.0.0/16

0 comments on commit 92f736b

Please sign in to comment.