Kubernetes maintain load balancer's external IP on new deployment

10/8/2019

Is there a way to keep the same external IP that current load balancer has even when I make a new deployment?

When I delete the deployment connected to the load balancer, load balancer still stays so is it possible to connect a new deployment to that existing load balancer?

-- J.S.C
eks
kubernetes

1 Answer

10/8/2019

yes, you can pass the externalIP in the service object's yaml file.

Try following this -

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: MyApp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9376
  loadBalancerIP: 78.11.24.19
  type: LoadBalancer

Please refer to https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer for more info on this

-- Tushar Mahajan
Source: StackOverflow