ON THIS PAGE
L2 Pod with Kernel Interface (Access Mode)
SUMMARY Read this topic to learn how to add a user pod with a kernel/veth
access-mode interface to an instance of the cloud-native router.
Overview
You can configure a user pod with a Layer 2 access-mode kernel
interface and attach it to the JCNR instance. The Juniper Cloud-Native Router must
have an L2 interface configured at the time of deployment. Your high-level tasks
are:
-
Define and apply a network attachment definition (NAD)—The NAD file defines the required configuration for Multus to invoke the JCNR-CNI and create a network to attach the pod interface to.
-
Define and apply a pod YAML file to your cloud-native router cluster—The pod YAML contains the pod specifications and an annotation to the network created by the JCNR-CNI.
Note:Please review the JCNR Use-Cases and Configuration Overview topic for more information on NAD and pod YAML files.
Configuration Example
- Here is an example NAD to create a Layer 2
kernel/veth
access-mode interface with static IPAM:apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: vswitch-pod1-bd100 spec: config: '{ "cniVersion":"0.4.0", "name": "vswitch-pod1-bd100", "plugins": [ { "type": "jcnr", "args": { "instanceName": "vswitch", "instanceType": "virtual-switch", "interfaceType": "veth", "bridgeDomain": "bd100", "bridgeVlanId": "100" }, "ipam": { "type": "static", "addresses":[ { "address":"99.61.0.2/16", "gateway":"99.61.0.1" }, { "address":"1234::99.61.0.2/120", "gateway":"1234::99.61.0.1" } ] }, "kubeConfig":"/etc/kubernetes/kubelet.conf" } ] }'
The NAD defines a bridge domain
It also defines a static IP address to be assigned to the pod interface.bd100
under which aveth
type pod interface should be attached in thevirtual-switch
instance. - Apply the NAD manifest to create the network.
kubectl apply -f nad-access_mode.yaml networkattachmentdefinition.k8s.cni.cncf.io/vswitch-pod1-bd100 created
- Verify the NAD is created.
[root@jcnr-01]# kubectl get net-attach-def NAME AGE vswitch-pod1-bd100 59s
- Here is an example yaml to create a pod attached to the
vswitch-pod1-bd100
network:apiVersion: v1 kind: Pod metadata: name: pod1 annotations: k8s.v1.cni.cncf.io/networks: vswitch-pod1-bd100 spec: containers: - name: pod1 image: ubuntu:latest imagePullPolicy: IfNotPresent securityContext: privileged: false env: - name: KUBERNETES_POD_UID valueFrom: fieldRef: fieldPath: metadata.uid volumeMounts: - name: dpdk mountPath: /dpdk subPathExpr: $(KUBERNETES_POD_UID) volumes: - name: dpdk hostPath: path: /var/run/jcnr/containers
The pod attaches to the router instance using the
.k8s.v1.cni.cncf.io/networks
annotation - Apply the pod manifest.
[root@jcnr-01]# kubectl apply -f pod_access_mode.yaml pod/pod1 created
- Verify the pod is running.
[root@jcnr-01 ~]# kubectl get pods NAME READY STATUS RESTARTS AGE pod1 1/1 Running 0 2m38s
- Describe the pod to verify a secondary interface is created and attached to the
vswitch-pod1-bd100
network. (The output is trimmed for brevity).[root@jcnr-01 ~]# kubectl describe pod pod1 Name: pod1 Namespace: default Priority: 0 Node: jcnr-01/10.100.20.25 Start Time: Mon, 26 Jun 2023 09:36:57 -0400 Labels: <none> Annotations: cni.projectcalico.org/containerID: 5b92668a6d7580e587de951d660c99969ce98bc239502afab6f9d191653f1e9b cni.projectcalico.org/podIP: 10.233.91.79/32 cni.projectcalico.org/podIPs: 10.233.91.79/32 k8s.v1.cni.cncf.io/network-status: [{ "name": "k8s-pod-network", "ips": [ "10.233.91.79" ], "default": true, "dns": {} },{ "name": "default/vswitch-pod1-bd100", "interface": "net1", "ips": [ "99.61.0.2", "1234::633d:2" ], "mac": "02:00:00:5D:74:76", "dns": {} }] ...
- Verify the vRouter has the corresponding interface created. Access the vRouter CLI
and issue the
vif --list
command. Note that the interface type isvif0/2 Ethernet: jvknet1-7c557fe MTU: 9160 Type:Virtual HWaddr:02:00:00:66:01:56 DDP: OFF SwLB: ON Vrf:0 Flags:L2Vof QOS:-1 Ref:8 RX port packets:20 errors:0 RX queue errors to lcore 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Vlan Mode: Access Vlan Id: 100 OVlan Id: 100 RX packets:7 bytes:518 errors:13 TX packets:31 bytes:2438 errors:0 Drops:14 TX port packets:31 errors:0
Virtual
and the Vlan mode is set toaccess
with the Vlan ID set to100
. The VRF is always 0 for L2 interfaces.