Integrate with Network Load Balancer
To integrate a Network Load Balancer with a Kubernetes cluster, you can use a Service with type LoadBalancer . When you create such a Service, VNGCloud LoadBalancer Controller will automatically create an NLB to forward traffic to pods on your node . You can also use annotations to customize Network Load Balancer properties, such as port, protocol,...
Prepare
Create a Kubernetes cluster on VNGCloud, or use an existing cluster. Note: make sure you have downloaded the cluster configuration file once the cluster has been successfully initialized and accessed your cluster.
Create or use a service account created on IAM and attach policy: vLBFullAccess , vServerFullAccess . To create a service account, go here and follow these steps:
Select " Create a Service Account ", enter a name for the Service Account and click Next Step to assign permissions to the Service Account
Find and select Policy: vLBFullAccess and Policy: vServerFullAccess , then click " Create a Service Account " to create Service Account, Policy: vLBFullAccess and Policy: vServerFullAccess created by VNG Cloud, you cannot delete these policies.
After successful creation, you need to save the Client_ID and Secret_Key of the Service Account to perform the next step.
Create Service Account and install VNGCloud LoadBalancer Controller
Deploy a Workload
1.If you do not have a previously initialized Network Load Balancer available on the vLB system.
At this point, you need to do:
Step 1 : Create Deployment, Service for Nginx app.
Create nginx-service-lb4.yaml file with the following content:
Or use the following script file to deploy HTTP Apache Service with Internal LoadBalancer allowing internal access on port 8080:
Or sample YAML file to create Deployment and Service for a UDP server application in a Kubernetes cluster:
2.If you already have a previously initialized Network Load Balancer on the vLB system and you want to reuse the NLB for your cluster.
At this point, please enter the Load Balancer ID information into the vks.vngcloud.vn/load-balancer-id annotation. The example below is a sample YAML file to deploy Nginx with External LoadBalancer using vngcloud-controller-manager to automatically expose the service to the internet using an L4 load balancer using an available NLB with ID = lb-2b9d8974- 3760-4d60-8203-9671f229fb96
3.Once a new NLB has been automatically created by us , you can now proceed
Edit your NLB configuration according to the specific instructions at Configure for a Network Load Balancer . For example below, I have edited the protocol and port as follows:
Like other Kubernetes resources, vngcloud-controller-manager has a structure including the following information fields:
apiVersion: API version for Ingress.
kind: Resource type, in this case "Service".
metadata: Information describing Ingress, including name, annotations.
spec: Configure the conditions of incoming requests.
For general information about working with vngcloud-controller-manager, see [Configure for a Network Load Balancer]
Deploy this Service using:
Step 2: Check 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.
At this point, the vLB system will automatically create a corresponding LB for the deployed nginx app, for example:

Step 3: To access the just exported nginx app, you can use the URL with the format:
You can get Load Balancer Public Endpoint information at the vLB interface. Specifically, access at https://hcm-3.console.vngcloud.vn/vserver/load-balancer/vlb/
For example, below I have successfully accessed the nginx app with the address: http://180.93.181.20/

Last updated
