Kubernetes on Azure: assign different external IP to different services Kubernetes on Azure: assign different external IP to different services kubernetes kubernetes

Kubernetes on Azure: assign different external IP to different services


In Azure container service, to expose a kubernetes service to Internet, we should use Azure Load balancer. As Radek said, several containers in one pod, and use the same load balancer to keep HA.

If you want to expose several containers to Internet with different Public IP addresses, we can create several pods, and expose them to Internet, in this way, containers with different public IP addresses.

The relationship about pod, containers and node, like this:enter image description here

We create several containers in one pod, several pods in one node(host), several pods work for one service. A service works as a cluster, one service with one public IP address.

So, if you want to create several nginx containers with different public IP addresses, we can create several services to archive this:

Create one or two nginx containers in one service, and expose several services to Internet.

root@k8s-master-7273A780-0:~# kubectl run jasonnginx --replicas=1 --image nginxroot@k8s-master-7273A780-0:~# kuberctl run mynginx --replicas=2 --image nginxroot@k8s-master-7273A780-0:~# kubectl expose deployments mynginx --port=80 --type=LoadBalancerroot@k8s-master-7273A780-0:~# kubectl expose deployments jasonnginx --port=80 --type=LoadBalancerroot@k8s-master-7273A780-0:~# kubectl get svcNAME         CLUSTER-IP     EXTERNAL-IP     PORT(S)        AGEjasonnginx   10.0.114.116   52.168.176.18   80:30153/TCP   5mkubernetes   10.0.0.1       <none>          443/TCP        15mmynginx      10.0.205.127   13.82.102.171   80:31906/TCP   6mroot@k8s-master-7273A780-0:~# kubectl get podsNAME                          READY     STATUS    RESTARTS   AGEjasonnginx-1417538491-v79mw   1/1       Running   0          20mmynginx-1396894033-78njj      1/1       Running   0          21mmynginx-1396894033-pmhjh      1/1       Running   0          21m

We can find the Load balancer frontend IP settings(two public IP addresses) via Azure portal:enter image description here


Looking at your linked Azure docs, it does not seem like it really differs from it should do on any cloud. I think you miss understood how it is supposed to be used.

When you create a service of any type, it is intended to provide service that does not differ. If it's pointing to multiple endpoints, it does that to LoadBalance traffic and provide HA. There is zero reason for this to be exposed externally on an IP per endpoint basis.

But, if you need to expose different services on different IPs, you just create both services as LoadBalancer service type, and every svc should receive its unique external load balancer (thus IP).

The behaviour you described (one loadbalancer, multiple services exposed externally) sounds much closer to what you can accomplish with Ingress/IngressController.