When I already have pods deployed to my nodes, do I need to recreate them to make updates to or implement a new service?

9/1/2020

I'm using Azure Kubernetes Services and was wondering if creating a new load balancing service would require me to re-create my deployments. I've been experimenting a bit, but I can't tell if the responses from the service were just delayed because of startup time and I'm impatient, or if the loadbalancer doesn't create endpoints for existing deployments (which seems weird to me)

-- Carson
azure-aks
kubernetes

1 Answer

9/1/2020

You don't need to redeploy the application if you just want to expose the service. A service can be exposed as a load balancer or other types. When you create a service of type LoadBalancer, the cloud controllers in AKS will create the Load Balancer Azure resource and setup the backend configuration based on the existing endpoints. Azure load balancer provisioning may take some time and you can check the status with kubectl get svc. If the status of the External-IP is pending that means it's being created. The load balancer is created in a few minutes. If it takes longer, you may have to see if there are any permissions or other configuration issuees.

$ kubectl create deploy nginx --image=nginx
deployment.apps/nginx created

$ kubectl expose deploy/nginx --port 80 --type LoadBalancer
service/nginx exposed


$ kubectl get svc nginx
NAME    TYPE           CLUSTER-IP    EXTERNAL-IP   PORT(S)        AGE
nginx   LoadBalancer   10.96.28.31   <pending>     80:30643/TCP   63s

$ kubectl get svc nginx
NAME    TYPE           CLUSTER-IP    EXTERNAL-IP     PORT(S)        AGE
nginx   LoadBalancer   10.0.13.232   52.nnn.nnn.nn   80:31540/TCP   111s
-- Faheem
Source: StackOverflow