kubernetes give public ip to many replicas

7/3/2018

I have a multiplayer application consisting of many containers and at the top level i have a REST API. I managed to run this application and i can access the rest api using the public ip. I am using the google cloud kubernetes engine. I would like to make many replicas of this multilayer application that each one should have a public ip so as to be able to communicate. Is it possible to have many public ips (not loadbalancer) each one pointing to a replica?

-- Anargyros Tsadimas
google-compute-engine
kubernetes

1 Answer

7/3/2018

You should use statefulsets. Then create as many load balancer services equal to your number of replicas. Use the custom labels that are added to the statefulset pods by default for selecting one service for one pod (see here). This will serve your purpose.

Also you can use external-dns.alpha.kubernetes.io/hostname in the annotations for your services to provide your own public dns for each of the pods.

-- Akash
Source: StackOverflow