Lab: localnet su VLAN
Procedura di riferimento per mettere un pod su una VLAN fisica (es. VLAN 100, subnet 192.168.100.0/24). Richiede una VLAN reale taggata sulla NIC dei nodi.
1. Bridge + bridge-mapping (NMState)
Sezione intitolata “1. Bridge + bridge-mapping (NMState)”cat <<'YAML' | oc apply -f -apiVersion: nmstate.io/v1kind: NodeNetworkConfigurationPolicymetadata: name: br-vlan100spec: nodeSelector: { node-role.kubernetes.io/worker: "" } desiredState: interfaces: - name: br-vlan100 type: ovs-bridge state: up bridge: { port: [{ name: ens192 }] } ovn: bridge-mappings: - { localnet: vlan100, bridge: br-vlan100, state: present }YAMLoc get nnce2. NAD localnet
Sezione intitolata “2. NAD localnet”cat <<'YAML' | oc apply -f -apiVersion: k8s.cni.cncf.io/v1kind: NetworkAttachmentDefinitionmetadata: { name: vlan100, namespace: net-lab }spec: config: | { "cniVersion": "0.4.0", "name": "vlan100", "type": "ovn-k8s-cni-overlay", "topology": "localnet", "netAttachDefName": "net-lab/vlan100", "vlanID": 100, "subnets": "192.168.100.0/24" }YAML3. Pod sulla VLAN
Sezione intitolata “3. Pod sulla VLAN”cat <<'YAML' | oc apply -f -apiVersion: v1kind: Podmetadata: name: on-vlan namespace: net-lab annotations: k8s.v1.cni.cncf.io/networks: vlan100spec: containers: - name: c image: registry.access.redhat.com/ubi9/ubi-minimal command: ["sleep","infinity"]YAMLoc -n net-lab exec on-vlan -- ip -br addr# atteso: net1 con IP in 192.168.100.0/24, raggiungibile sulla VLAN fisica4. Pulizia
Sezione intitolata “4. Pulizia”oc delete pod on-vlan -n net-laboc delete net-attach-def vlan100 -n net-laboc delete nncp br-vlan100