Offload Reconciliation of NLB to LBC Using loadBalancerClass¶
In this demo, we will use spec.loadBalancerClass
to offload the reconciliation of Network Load Balancer (NLB) to AWS Load Balancer Controller (LBC).
Note
If you configure spec.loadBalancerClass
, the service.beta.kubernetes.io/aws-load-balancer-nlb-target-type
defaults to instance
.
Docker Images¶
Here is the Docker Image used in this tutorial: reyanshkharga/nodeapp:v1
Note
reyanshkharga/nodeapp:v1 runs on port 5000
and has the following routes:
GET /
Returns host info and app versionGET /health
Returns health status of the appGET /random
Returns a randomly generated number between 1 and 10
Step 1: Create a Deployment¶
First, let's create a deployment as follows:
Apply the manifest to create the deployment:
Verify deployment and pods:
Step 2: Create a Service¶
Now, let's create a LoadBalancer
service but this time we'll offload the reconciliation of NLB to LBC using .spec.loadBalancerClass
field.
Note
The service.beta.kubernetes.io/aws-load-balancer-nlb-target-type
annotation is optional and defaults to instance
when you use the .spec.loadBalancerClass
field to offload the reconciliation of NLB to LBC.
Also, to create an internet-facing NLB, the following annotation is required on your service:
Apply the manifest to create the service:
Verify service:
Step 3: Verify the Network Load Balancer (NLB) in AWS Console¶
Visit AWS Console and verify that a network load balancer (NLB) was created.
Also, verify that the NLB was created by AWS Load Balancer Controller
. You can check the events in the logs as follows:
kubectl logs -f deploy/aws-load-balancer-controller -n aws-load-balancer-controller --all-containers=true
Step 4: Access App Via Network Load Balancer DNS¶
Once the load balancer is in Active
state, you can hit the load balancer DNS and verify if everything is working properly.
Access the load balancer DNS by entering it in your browser. You can get the load balancer DNS either from the AWS console or the service configuration.
Try accessing the following paths:
Clean Up¶
Assuming your folder structure looks like the one below:
Let's delete all the resources we created: