Note:

Use OCI VCN-Native Pods Networking CNI Plugin to Provide Networking Services to Oracle Cloud Infrastructure Container Engine for Kubernetes

Introduction

By default, Oracle Cloud Infrastructure Container Engine for Kubernetes (OKE) uses the Oracle Cloud Infrastructure (OCI) VCN-Native Container Network Interface (CNI) plugin to provide network or security features to containerized applications. In this tutorial, we will show you how you can verify what CNI plugin is used and how we can use this default CNI plugin (OCI VCN-Native CNI plugin) to configure an OCI Load Balancer service and attach it to an application running inside a container.

image

The benefit of using the OCI VCN-Native Pods Networking CNI Plugin is that the pods or containers will get an IP address from the private subnet in the VCN. This means that your Kubernetes pods are in the same network as your VMs (instances) or your baremetal nodes or other workloads.

Objectives

Task 1: Deploy a Kubernetes Cluster using OKE

For more information about the different OKE deployment models we can choose, see Example Network Resource Configurations.

The example OKE deployment models are:

We will select Example 3 deployment model. For more information, see Set up Oracle Cloud Infrastructure Container Engine for Kubernetes with Three Worker Nodes.

Task 2: Verify the Installed CNI Plugin

When Kubernetes cluster using OKE is fully deployed and you have access to this, you can run the following command.

  1. Run the following command.

    iwan_hooge@cloudshell:~ (eu-amsterdam-1)$ **kubectl get all -n kube-system** 
    NAME                                      READY   STATUS    RESTARTS     AGE
    pod/coredns-64ffdf5cf7-lvrhq              1/1     Running   0            2d
    pod/coredns-64ffdf5cf7-rmxt8              1/1     Running   0            2d
    pod/coredns-64ffdf5cf7-vq76p              1/1     Running   0            2d
    pod/csi-oci-node-ghff6                    1/1     Running   0            2d
    pod/csi-oci-node-jrjpr                    1/1     Running   0            2d
    pod/csi-oci-node-r68qz                    1/1     Running   1 (2d ago)   2d
    pod/kube-dns-autoscaler-5bb955d5c-r2j2q   1/1     Running   0            2d
    pod/kube-proxy-5cznp                      1/1     Running   0            2d
    pod/kube-proxy-fddrd                      1/1     Running   0            2d
    pod/kube-proxy-sb769                      1/1     Running   0            2d
    pod/proxymux-client-7s7f9                 1/1     Running   0            2d
    pod/proxymux-client-lngrm                 1/1     Running   0            2d
    pod/proxymux-client-qxlf2                 1/1     Running   0            2d
    **pod/vcn-native-ip-cni-hkfjz               1/1     Running   0            2d
    pod/vcn-native-ip-cni-pdv4c               1/1     Running   0            2d
    pod/vcn-native-ip-cni-qfvk8               1/1     Running   0            2d**
    
    NAME               TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                  AGE
    service/kube-dns   ClusterIP   10.96.5.5    <none>        53/UDP,53/TCP,9153/TCP   2d
    
    NAME                                      DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR                                 AGE
    daemonset.apps/csi-oci-node               3         3         3       3            3           <none>                                        2d
    daemonset.apps/kube-proxy                 3         3         3       3            3           beta.kubernetes.io/os=linux                   2d
    daemonset.apps/node-termination-handler   0         0         0       0            0           oci.oraclecloud.com/oke-is-preemptible=true   2d
    daemonset.apps/nvidia-gpu-device-plugin   0         0         0       0            0           <none>                                        2d
    daemonset.apps/proxymux-client            3         3         3       3            3           node.info.ds_proxymux_client=true             2d
    **daemonset.apps/vcn-native-ip-cni          3         3         3       3            3           <none>                                        2d**
    
    NAME                                  READY   UP-TO-DATE   AVAILABLE   AGE
    deployment.apps/coredns               3/3     3            3           2d
    deployment.apps/kube-dns-autoscaler   1/1     1            1           2d
    
    NAME                                            DESIRED   CURRENT   READY   AGE
    replicaset.apps/coredns-64ffdf5cf7              3         3         3       2d
    replicaset.apps/kube-dns-autoscaler-5bb955d5c   1         1         1       2d
    iwan_hooge@cloudshell:~ (eu-amsterdam-1)$ 
    
  2. Notice that the name is vcn-native in the output in the pod section.

  3. Notice that the name is vcn-native in the output in the daemonset section.

image

This will show you that the OCI VCN-Native Pods Networking CNI plugin is currently used for this deployed OKE deployment.

Task 3: Deploy a Sample Application

We will use this sample application together with the OCI VCN-Native Pods Networking CNI plugin and enable the OCI Load Balancer service type in the next task.

  1. Run the following command to deploy a sample Nginx application inside OKE.

    iwan_hooge@cloudshell:~ (eu-amsterdam-1)$ kubectl apply -f https://k8s.io/examples/application/deployment.yaml 
    deployment.apps/nginx-deployment created
    
  2. Run the following command to verify the details of the deployed sample Nginx application.

    iwan_hooge@cloudshell:~ (eu-amsterdam-1)$ kubectl describe deployment nginx-deployment
    Name:                   nginx-deployment
    Namespace:              default
    CreationTimestamp:      Fri, 08 Mar 2024 07:57:02 +0000
    Labels:                 <none>
    Annotations:            deployment.kubernetes.io/revision: 1
    Selector:               app=nginx
    Replicas:               2 desired | 2 updated | 2 total | 2 available | 0 unavailable
    StrategyType:           RollingUpdate
    MinReadySeconds:        0
    RollingUpdateStrategy:  25% max unavailable, 25% max surge
    Pod Template:
      Labels:  app=nginx
      Containers:
       nginx:
        Image:        nginx:1.14.2
        Port:         80/TCP
        Host Port:    0/TCP
        Environment:  <none>
        Mounts:       <none>
      Volumes:        <none>
    Conditions:
      Type           Status  Reason
      ----           ------  ------
      Available      True    MinimumReplicasAvailable
      Progressing    True    NewReplicaSetAvailable
    OldReplicaSets:  <none>
    NewReplicaSet:   nginx-deployment-86dcfdf4c6 (2/2 replicas created)
    Events:
      Type    Reason             Age   From                   Message
      ----    ------             ----  ----                   -------
      Normal  ScalingReplicaSet  14s   deployment-controller  Scaled up replica set nginx-deployment-86dcfdf4c6 to 2
    iwan_hooge@cloudshell:~ (eu-amsterdam-1)$
    
  3. Notice that the application is deployed using two pods.

image

  1. Execute the following command to take a closer look at the deployed pods.

    iwan_hooge@cloudshell:~ (eu-amsterdam-1)$ kubectl get pods
    NAME                                READY   STATUS    RESTARTS   AGE
    nginx-deployment-86dcfdf4c6-fdxgz   1/1     Running   0          3m46s
    nginx-deployment-86dcfdf4c6-fqrkh   1/1     Running   0          3m46s
    iwan_hooge@cloudshell:~ (eu-amsterdam-1)$ 
    
  2. Notice that there are two instances or pods or replicas of the Nginx application and the status is set to RUNNING.

image

A visual representation of the deployment can be found in the following diagram. Focus on the two deployed pods inside the worker nodes.

image

The benefit of using the OCI VCN-Native Pods Networking CNI plugin is that the pods or containers will get an IP address from the private subnet in the VCN. This means that your Kubernetes pods are in the same network as your VMs (instances) or your baremetal nodes or other workloads.

Task 4: Configure Kubernetes Services of Load Balancer Type

We have our sample application running inside OKE, it is time to expose the application to the network or to the internet by attaching a network service of load balancer type to the application.

A visual representation of the load balancer deployment can be found in the following diagram. Focus on the load balancer.

image

Task 5: Remove the Sample application and Kubernetes Services of Load Balancer Type

We have deployed a sample application and created a new Kubernetes network service of load balancer type, it is time to clean up the application and the service.

Notice that there is no load balancer deployed anymore.

image

A visual representation of the load balancer deletion can be found in the following diagram. Focus on the part where the load balancer is no longer deployed.

image

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.