Kubernetes cluster outgoing traffic IP

9/24/2018

I have a Kubernetes cluster on Google Kubernetes Engine. I want to assign a static IP for all outgoing traffic of a cluster.

I already have reserved external IPs but I can't assign them to a cluster with the GCP console.

I found a solution to do it with the cli : Static outgoing IP in Kubernetes

but it targets the VM and I will need to set it each time I deploy. So it's not targeting the cluster.

Can anybody provide any pointers? Thanks.

-- raven8
google-cloud-platform
google-kubernetes-engine
kubernetes
network-traffic

2 Answers

9/24/2018

GKE currently doesn't have an option to create the cluster with all your nodes using a reserved public IP. All you get in advanced networking options is something like this:

advanced network k8s

You will have to use the gcloud API that you mentioned which should be easy to put in a script.

Or you can also use the UI by editing the instance(s) and going into 'Network Interfaces' like this:

network

-- Rico
Source: StackOverflow

9/24/2018

I agree with something in the previous answer you can't do something like this directly in the cluster, but you can use another service to do what you are looking for: nat gateway that will use a fixe public ip.

For more security, you can even deploy the gateways in multiple zones to have some redundancy and your cluster will always have outgoing trafic go by the gateways.

I won't explain how it works here, because google already provided a tutorial to what you want to do here: https://cloud.google.com/solutions/using-a-nat-gateway-with-kubernetes-engine

Enjoy.

-- night-gold
Source: StackOverflow