How to re-assign static IP address from one cluster to another in the google container engine

9/28/2016

I setup cluster via gcloud container engine, where I have deployed my pods with nodejs server running on them. I am using LoadBalancer service and static IP for routing the traffic across these instances. Everything works perfectly, but I forget to specify write/read permission for google storage api, and my server cannot save files to the bucket storage.

According to this answer there is no way I can change permissions (scopes) for cluster after it was created. So I created a new cluster with correct permissions and re-deployed my containers. I would like to re-use the static IP, I have received from google, tell loadBalancer to use existing IP and remove old cluster. How to do that? I really don't want to change DNS.

-- Max Podriezov
google-kubernetes-engine
kubernetes
load-balancing
static-ip-address

1 Answer

10/4/2016

If you are using a type: LoadBalancer style service then you can use the loadBalancerIP field on the service.

apiVersion: v1
kind: Service
spec:
  type: LoadBalancer
  loadBalancerIP: 10.10.10.10
  ...

If you are using an Ingress you can use an annotation on Google Cloud to set the IP address. Here you use the IP address name in Google Cloud rather than the IP address itself.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
 name: myingress
 annotations:
   "kubernetes.io/ingress.global-static-ip-name": my-ip-name
spec:
  ...
-- Ian Lewis
Source: StackOverflow