Creating a VLAN with OVS CNI - gpillon/k4all GitHub Wiki

On v2.x the OVS CNI is optional. Turn on OVS secondary networks in Headlamp (k4all > Settings > Features, see Headlamp plugin), or set spec.features.ovsCni.enabled: true in the ClusterConfig. The example uses the ovs-bridge bridge, which nodes have when the OVS bridge is on (spec.features.ovsBridge.enabled, the default, chosen at install).

To configure a VLAN, you first need to create a NetworkAttachmentDefinition that specifies the network details. Here is an example (you can paste directy in the Kubernetes dashboard):

apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
  namespace: default
  name: ovs-net-vlan100
spec:
  config: '{
      "cniVersion": "0.3.1",
      "type": "ovs",
      "bridge": "ovs-bridge",
      "vlan": 100,
      "ipam": {
            "type": "static",
            "addresses": [
                {
                    "address": "192.168.10.42/24",
                    "gateway": "192.168.10.42"
                }]
        }
    }'

Save this YAML as ovs-vlan100.yaml and apply it to your cluster with kubectl apply -f ovs-vlan100.yaml.