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:
- Removed the loadbalancer from cluster A.
- 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.
- Hoped for success.
The load balancer service on the GCS portal under Kubernetes Engine > Services
looks like this:
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcp
name: contour
namespace: heptio-contour
spec:
clusterIP: x.x.x.x
externalTrafficPolicy: Cluster
ports:
- name: http
nodePort: 31774
port: 80
protocol: TCP
targetPort: 8080
- name: https
nodePort: 30314
port: 443
protocol: TCP
targetPort: 8443
selector:
app: contour
sessionAffinity: None
type: LoadBalancer
status:
loadBalancer:
ingress:
- 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:
Load balancer:
Best Answer
If you want to update a static IP to a load balancer in GKE:
“loadBalancerIP".
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.