Skip to content

Commit

Permalink
Modify metallb/metallb_config to allow more customization
Browse files Browse the repository at this point in the history
Adopting a multicontroller OSP 17.1 wallaby deployment means
modifying a lot of the hardcoded values in netattach stage.
In order to make things easier the Interfaces, Networks and vlans
are parameterized.
  • Loading branch information
averdagu committed Oct 6, 2023
1 parent 2a430df commit 107c317
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 15 deletions.
50 changes: 50 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ POD_STORAGE_IP_START ?= 30
POD_STORAGE_IP_END ?= 70
POD_TENANT_IP_START ?= 30
POD_TENANT_IP_END ?= 70
POD_METALLB_INTERNALAPI_IP_START ?= 80
POD_METALLB_INTERNALAPI_IP_END ?= 90
POD_METALLB_STORAGE_IP_START ?= 80
POD_METALLB_STORAGE_IP_END ?= 90
POD_METALLB_TENANT_IP_START ?= 80
POD_METALLB_TENANT_IP_END ?= 90

# multiple controller deployment (MCD)
MCD_ENABLED ?= false
Expand All @@ -46,6 +52,12 @@ MCD_STORAGE_IP_START ?= 150
MCD_STORAGE_IP_END ?= 190
MCD_TENANT_IP_START ?= 150
MCD_TENANT_IP_END ?= 190
MCD_METALLB_INTERNALAPI_IP_START ?= 191
MCD_METALLB_INTERNALAPI_IP_END ?= 201
MCD_METALLB_STORAGE_IP_START ?= 191
MCD_METALLB_STORAGE_IP_END ?= 201
MCD_METALLB_TENANT_IP_START ?= 191
MCD_METALLB_TENANT_IP_END ?= 201

# Allows overriding the cleanup command used in *_cleanup targets.
# Useful in CI, to allow injectin kustomization in each operator CR directory
Expand Down Expand Up @@ -387,6 +399,14 @@ NETATTACH_STORAGE_IP_END ?= $(if $(findstring true, $(MCD_ENABLED)),$(MCD_STORAG
NETATTACH_TENANT_IP_START ?= $(if $(findstring true, $(MCD_ENABLED)),$(MCD_TENANT_IP_START),$(POD_TENANT_IP_START))
NETATTACH_TENANT_IP_END ?= $(if $(findstring true, $(MCD_ENABLED)),$(MCD_TENANT_IP_END),$(POD_TENANT_IP_END))

# metallb
METALLB_INTERNALIP_IP_START ?= $(if $(findstring true, $(MCD_ENABLED)),$(MCD_METALLB_INTERNALAPI_IP_START),$(POD_METALLB_INTERNALAPI_IP_START))
METALLB_INTERNALIP_IP_END ?= $(if $(findstring true, $(MCD_ENABLED)),$(MCD_METALLB_INTERNALAPI_IP_END),$(POD_METALLB_INTERNALAPI_IP_END))
METALLB_STORAGE_IP_START ?= $(if $(findstring true, $(MCD_ENABLED)),$(MCD_METALLB_STORAGE_IP_START),$(POD_METALLB_STORAGE_IP_START))
METALLB_STORAGE_IP_END ?= $(if $(findstring true, $(MCD_ENABLED)),$(MCD_METALLB_STORAGE_IP_END),$(POD_METALLB_STORAGE_IP_END))
METALLB_STORAGE_IP_START ?= $(if $(findstring true, $(MCD_ENABLED)),$(MCD_METALLB_TENANT_IP_START),$(POD_METALLB_TENANT_IP_START))
METALLB_STORAGE_IP_END ?= $(if $(findstring true, $(MCD_ENABLED)),$(MCD_METALLB_TENANT_IP_END),$(POD_METALLB_TENANT_IP_END))

# Telemetry
TELEMETRY_IMG ?= quay.io/openstack-k8s-operators/telemetry-operator-index:latest
TELEMETRY_REPO ?= https://github.com/openstack-k8s-operators/telemetry-operator.git
Expand Down Expand Up @@ -1866,6 +1886,21 @@ netattach_cleanup: ## Deletes the network-attachment-definitions
.PHONY: metallb
metallb: export NAMESPACE=metallb-system
metallb: export INTERFACE=${NNCP_INTERFACE}
metallb: export INTERFACE_DATA=${NNCP_INTERFACE_DATA}
metallb: export INTERFACE_MANAGEMENT=${NNCP_INTERFACE_MANAGEMENT}
metallb: export INTERFACE_EXTERNAL=${NNCP_INTERFACE_EXTERNAL}
metallb: export INTERNALAPI_VLAN=${NNCP_INTERNALAPI_VLAN}
metallb: export STORAGE_VLAN=${NNCP_STORAGE_VLAN}
metallb: export TENANT_VLAN=${NNCP_TENANT_VLAN}
metallb: export INTERNALAPI_NET=${NNCP_INTERNALAPI_NET}
metallb: export STORAGE_NET=${NNCP_STORAGE_NET}
metallb: export TENANT_NET=${NNCP_TENANT_NET}
metallb: export INTERNALAPI_IP_START=${METALLB_INTERNALIP_IP_START}
metallb: export INTERNALAPI_IP_END=${METALLB_INTERNALIP_IP_END}
metallb: export STORAGE_IP_START=${METALLB_STORAGE_IP_START}
metallb: export STORAGE_IP_END=${METALLB_STORAGE_IP_END}
metallb: export TENANT_IP_START=${METALLB_TENANT_IP_START}
metallb: export TENANT_IP_END=${METALLB_TENANT_IP_END}
metallb: ## installs metallb operator in the metallb-system namespace
$(eval $(call vars,$@,metallb))
bash scripts/gen-namespace.sh
Expand All @@ -1885,6 +1920,21 @@ metallb: ## installs metallb operator in the metallb-system namespace
metallb_config: export NAMESPACE=metallb-system
metallb_config: export CTLPLANE_METALLB_POOL=${METALLB_POOL}
metallb_config: export INTERFACE=${NNCP_INTERFACE}
metallb_config: export INTERFACE_DATA=${NNCP_INTERFACE_DATA}
metallb_config: export INTERFACE_MANAGEMENT=${NNCP_INTERFACE_MANAGEMENT}
metallb_config: export INTERFACE_EXTERNAL=${NNCP_INTERFACE_EXTERNAL}
metallb_config: export INTERNALAPI_VLAN=${NNCP_INTERNALAPI_VLAN}
metallb_config: export STORAGE_VLAN=${NNCP_STORAGE_VLAN}
metallb_config: export TENANT_VLAN=${NNCP_TENANT_VLAN}
metallb_config: export INTERNALAPI_NET=${NNCP_INTERNALAPI_NET}
metallb_config: export STORAGE_NET=${NNCP_STORAGE_NET}
metallb_config: export TENANT_NET=${NNCP_TENANT_NET}
metallb_config: export INTERNALAPI_IP_START=${METALLB_INTERNALIP_IP_START}
metallb_config: export INTERNALAPI_IP_END=${METALLB_INTERNALIP_IP_END}
metallb_config: export STORAGE_IP_START=${METALLB_STORAGE_IP_START}
metallb_config: export STORAGE_IP_END=${METALLB_STORAGE_IP_END}
metallb_config: export TENANT_IP_START=${METALLB_STORAGE_IP_START}
metallb_config: export TENANT_IP_END=${METALLB_STORAGE_IP_END}
metallb_config: metallb_config_cleanup ## creates the IPAddressPools and l2advertisement resources
$(eval $(call vars,$@,metallb))
bash scripts/gen-olm-metallb.sh
Expand Down
45 changes: 30 additions & 15 deletions scripts/gen-olm-metallb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,40 @@
# under the License.
set -ex

if [ -z "${OPERATOR_DIR}" ]; then
echo "Please set OPERATOR_DIR"; exit 1
fi
function check_var_setted () {
if [[ ! -v $1 ]]; then
echo "Please set $1"; exit 1
fi
}

check_var_setted OPERATOR_DIR

if [ ! -d ${OPERATOR_DIR} ]; then
mkdir -p ${OPERATOR_DIR}
fi

if [ -z "${DEPLOY_DIR}" ]; then
echo "Please set DEPLOY_DIR"; exit 1
fi
check_var_setted DEPLOY_DIR

if [ ! -d ${DEPLOY_DIR} ]; then
mkdir -p ${DEPLOY_DIR}
fi

if [ -z "${INTERFACE}" ]; then
echo "Please set INTERFACE"; exit 1
fi
check_var_setted INTERFACE
check_var_setted INTERFACE_DATA
check_var_setted INTERFACE_MANAGEMENT
check_var_setted INTERFACE_EXTERNAL
check_var_setted INTERNALAPI_VLAN
check_var_setted STORAGE_VLAN
check_var_setted TENANT_VLAN
check_var_setted INTERNALAPI_NET
check_var_setted STORAGE_NET
check_var_setted TENANT_NET
check_var_setted INTERNALAPI_IP_START
check_var_setted INTERNALAPI_IP_END
check_var_setted STORAGE_IP_START
check_var_setted STORAGE_IP_END
check_var_setted TENANT_IP_START
check_var_setted TENANT_IP_END

echo OPERATOR_DIR ${OPERATOR_DIR}
echo DEPLOY_DIR ${DEPLOY_DIR}
Expand Down Expand Up @@ -90,7 +105,7 @@ metadata:
name: internalapi
spec:
addresses:
- 172.17.0.80-172.17.0.90
- ${INTERNALAPI_NET}.${INTERNALAPI_IP_START}-${INTERNALAPI_NET}.${INTERNALAPI_IP_END}
---
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
Expand All @@ -99,7 +114,7 @@ metadata:
name: storage
spec:
addresses:
- 172.18.0.80-172.18.0.90
- ${STORAGE_NET}.${STORAGE_IP_START}-${STORAGE_NET}.${STORAGE_IP_END}
---
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
Expand All @@ -108,7 +123,7 @@ metadata:
name: tenant
spec:
addresses:
- 172.19.0.80-172.19.0.90
- ${TENANT_NET}.${TENANT_IP_START}-${TENANT_NET}.${TENANT_IP_END}
EOF_CAT

cat > ${DEPLOY_DIR}/l2advertisement.yaml <<EOF_CAT
Expand All @@ -133,7 +148,7 @@ spec:
ipAddressPools:
- internalapi
interfaces:
- ${INTERFACE}.20
- ${INTERFACE_DATA}.${INTERNALAPI_VLAN}
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
Expand All @@ -144,7 +159,7 @@ spec:
ipAddressPools:
- storage
interfaces:
- ${INTERFACE}.21
- ${INTERFACE_MANAGEMENT}.${STORAGE_VLAN}
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
Expand All @@ -155,5 +170,5 @@ spec:
ipAddressPools:
- tenant
interfaces:
- ${INTERFACE}.22
- ${INTERFACE_MANAGEMENT}.${TENANT_VLAN}
EOF_CAT

0 comments on commit 107c317

Please sign in to comment.