Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
Juniper Cloud-Native Router User Guide
Table of Contents Expand all
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

L2 Kernel Access-Mode Interface Configuration Example

Release: JCNR 23.3
{}
Change Release
date_range 27-Nov-24

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 Cloud-Native Router 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 Cloud-Native Router Use-Cases and Configuration Overview topic for more information on NAD and pod YAML files.

Configuration Example

  1. Here is an example NAD to create a Layer 2 kernel/veth access-mode interface with static IPAM:
    content_copy zoom_out_map
    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 bd100 under which a veth type pod interface should be attached in the virtual-switch instance.

    It also defines a static IP address to be assigned to the pod interface.
  2. Apply the NAD manifest to create the network.
    content_copy zoom_out_map
    kubectl apply -f nad-access_mode.yaml
    networkattachmentdefinition.k8s.cni.cncf.io/vswitch-pod1-bd100 created
  3. Verify the NAD is created.
    content_copy zoom_out_map
    [root@jcnr-01]# kubectl get net-attach-def
    NAME                 AGE
    vswitch-pod1-bd100   59s
  4. Here is an example yaml to create a pod attached to the vswitch-pod1-bd100 network:
    content_copy zoom_out_map
    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

    .
  5. Apply the pod manifest.
    content_copy zoom_out_map
    [root@jcnr-01]# kubectl apply -f pod_access_mode.yaml 
    pod/pod1 created
  6. Verify the pod is running.
    content_copy zoom_out_map
    [root@jcnr-01 ~]# kubectl get pods 
    NAME   READY   STATUS    RESTARTS   AGE
    pod1   1/1     Running   0          2m38s
  7. Describe the pod to verify a secondary interface is created and attached to the vswitch-pod1-bd100 network. (The output is trimmed for brevity).
    content_copy zoom_out_map
    [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": {}
                    }]
    ...
  8. Verify the vRouter has the corresponding interface created. Access the vRouter CLI and issue the vif --list command.
    content_copy zoom_out_map
    vif0/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
    Note that the interface type is Virtual and the Vlan mode is set to access with the Vlan ID set to 100. The VRF is always 0 for L2 interfaces.
footer-navigation