Home > OS >  Azure Kubernetes Load Balancer not working
Azure Kubernetes Load Balancer not working

Time:05-31

Deploy NGINX demo containers and setup loadbalancer on Azure, the page cannot be loaded. I think it is some problem on NSG, can someone please tell me whats wrong.

kubectl run hello-app --image=nginxdemos/hello --port=80
kubectl expose pod hello-app --type="LoadBalancer"

Verify service is running, and check external IP.

kubectl get svc hello-app
NAME        TYPE           CLUSTER-IP    EXTERNAL-IP    PORT(S)        AGE
hello-app   LoadBalancer   10.0.214.81   20.25.212.62   80:31162/TCP   16m

Open Browser and visit website, the page does not load.

curl http://20.25.212.62:31162

Server and client version

kubectl version
Client Version: v1.24.0
Kustomize Version: v4.5.4
Server Version: v1.22.6

Azure AKS Deployment Script

https://github.com/scout249/k8s-learn/blob/main/azure-k8s.sh

CodePudding user response:

You are accessing the wrong port.

If you create the Kubernetes service type LoadBalancer By default it will expose with Node port and create the Load balancer in Azure and add the all Kubernetes worker nodes as targets

If you send any request to Load balaner , In background it will send request to any one of the node with node port.

For Example if you have two nodes in cluster

node1, node2

curl loadbalaner-ip:80 -> node1:nodeport or node2:nodeport

Run the below command

curl http://20.25.212.62

or

curl http://20.25.212.62:80
  • Related