How can gke create a reserved public or private gcp address for use in a LoadBalancer Service?

11/25/2018

is there support in gke or helm to have k8s create a reserved GCP address for me that I will be using in externalIPs? https://cloud.google.com/compute/docs/ip-addresses/reserve-static-external-ip-address https://cloud.google.com/compute/docs/ip-addresses/reserve-static-internal-ip-address

I can script it myself, but Id like this reservation to be part of the kuberenetes config itself instead of having to create it outside of the k8s config with my own scripts or manually

perhaps the new k8s Service Catalog can provision a reserved static IP for me?

-- red888
google-cloud-platform
google-compute-engine
google-kubernetes-engine
kubernetes

1 Answer

11/26/2018

EDIT:

For incoming traffic:

You can define a static IP for a service type LoadBalancer. You must hav the static IP reserved before hand and you can define the spec.loadBalancerIP field to use the reserved IP address.

You can also assign a static IP to an Ingress resource using an annotation

For outbound or Egress traffic:

There is no way to have GKE use predefined static IPs as the nodes are created from a single template which can't include the static IPs.

Nodes, like many k8s components, are meant to be ephemeral and stateless. In most cases where static IPs are necessary, it is because the cluster will be making calls to an outside application or end point and the IPs must be whitelisted. In those situations, it is recommended to use a NAT which will use a static IP.

You can follow this tutorial or consider using Cloud NAT with GKE

-- Patrick W
Source: StackOverflow