I had cluster A with a static IP on a load balancer, but needed to move a deployment to service B whilst maintaining the same static IP address.

I did the following:

  1. Removed the loadbalancer from cluster A.
  2. Created a new loadbalancer in cluster B, and then after it was created assigned the static IP address to it via the networking screen, and at the same time removed the ephemeral IP address.
  3. Hoped for success.

The load balancer service on the GCS portal under Kubernetes Engine > Services looks like this:

apiVersion: v1
kind: Service
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcp
  name: contour
  namespace: heptio-contour
  clusterIP: x.x.x.x
  externalTrafficPolicy: Cluster
  - name: http
    nodePort: 31774
    port: 80
    protocol: TCP
    targetPort: 8080
  - name: https
    nodePort: 30314
    port: 443
    protocol: TCP
    targetPort: 8443
    app: contour
  sessionAffinity: None
  type: LoadBalancer
    - ip: e.e.e.e

At present the IP address is the ephemeral IP address e.e.e.e, and this is what the details tab shows as both the "external endpoints" and the "loadbalancer" IP.

If I click through to the linked load balancer (found under Network Services > Load Balancing), I can see that the frontend IP is s.s.s.s (my static IP) for ports 80-443 - I'm specifically trying to access ports 80 and 443.

I've found that I can't change the load balancer IP at the bottom of the YAML config file - after I save, it just reverts my changes. I've also tried adding loadBalancerIP: s.s.s.s below clusterIP but this didn't make a difference. Finally, I've gone to the static IP itself and ensured that the forwarding rule was pointed at the correct load balancer.

My question is: What steps do I have to take to successfully assign this external IP address to an existing load balancer, and have it serve traffic to the cluster?

Kubernetes service:

enter image description here

Load balancer:

enter image description here

1 Answer 1


If you want to update a static IP to a load balancer in GKE:

  • Create LB using service yaml file.
  • Go inside the service yaml file and then define LB’s static IP using notation
  • Once your yaml is modified you just need to run it, use:

    kubectl apply -f service.yaml.

This will update the configuration changes.

It’s important to mention that in GKE every modification should be done in yaml file not from the console.

You can have a look into this guide for more clarification.

  • I already tried that, unfortunately. Thanks though. Dec 1, 2018 at 2:30
  • you might have to delete and recreate the loadbalancer service if the update is not taking effect.
    – Patrick W
    Dec 4, 2018 at 15:32
  • Also, make sure that you are using a regional IP for the Loadbalancer IP and not a global one.
    – Patrick W
    Dec 4, 2018 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.