Kubernetes echo pod from different external IP

10/7/2020

I have k8s cluster with 3 nodes, each node run 4 pods.

I want that each pod get different external IP, How it possible to do that with K8s/docker?

-- yaakov yaakov
docker
kubernetes

3 Answers

10/7/2020

To expose your application to the outside world, You need to create a service & it will provide you an external IP address.

This Service can be applied to one or more pods. If you apply to more pods then service will randomly select any pod to satisfy your request.

Your case:

You want external IP for each pod then, create service for each pod. 4 pod requires 4 IP and that's why it requires 4 services.

On creating a successful service, you get this output, Display information about the Service:

kubectl get services my-service

The output is similar to this:

NAME         TYPE           CLUSTER-IP     EXTERNAL-IP      PORT(S)    AGE
 my-service   LoadBalancer   10.3.245.137   104.198.205.71   8080/TCP   54s

you should see 4 services with 4 external IP addresses here.

Learn from official Kubernetes website how to create service.

-- Vamp thehacker
Source: StackOverflow

10/7/2020

You cannot assign external IP to the node.

what you can do:

  1. Create 4 deployment with 1 replica or deploy 4 pods with different labels
  2. Create 4 service to that 4 deployment or 4 specific labels above with specific external IP you desired.

Docs: external IP, deployment

-- Duy Tran
Source: StackOverflow

10/7/2020

You can't assign external IP to pod.

In order to expose your application outside of your cluster through an external IP, you need to create a service.

You can have an example here in the official doc.
Also you might want to read some documentation about services.

-- Marc ABOUCHACRA
Source: StackOverflow