简体   繁体   中英

Kubernetes cluster outgoing traffic IP

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.

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:

先进的网络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:

网络

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM