Create NetworkCatalogue structural schema CRD

Replaces the networking VariableCatalogue with a
structural schema NetworkCatalogue CRD.

Relates-To: #468
Change-Id: I9973708799ec35c2dde5832e7400c798dc7adae1
This commit is contained in:
Matthew Fuller 2021-02-20 00:35:27 +00:00
parent 3fec6981f0
commit 5820e22d9f
12 changed files with 260 additions and 140 deletions

View File

@ -1,62 +1,62 @@
# The default networking catalogue for functions hosted in the airshipctl project. # The default networking catalogue for functions hosted in the airshipctl project.
# These values can be overridden at the site, type, etc levels as appropriate. # These values can be overridden at the site, type, etc levels as appropriate.
apiVersion: airshipit.org/v1alpha1 apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue kind: NetworkCatalogue
metadata: metadata:
name: networking name: networking
labels: labels:
airshipit.org/deploy-k8s: "false" airshipit.org/deploy-k8s: "false"
spec:
# The catalogue should be overridden as appropriate for different kubernetes
# clusters, e.g. ephemeral vs target vs tenant
kubernetes:
serviceCidr: "10.96.0.0/12"
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]"
# The catalogue should be overridden as appropriate for different kubernetes ironic:
# clusters, e.g. ephemeral vs target vs tenant provisioningInterface: "pxe"
kubernetes: provisioningIp: "10.23.25.102"
serviceCidr: "10.96.0.0/12" dhcpRange: "10.23.25.200,10.23.25.250"
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]"
ironic: # This section is only relevant when using Metal3 BareMetalHosts, and
provisioningInterface: "pxe" # is consumed by the `hostgenerator-m3` function.
provisioningIp: "10.23.25.102" # It defines host-level networking that is common across all BMHs in a site,
dhcpRange: "10.23.25.200,10.23.25.250" # and will typically be fully overridden at the Type and Site level.
commonHostNetworking:
# This section is only relevant when using Metal3 BareMetalHosts, and links:
# is consumed by the `hostgenerator-m3` function. - id: oam
# It defines host-level networking that is common across all BMHs in a site, name: oam
# and will typically be fully overridden at the Type and Site level. type: phy
commonHostNetworking: mtu: "1500"
links: # ethernet_mac_address: <from host-catalogue> (optional)
- id: oam - id: pxe
name: oam name: pxe
type: phy type: phy
mtu: "1500" mtu: "1500"
# ethernet_mac_address: <from host-catalogue> (optional) # ethernet_mac_address: <from host-catalogue> (optional)
- id: pxe networks:
name: pxe - id: oam-ipv4
type: phy type: ipv4
mtu: "1500" link: oam
# ethernet_mac_address: <from host-catalogue> (optional) # ip_address: <from host-catalogue>
networks: netmask: 255.255.255.0
- id: oam-ipv4 routes:
type: ipv4 - network: 0.0.0.0
link: oam netmask: 0.0.0.0
# ip_address: <from host-catalogue> gateway: 10.23.25.1
netmask: 255.255.255.0 - id: pxe-ipv4
routes: type: ipv4
- network: 0.0.0.0 link: pxe
netmask: 0.0.0.0 # ip_address: <from host-catalogue>
gateway: 10.23.25.1 netmask: 255.255.255.0
- id: pxe-ipv4 services:
type: ipv4 - address: 8.8.8.8
link: pxe type: dns
# ip_address: <from host-catalogue> - address: 8.8.4.4
netmask: 255.255.255.0 type: dns
services:
- address: 8.8.8.8
type: dns
- address: 8.8.4.4
type: dns

View File

@ -1,2 +1,3 @@
resources: resources:
- versions-catalogue.yaml - versions-catalogue.yaml
- network-catalogue.yaml

View File

@ -0,0 +1,121 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: networkcatalogues.airshipit.org
spec:
group: airshipit.org
names:
kind: NetworkCatalogue
plural: networkcatalogues
singular: networkcatalogue
scope: Namespaced
versions:
- name: v1alpha1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
commonHostNetworking:
type: object
properties:
links:
type: array
items:
type: object
properties:
id:
type: string
name:
type: string
type:
type: string
mtu:
type: string
networks:
type: array
items:
type: object
properties:
id:
type: string
type:
type: string
link:
type: string
netmask:
type: string
oneOf:
- format: ipv4
- format: ipv6
routes:
type: array
items:
type: object
properties:
network:
type: string
oneOf:
- format: ipv4
- format: ipv6
netmask:
type: string
oneOf:
- format: ipv4
- format: ipv6
gateway:
type: string
oneOf:
- format: ipv4
- format: ipv6
services:
type: array
items:
type: object
properties:
address:
type: string
oneOf:
- format: ipv4
- format: ipv6
type:
type: string
kubernetes:
type: object
properties:
serviceCidr:
type: string
format: cidr
podCidr:
type: string
format: cidr
controlPlaneEndpoint:
type: object
properties:
host:
type: string
oneOf:
- format: ipv4
- format: ipv6
port:
type: integer
maximum: 65535
apiserverCertSANs:
type: string
ironic:
type: object
properties:
provisioningInterface:
type: string
provisioningIp:
type: string
oneOf:
- format: ipv4
- format: ipv6
dhcpRange:
# TODO(mfuller): should this be enforced with a pattern?
type: string

View File

@ -11,9 +11,9 @@ replacements:
# Replace the pod & service networks # Replace the pod & service networks
- source: - source:
objref: objref:
kind: VariableCatalogue kind: NetworkCatalogue
name: networking name: networking
fieldref: ironic.provisioningInterface fieldref: spec.ironic.provisioningInterface
target: target:
objref: objref:
kind: ConfigMap kind: ConfigMap
@ -21,9 +21,9 @@ replacements:
fieldrefs: ["data.PROVISIONING_INTERFACE"] fieldrefs: ["data.PROVISIONING_INTERFACE"]
- source: - source:
objref: objref:
kind: VariableCatalogue kind: NetworkCatalogue
name: networking name: networking
fieldref: ironic.provisioningIp fieldref: spec.ironic.provisioningIp
target: target:
objref: objref:
kind: ConfigMap kind: ConfigMap
@ -31,9 +31,9 @@ replacements:
fieldrefs: ["data.PROVISIONING_IP"] fieldrefs: ["data.PROVISIONING_IP"]
- source: - source:
objref: objref:
kind: VariableCatalogue kind: NetworkCatalogue
name: networking name: networking
fieldref: ironic.dhcpRange fieldref: spec.ironic.dhcpRange
target: target:
objref: objref:
kind: ConfigMap kind: ConfigMap

View File

@ -11,9 +11,9 @@ replacements:
# Substring-replace the ephemeral control plane's info # Substring-replace the ephemeral control plane's info
- source: - source:
objref: objref:
kind: VariableCatalogue kind: NetworkCatalogue
name: networking name: networking
fieldref: kubernetes.controlPlaneEndpoint.host fieldref: spec.kubernetes.controlPlaneEndpoint.host
target: target:
objref: objref:
name: ephemeral-bmc-secret name: ephemeral-bmc-secret
@ -21,9 +21,9 @@ replacements:
fieldrefs: ["stringData.userData%REPLACEMENT_CP_IP%"] fieldrefs: ["stringData.userData%REPLACEMENT_CP_IP%"]
- source: - source:
objref: objref:
kind: VariableCatalogue kind: NetworkCatalogue
name: networking name: networking
fieldref: kubernetes.controlPlaneEndpoint.port fieldref: spec.kubernetes.controlPlaneEndpoint.port
target: target:
objref: objref:
name: ephemeral-bmc-secret name: ephemeral-bmc-secret
@ -31,9 +31,9 @@ replacements:
fieldrefs: ["stringData.userData%REPLACEMENT_CP_PORT%"] fieldrefs: ["stringData.userData%REPLACEMENT_CP_PORT%"]
- source: - source:
objref: objref:
kind: VariableCatalogue kind: NetworkCatalogue
name: networking name: networking
fieldref: kubernetes.apiserverCertSANs fieldref: spec.kubernetes.apiserverCertSANs
target: target:
objref: objref:
name: ephemeral-bmc-secret name: ephemeral-bmc-secret
@ -41,9 +41,9 @@ replacements:
fieldrefs: ["stringData.userData%REPLACEMENT_CERT_SANS%"] fieldrefs: ["stringData.userData%REPLACEMENT_CERT_SANS%"]
- source: - source:
objref: objref:
kind: VariableCatalogue kind: NetworkCatalogue
name: networking name: networking
fieldref: kubernetes.podCidr fieldref: spec.kubernetes.podCidr
target: target:
objref: objref:
name: ephemeral-bmc-secret name: ephemeral-bmc-secret

View File

@ -29,9 +29,9 @@ replacements:
fieldrefs: ["{.values.hostsToGenerate}"] fieldrefs: ["{.values.hostsToGenerate}"]
- source: - source:
objref: objref:
kind: VariableCatalogue kind: NetworkCatalogue
name: networking name: networking
fieldref: "{.commonHostNetworking}" fieldref: "{.spec.commonHostNetworking}"
target: target:
objref: objref:
kind: Templater kind: Templater

View File

@ -16,18 +16,18 @@ replacements:
# Replace the pod & service networks # Replace the pod & service networks
- source: - source:
objref: objref:
kind: VariableCatalogue kind: NetworkCatalogue
name: networking name: networking
fieldref: kubernetes.serviceCidr fieldref: spec.kubernetes.serviceCidr
target: target:
objref: objref:
kind: Cluster kind: Cluster
fieldrefs: ["spec.clusterNetwork.services.cidrBlocks.0"] fieldrefs: ["spec.clusterNetwork.services.cidrBlocks.0"]
- source: - source:
objref: objref:
kind: VariableCatalogue kind: NetworkCatalogue
name: networking name: networking
fieldref: kubernetes.podCidr fieldref: spec.kubernetes.podCidr
target: target:
objref: objref:
kind: Cluster kind: Cluster
@ -36,9 +36,9 @@ replacements:
# Replace the k8s controlplane host endpoint # Replace the k8s controlplane host endpoint
- source: - source:
objref: objref:
kind: VariableCatalogue kind: NetworkCatalogue
name: networking name: networking
fieldref: kubernetes.controlPlaneEndpoint fieldref: spec.kubernetes.controlPlaneEndpoint
target: target:
objref: objref:
kind: Metal3Cluster kind: Metal3Cluster

View File

@ -11,7 +11,7 @@ patches: |-
$patch: delete $patch: delete
--- ---
apiVersion: airshipit.org/v1alpha1 apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue kind: NetworkCatalogue
metadata: metadata:
name: networking name: networking
$patch: delete $patch: delete

View File

@ -2,19 +2,18 @@
# ephemeral cluster, on top of the target cluster networking definition. # ephemeral cluster, on top of the target cluster networking definition.
# These values can be overridden at the site, type, etc levels as appropriate. # These values can be overridden at the site, type, etc levels as appropriate.
apiVersion: airshipit.org/v1alpha1 apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue kind: NetworkCatalogue
metadata: metadata:
name: networking name: networking
spec:
# The catalogue should be overridden as appropriate for different kubernetes
# clusters, e.g. ephemeral vs target vs tenant
kubernetes:
podCidr: "192.168.0.0/24"
controlPlaneEndpoint:
host: "10.23.25.101"
apiserverCertSANs: "[10.23.25.101, 10.23.24.101]"
# The catalogue should be overridden as appropriate for different kubernetes ironic:
# clusters, e.g. ephemeral vs target vs tenant provisioningIp: "10.23.24.101"
kubernetes: dhcpRange: "10.23.24.200,10.23.24.250"
podCidr: "192.168.0.0/24"
controlPlaneEndpoint:
host: "10.23.25.101"
apiserverCertSANs: "[10.23.25.101, 10.23.24.101]"
ironic:
provisioningIp: "10.23.24.101"
dhcpRange: "10.23.24.200,10.23.24.250"

View File

@ -11,7 +11,7 @@ patches: |-
$patch: delete $patch: delete
--- ---
apiVersion: airshipit.org/v1alpha1 apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue kind: NetworkCatalogue
metadata: metadata:
name: networking name: networking
$patch: delete $patch: delete

View File

@ -2,18 +2,17 @@
# ephemeral cluster, on top of the target cluster networking definition. # ephemeral cluster, on top of the target cluster networking definition.
# These values can be overridden at the site, type, etc levels as appropriate. # These values can be overridden at the site, type, etc levels as appropriate.
apiVersion: airshipit.org/v1alpha1 apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue kind: NetworkCatalogue
metadata: metadata:
name: networking name: networking
spec:
# The catalogue should be overridden as appropriate for different kubernetes
# clusters, e.g. ephemeral vs target vs tenant
kubernetes:
controlPlaneEndpoint:
host: "10.23.25.102"
apiserverCertSANs: "[10.23.25.102, 10.23.24.102]"
# The catalogue should be overridden as appropriate for different kubernetes ironic:
# clusters, e.g. ephemeral vs target vs tenant provisioningIp: "10.23.24.102"
kubernetes: dhcpRange: "10.23.24.200,10.23.24.250"
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

@ -1,45 +1,45 @@
# The default networking catalogue for site- and operator-specific networking. # The default networking catalogue for site- and operator-specific networking.
# These values can be overridden at the site, type, etc levels as appropriate. # These values can be overridden at the site, type, etc levels as appropriate.
apiVersion: airshipit.org/v1alpha1 apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue kind: NetworkCatalogue
metadata: metadata:
name: networking name: networking
labels: labels:
airshipit.org/deploy-k8s: "false" airshipit.org/deploy-k8s: "false"
spec:
# This section is only relevant when using Metal3 BareMetalHosts, and # This section is only relevant when using Metal3 BareMetalHosts, and
# is consumed by the `hostgenerator-m3` function. # is consumed by the `hostgenerator-m3` function.
# It defines host-level networking that is common across all BMHs in a site, # It defines host-level networking that is common across all BMHs in a site,
# and will typically be fully overridden at the Type and Site level. # and will typically be fully overridden at the Type and Site level.
commonHostNetworking: commonHostNetworking:
links: links:
- id: oam - id: oam
name: oam name: oam
type: phy type: phy
mtu: "1500" mtu: "1500"
# ethernet_mac_address: <from host-catalogue> (optional) # ethernet_mac_address: <from host-catalogue> (optional)
- id: pxe - id: pxe
name: pxe name: pxe
type: phy type: phy
mtu: "1500" mtu: "1500"
# ethernet_mac_address: <from host-catalogue> (optional) # ethernet_mac_address: <from host-catalogue> (optional)
networks: networks:
- id: oam-ipv4 - id: oam-ipv4
type: ipv4 type: ipv4
link: oam link: oam
# ip_address: <from host-catalogue> # ip_address: <from host-catalogue>
netmask: 255.255.255.0 netmask: 255.255.255.0
routes: routes:
- network: 0.0.0.0 - network: 0.0.0.0
netmask: 0.0.0.0 netmask: 0.0.0.0
gateway: 10.23.25.1 gateway: 10.23.25.1
- id: pxe-ipv4 - id: pxe-ipv4
type: ipv4 type: ipv4
link: pxe link: pxe
# ip_address: <from host-catalogue> # ip_address: <from host-catalogue>
netmask: 255.255.255.0 netmask: 255.255.255.0
services: services:
- address: 8.8.8.8 - address: 8.8.8.8
type: dns type: dns
- address: 8.8.4.4 - address: 8.8.4.4
type: dns type: dns