Static IP address from gcloud docker container using Curl

9/19/2017

I have multiple different pods (containers) (9) on gcloud using kubenetes each with their own static IP address. I also have multiple node pools (9) in the cluster they all use. If I make a cURL request from any of the pods (containers) the IP address that is logged in the destination URL's logs is always the IP address of the first node pool in the cluster.

My question is does this consistently happen? If this node pool is removed I lose the IP address. Is there any way to make this cURL request address static?

I need this because these containers need to cURL an external service that is IP limited and I need to make a request to change this IP address each time it changes.

-- Apothan
curl
gcloud
google-kubernetes-engine
php

1 Answer

9/21/2017

Since you have a large number of nodes, I think the only reliable way to do this would be to configure a single node as the NAT gateway for the outbound traffic. So outbound traffic from all nodes will first go to the NAT gateway which in turn will connect to your external service. You can then assign a static IP to this gateway VM instance. Obviously this also introduces a single point of failure for external traffic.

This page contains detailed steps on setting up a NAT gateway. You may also refer to this discussion.

A second option would be to have a dedicated pool/nodes just for pods which needs external access. You can then give dedicated IPs for those nodes alone.

-- Jayson Chacko
Source: StackOverflow