0

I am in the process of moving our project from the Compute Engine to GKE autopilot (cost efficiency, scale-up/down).

Currently, in the Compute Engine, each machine gets a different external IP (at no cost, by default, I don't care about reserving IPs, incoming traffic).

I just care that the target/destination the machines requesting data from, will see they are from different IPs

How can I make each Pod come up with a different external IP (as in the GCE)? With no extra/minimal cost? Is it possible?

5
  • Have you checked the documentation related to rotate your control plane IP? Unsure if this will renew pods IP addresses.
    – Pit
    Feb 3, 2022 at 14:39
  • Actually, correct me if I'm wrong but as I dig deeper in k8s, I understand that Pod never will have an external IP, they must have Service (to serve IP to the outer world), But I'm not sure if it's legit to create 1 pod with 1 service, lets say 12, or 15.
    – Emanuel
    Feb 3, 2022 at 21:04
  • Do you really need each pod to appear to come from a different IP? Or is it ok is all pods on a given node come from the same IP?
    – Gari Singh
    Feb 19, 2022 at 11:28
  • I am really need each pod to appear to come from different IP
    – Emanuel
    Feb 20, 2022 at 11:50
  • Ok, so then why exactly do you need them to appear to come from different IPs? Just trying to understand the use case to see if there may be an alternative which still meets the core requirements.
    – Gari Singh
    Mar 10, 2022 at 9:54

1 Answer 1

1

Each Pod has a single IP address assigned from the Pod CIDR range of its node. This IP address is shared by all containers running within the Pod, and connects them to other Pods running in the cluster.Pod IP address is ephemeral(lasts for a very short time) and even External IP Services are not permitted on Autopilot clusters. To give a Service an external IP, you can use a LoadBalancer type of Service or use an Ingress to add the Service to an external IP shared among several services.

Traditionally, HTTP(S) load balancers targeting Kubernetes clusters would actually be targeting its nodes because they didn’t have a way to recognize each pod. But Google came out with a Network Endpoint Group (NEG) abstraction layer that enables container-native load balancing. This means the load balancer has visibility into a Kubernetes cluster’s pods because NEGs are integrated with the Kubernetes Ingress controller running on GCP. If they have a multi-tiered e-commerce deployment and want to expose one service to the internet using GKE. With NEGs they can now provision an HTTP(S) load balancer, allowing them to configure path-based or host-based routing to their backend pods.

There is no charge for ingress traffic. However there may be a charge for load balancer that processes ingress traffic. Refer this documentation for pricing details of Load balancers enter image description here

5
  • Hi, thanks for the details and long answer. I just want to make sure you got my question right, my initial and final purpose is that the destination that the Pods requesting, will think they are different machines from different addresses. Therfore I need that each Pod will have different IP externally (without any care about reserving IPs, incoming requests), I care only about the destination to think they come from different IP addresses. That's why I started with GCE, and thought that GKE can save me cost, but now I'm not sure K8s can offer that kind of a solution.
    – Emanuel
    Feb 7, 2022 at 14:29
  • @SpazaM, yeah I got your question and my solution for that is as there is no provision of external IP address for pods so using load balancer type service which can externally host an IP address and internally forward the request to pods on our routing rules and load balancer is one of the best options to distribute the traffic evenly among the pods. If you directly want to have an external IP of the pod to be used that is not possible . Feb 9, 2022 at 13:47
  • Thanks for the response, I just wanted the Pods to be seen at the destination service, as different IP addresses (when they initiate a request), I guess it's not possible with K8s...
    – Emanuel
    Feb 9, 2022 at 16:28
  • @SpazaM, yes its not possible. Feb 10, 2022 at 10:52
  • 1
    @SpazaM, If the answer was useful, please mark the answer as accepted for greater visibility for community or upvote if the answer has some useful information. Feb 14, 2022 at 5:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .