Integrate with Container Storage Interface (CSI)
Prerequisites
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 a VPC or Subnet yet, please create a VPC or 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 create an SSH key according to the instructions here .
Installed and configured kubectl on your device. Please refer here if you are not sure how to install and use kuberctl. In addition, you should not use a kubectl version that is too old, we recommend that you use a kubectl version that is no more than one version different from the cluster version.
Initialize Cluster
A cluster in Kubernetes is a collection of one or more virtual machines (VMs) connected together to run containerized applications. Cluster provides a unified environment to deploy, manage, and operate containers at scale.
To initialize a Cluster, follow the steps below:
Step 1: Visit https://vks.console.vngcloud.vn/overview
Step 2: At the Overview screen , select Activate.
Step 3: Wait until we successfully create your VKS account. After Activate successfully, select Create a Cluster
Step 4: At the Cluster initialization screen, we have set up information for the Cluster and a Default Node Group for you. You can keep these default values or adjust the desired parameters for the Cluster and Node Group at Cluster Configuration, Default Node Group Configuration, Plugin. When you choose to enable the Enable vLB Native Integration Driver option , by default we will pre-install this plugin into your Cluster.
Step 5: Select Create Kubernetes cluster. Please wait a few minutes for us to initialize your Cluster, the Cluster's status 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 .
Connect and check the newly created Cluster information
After the Cluster is successfully initialized, you can connect and check the newly created Cluster information by following these steps:
Step 1: Visit https://vks.console.vngcloud.vn/k8s-cluster
Step 2: The Cluster list is displayed, 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 directory
Step 4: Perform Cluster check via command:
Run the following command to test node
If the results are returned as below, it means your Cluster was successfully initialized with 3 nodes as below.
Create Service Account and install VNGCloud BlockStorage CSI Driver
Attention:
When you initialize the Cluster according to the instructions above, if you have not enabled the Enable BlockStore Persistent Disk CSI Driver option , by default we will not pre-install this plugin into your Cluster. You need to manually create Service Account and install VNGCloud BlockStorage CSI Driver according to the instructions below. If you have enabled the Enable BlockStore Persistent Disk CSI Driver option , we have pre-installed this plugin into your Cluster, skip the Service Account Initialization step, install VNGCloud BlockStorage CSI Driver and continue following the instructions from now on. Deploy a Workload.
VNGCloud BlockStorage CSI Driver only supports attaching volumes to a single node (VM) throughout the life of that volume. If you have a need for ReadWriteMany, you may consider using the NFS CSI Driver, as it allows multiple nodes to Read and Write on the same volume at the same time. This is very useful for applications that need to share data between multiple pods or services in Kubernetes.
Deploy a Workload
The following is a guide for you to deploy the nginx service on Kubernetes.
Step 1 : Create Deployment for Nginx app.
Create nginx-service.yaml file with the following content:
Deploy This deployment equals:
Step 2: Check the Deployment and Service information just deployed
Run the following command to test Deployment
If the results are returned as below, it means you have deployed Deployment successfully.
Create Persistent Volume
Create a persistent-volume.yaml file with the following content:
Run the following command to deploy Ingress
At this time, the vServer system will automatically create a Volume corresponding to the yaml file above, for example:
Create Snapshots
Snapshot is a low-cost, convenient and effective data backup method and can be used to create images, restore data and distribute copies of data. If you are a new user who has never used the Snapshot service, you will need to Activate Snapshot Service before you can create a Snapshot for your Persistent Volume.
Activate Snapshot Service
To be able to create Snapshots, you need to perform Activate Snapshot Service. You will not be charged for activating the snapshot service. After you create snapshots, costs will be calculated based on the storage capacity and storage time of these snapshots. Follow these steps to enable the Snapshot service:
Step 1: Visit https://hcm-3.console.vngcloud.vn/vserver/block-store/snapshot/overview
Step 2: Select Activate Snapshot Service .
For example:
Install VNGCloud Snapshot Controller
Install Helm version 3.0 or higher. Refer to https://helm.sh/docs/intro/install/ for instructions on how to install.
Add this repo to your cluster via the command:
Continue running:
After the installation is complete, check the status of vngcloud-blockstorage-csi-driver pods:
For example, in the image below you have successfully installed vngcloud-controller-manager:
Create a snapshot.yaml file with the following content:
Run the following command to deploy Ingress
Check the newly created PVC and Snapshot
After applying the file successfully, you can check the service and pvc list via:
Change the IOPS parameters of the newly created Persistent Volume
To change the IOPS parameters of the newly created Persistent Volume, follow these steps:
Step 1: Run the command below to list the PVCs in your Cluster
Step 2: Edit the PVC YAML file according to the command
If you have not edited the IOPS of the Persistent Volume before, when you run the above command, add an annotation bs.csi.vngcloud.vn/volume-type: "volume-type-id" . For example, below I am changing the Persistent Volume IOPS from 200 (Volume type id = vtype-61c3fc5b-f4e9-45b4-8957-8aa7b6029018) to 1000 (Volume type id = vtype-85b39362-a360-4bbb-9afa-a36a40cea748 )
If you have edited the IOPS of the Persistent Volume before, when you run the above command, your yaml file will already have the annotation bs.csi.vngcloud.vn/volume-type: "volume-type-id" . Now, edit this annotation to the Volume type id with the IOPS you desire.
Change the Disk Volume of the newly created Persistent Volume
To change the Disk Volume of the newly created Persistent Volume, run the following command:
For example, initially the PVC created was 20 Gi in size, now I will increase it to 30 Gi
Attention:
You can only increase Disk Volume but cannot reduce Disk Volume size.
Restore Persistent Volume from Snapshot
To restore Persistent Volume from Snapshot, follow these steps:
Create file restore-volume.yaml with the following content:
Last updated