cluster-cudn
by startxfr
Configure OVN-Kubernetes user-defined networks (ClusterUserDefinedNetwork and UserDefinedNetwork)
About this chart
Cluster Chart : User-defined networks
Configure OVN-Kubernetes user-defined networks (ClusterUserDefinedNetwork and UserDefinedNetwork).
This chart is part of the cluster-xxx startx helm chart series that doesn't necessarily deploy pods but rather represent a cluster configuration state orchestrated by gitops tools like ArgoCD.
User-defined networks (UDN) are a native feature of the OVN-Kubernetes network plugin: they create isolated layer 2 or layer 3
network segments that replace (primary network) or complete (secondary network) the default pod network of the selected namespaces,
with optional persistent IP addresses for virtual machines. No operator is required, the ClusterUserDefinedNetwork and
UserDefinedNetwork APIs (k8s.ovn.org/v1) are shipped with OpenShift. This chart manages:
- Namespaces attached to a primary user-defined network, created with the mandatory
k8s.ovn.org/primary-user-defined-networklabel - ClusterUserDefinedNetwork resources (cluster-scoped, shared across the namespaces matched by a selector,
Layer2,Layer3orLocalnettopology) - UserDefinedNetwork resources (namespace-scoped,
Layer2orLayer3topology)
Requirements and guidelines
Read the startx helm-repository homepage for more information on how to use these resources.
Prerequisites
- An OpenShift cluster running the OVN-Kubernetes network plugin (the only plugin providing the user-defined network APIs)
- OpenShift 4.18 or later, the first release where user-defined network segmentation is generally available
- For
Localnetnetworks, an OVS bridge mapping on the nodes created with aNodeNetworkConfigurationPolicy(see the cluster-nmstate chart): thephysicalNetworkNameof the network must match thelocalnetvalue of theovn.bridge-mappingsitem of the policy cluster-adminprivileges:ClusterUserDefinedNetworkresources and namespaces are cluster-scoped
Namespaces and the primary network label
OVN-Kubernetes only attaches a namespace to a primary user-defined network when the namespace carries the
k8s.ovn.org/primary-user-defined-network: "" label. This label can only be set when the namespace is created (it cannot be
added afterwards) and must exist before any pod runs in the namespace. The namespaces block of this chart therefore creates
the tenant namespaces itself (sync-wave -10, annotated helm.sh/resource-policy: keep so that they survive a chart removal),
with the label and the additional labels used by the ClusterUserDefinedNetwork namespace selectors. Create these namespaces
with this chart (or with the project chart and its additionalLabels option), never with an ArgoCD CreateNamespace=true
sync option that would create them without the label.
Additional rules to keep in mind:
- the
defaultnamespace and theopenshift-*namespaces must never be selected by a primary network - a namespace can only have one primary network; namespaces that only consume a secondary network do not need the label
ClusterUserDefinedNetworkandUserDefinedNetworkresources are immutable: delete and recreate them to change a network- the network subnets must not overlap the cluster network, the service network, the join subnet (
100.64.0.0/16,100.65.0.0/16) and the masquerade subnet (169.254.0.0/17) of the cluster - the namespace and the network must exist before the pods: a pod created in a labelled namespace stays pending until its primary network is created
Localnetis only available withClusterUserDefinedNetwork, with theSecondaryrole only
Deploy this helm chart on openshift
1. Connect to your Openshift cluster
oc login -t <token> <cluster-url>
2. Install the repository
helm repo add startx https://helm-repository.readthedocs.io/en/latest/repos/stable/
3. Get information about this chart
helm show chart startx/cluster-cudn
4. Install this chart
Default values
The default values keep every feature disabled and render nothing: the networks and namespaces are cluster-specific and must be provided in a values file.
# base configuration running default configuration
helm install cluster-cudn startx/cluster-cudn
Full deployment with tenant namespaces and networks
Create a values file describing the namespaces and the networks of your cluster, then enable the features:
namespaces:
enabled: true
list:
- name: demo-cudn-blue
display_name: "Demo blue tenant"
labels:
app.startx.fr/network: blue
clusterNetworks:
enabled: true
list:
# Layer2 primary network with persistent IP addresses (virtual machines live migration)
- name: blue-layer2
namespaceSelector:
matchLabels:
app.startx.fr/network: blue
network:
topology: Layer2
layer2:
role: Primary
subnets:
- 10.200.0.0/16
ipam:
lifecycle: Persistent
# Localnet secondary network bridged to the physical VLAN 100 (needs a NNCP bridge mapping named localnet-datacenter)
- name: datacenter-vlan100
namespaceSelector:
matchLabels:
app.startx.fr/network: datacenter
network:
topology: Localnet
localnet:
role: Secondary
physicalNetworkName: localnet-datacenter
vlan:
mode: Access
access:
id: 100
subnets:
- 192.168.100.0/24
excludeSubnets:
- 192.168.100.0/26
ipam:
lifecycle: Persistent
mtu: 1500
helm install cluster-cudn startx/cluster-cudn -f my-networks.yaml
The NodeNetworkConfigurationPolicy required by the Localnet example above can be deployed with the cluster-nmstate chart:
nncp:
enabled: true
name: ovs-br1-datacenter
nodeSelector:
node-role.kubernetes.io/worker: ""
desiredState: |
interfaces:
- name: ovs-br1
type: ovs-bridge
state: up
bridge:
allow-extra-patch-ports: true
options:
stp: false
port:
- name: eth1
ovn:
bridge-mappings:
- localnet: localnet-datacenter
bridge: ovs-br1
state: present
Other available values
- startx : STARTX demo tenants (
startx-cudn-blueon a Layer2 primary cluster network,startx-cudn-greenon a Layer3 namespaced network), see values-startx.yaml - startx_noinfra : same content, used by the ArgoCD examples, see values-startx_noinfra.yaml
helm install cluster-cudn startx/cluster-cudn -f https://raw.githubusercontent.com/startxfr/helm-repository/master/charts/cluster-cudn/values-startx.yaml \
--set namespaces.enabled=true \
--set clusterNetworks.enabled=true \
--set networks.enabled=true
Values files
Example values files shipped with the chart, to use with helm install -f <file> :
- startx : STARTX cluster configuration, see values.yaml for the parameters (see values-startx.yaml)
- startx_noinfra : STARTX cluster configuration, see values.yaml for the parameters (see values-startx_noinfra.yaml)
examples/argocd/: 4 example manifest(s) (see the ArgoCD or usage sections)
helm install cluster-cudn startx/cluster-cudn -f https://raw.githubusercontent.com/startxfr/helm-repository/master/charts/cluster-cudn/values-startx.yaml
Deploy with ArgoCD
Deploy via ArgoCD Application
Deploy cluster-cudn using two dedicated ArgoCD Applications - one per concern - sharing the same AppProject (there is no
operator Application because the user-defined network APIs are built into OpenShift):
cluster-cudn-project(sync-wave1) creates thedefault-cudnproject with theprojectsub-chartcluster-cudn-app(sync-wave10) creates the tenant namespaces, theClusterUserDefinedNetworkand theUserDefinedNetworkresources
git clone https://gitlab.com/startx1/helm.git
cd helm-repository/charts/cluster-cudn/examples/argocd/
oc apply -k .
The automated sync policy ensures ArgoCD reconciles each concern independently whenever the chart or values drift from the desired state.
The cluster-cudn-app Application must not use the CreateNamespace=true sync option: the tenant namespaces have to be created
by the chart templates so that they carry the k8s.ovn.org/primary-user-defined-network label from the start. The AppProject
whitelists the cluster-scoped kinds created by the chart (Namespace and ClusterUserDefinedNetwork) and the Application ignores
the k8s.ovn.org/user-defined-network-protection finalizer added by OVN-Kubernetes on every network.
Values dictionary
context values dictionary
| Key | Default | Description |
|---|---|---|
| context.scope | myscope | Name of the global scope for this application |
| context.cluster | default | Name of the cluster running this application |
| context.environment | myenv | Name of the environment (dev, factory, preprod, prod) |
| context.component | mycomponent | Component name of this application |
| context.app | default-cudn | Application name |
| context.version | 4.22.0 | Version name of this application |
namespaces values dictionary
| Key | Default | Description |
|---|---|---|
| namespaces.enabled | false | Enable the creation of the namespaces attached to a primary user-defined network |
| namespaces.list | [] | List of namespaces to create (sync-wave -10, kept on uninstall) |
| namespaces.list[].name | Name of the namespace (never default or openshift-*) | |
| namespaces.list[].display_name | name | Display name of the namespace (openshift.io/display-name annotation) |
| namespaces.list[].description | Description of the namespace (openshift.io/description annotation) | |
| namespaces.list[].labels | {} | Additional labels, added to the k8s.ovn.org/primary-user-defined-network label |
| namespaces.list[].primary | true | Set the k8s.ovn.org/primary-user-defined-network label (false: secondary networks only) |
clusterNetworks values dictionary
| Key | Default | Description |
|---|---|---|
| clusterNetworks.enabled | false | Enable the creation of the ClusterUserDefinedNetwork resources |
| clusterNetworks.list | [] | List of ClusterUserDefinedNetwork resources (sync-wave 15) |
| clusterNetworks.list[].name | Name of the cluster-scoped network | |
| clusterNetworks.list[].labels | {} | Additional labels set on the resource |
| clusterNetworks.list[].namespaceSelector | Label selector of the attached namespaces (spec.namespaceSelector, rendered as is, required) | |
| clusterNetworks.list[].network | Network definition (spec.network, rendered as is, required) | |
| ...network.topology | Layer2 (one switch for all nodes), Layer3 (one subnet per node) or Localnet (physical) | |
| ...network.layer2.role | Primary (replaces the pod network) or Secondary (attached on demand) | |
| ...network.layer2.subnets | Pod subnets (one IPv4 and/or one IPv6 CIDR) | |
| ...network.layer2.ipam.lifecycle | Persistent keeps the IP addresses of virtual machines across restarts and live migrations | |
| ...network.layer2.ipam.mode | Enabled (default) or Disabled (secondary networks only, no IP assigned by OVN-Kubernetes) | |
| ...network.layer2.mtu | Maximum |
Deploy cluster-cudn with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has cluster-cudn on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartcluster-cudn is pinned at v21.3.412 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply