Using CNI Calico Overlay

Overview

The CNI Calico Overlay in VKS is a type of overlay network that uses IP-in-IP encapsulation to create an overlay network. This allows pods to communicate with each other without changing the underlying physical network configuration. Pods will receive IP addresses from the IP address range configured for Calico, which is usually different from the IP address of your VPC or subnet.


Model

On VKS, Calico Overlay works according to the following model:

In there:

  • Pods on each node communicate with each other via the cali interface and bridge cni0 .

  • When pods need to communicate with pods on other nodes, packets are encapsulated into overlay packets and sent over the physical network (VPC Network) .

  • Calico on each node is responsible for performing encapsulation and decapsulation so that pods can communicate across different nodes.


Necessary conditions

To be able to initialize a Cluster and Deploy a Workload , you need:

  • There is at least 1 VPC and 1 Subnet in ACTIVE state . If you do not have any VPC, Subnet, please initialize VPC, Subnet according to the instructions here .

  • There is at least 1 SSH key in ACTIVE state . If you do not have any SSH key, please initialize SSH key following the instructions here .

  • kubectl installed and configured on your device. please refer here if you are not sure how to install and use kuberctl. In addition, you should not use an outdated version of kubectl, we recommend that you use a kubectl version that is no more than one version different from the cluster version.


Create a Cluster using Calico Overlay

To initialize a Cluster, follow the steps below:

Step 1: Access https://vks.console.vngcloud.vn/overview

Step 2: On the Overview screen , select Activate.

Step 3: Wait until we successfully initialize your VKS account. After successfully Activating, select Create a Cluster.

Step 4: At the Cluster initialization screen, we have set up the information for the Cluster and a Default Node Group for you. To use Calico Overlay for your Cluster , please select:

  • Network type : Calico Overlay

Field

Meaning

Illustrative example

VPC

The IP address range that the Cluster nodes will use to communicate.

In the picture, we choose VPC with IP range 10.111.0.0/16 , corresponding to 65536 IPs

Subnet

A smaller IP address range belonging to the VPC. Each node in the Cluster will be assigned an IP from this Subnet. The Subnet must be within the IP range of the selected VPC.

In the picture, we choose Subnet with Primary IP range of 10.111.0.0/24 , corresponding to 256 IPs

IP-IP encapsulation mode

IP-IP encapsulation mode in VKS is Always

In the figure, we select Always mode to always encapsulate packets.

CIDR

The virtual network range that the pods will use

In the picture, we choose the virtual network range as 172.16.0.0/16. The pods will get IP from this IP range.

Attention:

  • Only one networktype: In a cluster, you can use only one of three networktypes: Calico Overlay, Cilium Overlay, or Cilium VPC Native Routing

  • Multiple subnets for a cluster: VKS supports the use of multiple subnets for a cluster. This allows you to configure each node group in the cluster to be located on different subnets within the same VPC, helping to optimize resource allocation and network management.

Step 5: Select Create Kubernetes cluster. Please wait a few minutes for us to initialize your Cluster, the status of the Cluster is now Creating .

Step 6: When the Cluster status is Active , you can view Cluster information and Node Group information by selecting Cluster Name in the Name column .


Deploy a Workload

Below are instructions for deploying an nginx deployment and testing IP assignment for the pods deployed in your cluster.

Step 1: Access https://vks.console.vngcloud.vn/k8s-cluster

Step 2: The Cluster list is displayed, select the Download icon and select Download Config File to download the kubeconfig file. This file will give you full access to your Cluster.

Step 3 : Rename this file to config and save it to the ~/.kube/config folder

Step 4: Perform Cluster check via command:

  • Run the following command to check the node

  • If the result is as below, it means your Cluster is successfully initialized with 5 nodes:

  • Continue running the following command to check the pods deployed on your kube-system namespace:

  • If the result is as below, it means that the pods supporting Calico Overlay have been successfully run:

Step 2: Deploy nginx on the newly created cluster:

  • Initialize the nginx-deployment.yaml file with the following content:

  • Perform this deployment via command:

Step 3: Check the deployed nginx pods and the IP address assigned to each pod

  • Perform a check of the pods via the command:

  • You can observe below, the nginx pods are assigned IPs 172.16.xx which satisfy the Calico CIDR condition 172.16.0.0/16 that we specified above:

  • You can also perform a detailed description of each pod to check this pod information via the command:

Last updated