Add Subcluster Networking Catalogue

This PS introduces a subcluster networking catalogue and combines all subcluster related networking
in one place so that it can be managed centrally.

A site level patch uses replacement rules defined at type/multi-tenant level to take data out of subcluster-networking catalogue
and inject into networking catalogue.

Relates-To: #103
Closes: #103

Change-Id: I732937a4b68ccb0d290356bed8dbbeae838bae79
This commit is contained in:
Ratnopam Chakrabarti 2021-03-10 20:54:23 -05:00 committed by Drew Walters
parent 4afe0b43f9
commit aedecd4495
12 changed files with 166 additions and 9 deletions

View File

@ -39,3 +39,9 @@ patches: |-
metadata:
name: networking-ha
$patch: delete
---
apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue
metadata:
name: subcluster-networking
$patch: delete

View File

@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# This pulls in general site catalog information which is valid across clusters
# It also pulls in undercloud-specific values, which will be replaced below
- ../../../target/catalogues/
transformers:
# This replaces lma-specific network data from the lma stanza
# of the subcluster-networking catalogue into the standard networking catalogue
- ../../../../../type/multi-tenant/sub-clusters/lma/catalogue-replacements

View File

@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# This pulls in general site catalog information which is valid across clusters
# It also pulls in undercloud-specific values, which will be replaced below
- ../../../target/catalogues/
transformers:
# This replaces wordpress-specific network data from the wordpress stanza
# of the subcluster-networking catalogue into the standard networking catalogue
- ../../../../../type/multi-tenant/sub-clusters/wordpress/catalogue-replacements

View File

@ -39,3 +39,10 @@ patches: |-
metadata:
name: networking-ha
$patch: delete
---
apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue
metadata:
name: subcluster-networking
$patch: delete

View File

@ -13,7 +13,7 @@ spec:
controlPlaneEndpoint:
host: "10.23.25.102"
apiserverCertSANs: "[10.23.25.102, 10.23.24.102]"
ironic:
provisioningIp: "10.23.24.102"
dhcpRange: "10.23.24.200,10.23.24.250"

View File

@ -2,10 +2,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../airship-core/shared/catalogues
- subcluster-networking.yaml
# NOTE(drewwalters96): Uncomment to patch networking catalogue.
# patchesStrategicMerge:
# - networking.yaml
# Uncomment to patch versions catalogue once needed
# patchesStrategicMerge:
# - versions.yaml

View File

@ -1,2 +0,0 @@
# NOTE(drewwalters96): This patch file is applied to override the
# airship-core networking catalogue.

View File

@ -0,0 +1,58 @@
# This catalogue gathers in one place networking configuration which must
# be coordinated among the target (undercloud) cluster and different subclusters.
# In particular, it contains `kubernetes` stanzas which are intended to be
# substituted into subclusters' networking catalogues (to be consumed by
# e.g. the k8scontrol function), and subcluster ports which must be known by
# SIP loadbalancers in the target cluster and NodePorts in the subclusters.
apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue
metadata:
labels:
airshipit.org/deploy-k8s: "false"
name: subcluster-networking
spec:
lma:
# This stanza is replaced directly into lma's networking catalogue
kubernetes:
serviceCidr: "10.0.80.0/20"
podCidr: "192.168.0.0/18"
controlPlaneEndpoint:
host: "10.23.25.102" # ephemeral will be different
port: 6443
# NOTE: This stringing is required to do substring replacement.
# Ideally, improve this in the future.
apiserverCertSANs: "[10.23.25.201, 10.23.24.201]"
# TODO: might spin this differently if SIP needs ranges instead of individual ports.
# But really, it makes sense to put all this info in the same place in any case
# The non-overlapping port range allocated to the lma subcluster
# One of these ports (11000? 11001?) will be automaticaly used by SIP
# to build a loadbalancer for the k8s API
port_range: [11020, 11039]
# This is consumed by two different targets:
# 1. SIP in the undercloud, to set up lma's load balancers
# 2. NodePorts in the subcluster
exposed_services:
- name: lma # Service metadata.name
selector: # Service spec.selector
app: lma
ports: # Service spec.ports
- port: 11022
targetPort: 80
protocol: TCP
name: http
wordpress:
# This stanza is replaced directly into lma's networking catalogue
kubernetes:
serviceCidr: "10.0.80.0/20"
podCidr: "192.168.0.0/18"
controlPlaneEndpoint:
host: "10.23.25.102"
port: 6443
apiserverCertSANs: [10.23.25.201, 10.23.24.201]
port_range: ["11040:11059"]

View File

@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- subcluster-networking.yaml

View File

@ -0,0 +1,33 @@
# These rules take artifactory-specific data out of the subcluster catalogue,
# and overwrites it into the networking catalogue
# as well as some (TODO) catalogue that feeds into subcluster NodePorts
apiVersion: airshipit.org/v1alpha1
kind: ReplacementTransformer
metadata:
name: lma-subcluster-networking
annotations:
config.kubernetes.io/function: |-
container:
image: quay.io/airshipit/replacement-transformer:latest
replacements:
# Replace Kubernetes networking info
- source:
objref:
kind: VariableCatalogue
name: subcluster-networking
fieldref: "{.spec.lma.kubernetes}"
target:
objref:
kind: NetworkCatalogue
name: networking
fieldrefs: ["{.spec.kubernetes}"]
- source:
objref:
kind: VariableCatalogue
name: subcluster-networking
fieldref: "{.spec.lma.port_range}"
target:
objref:
kind: NetworkCatalogue
name: networking
fieldrefs: ["{.spec.port_range}"]

View File

@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- subcluster-networking.yaml

View File

@ -0,0 +1,30 @@
apiVersion: airshipit.org/v1alpha1
kind: ReplacementTransformer
metadata:
name: wordpress-subcluster-networking
annotations:
config.kubernetes.io/function: |-
container:
image: quay.io/airshipit/replacement-transformer:latest
replacements:
# Replace Kubernetes networking info
- source:
objref:
kind: VariableCatalogue
name: subcluster-networking
fieldref: "{.spec.wordpress.kubernetes}"
target:
objref:
kind: NetworkCatalogue
name: networking
fieldrefs: ["{.spec.kubernetes}"]
- source:
objref:
kind: VariableCatalogue
name: subcluster-networking
fieldref: "{.spec.wordpress.port_range}"
target:
objref:
kind: NetworkCatalogue
name: networking
fieldrefs: ["{.spec.port_range}"]