How to have the static ELB endpoint for kubernates deployments

12/21/2018

Every time I deploy a new build in kubernates. I am getting different EXTERNAL-IP which in below case is afea383cbf72c11e8924c0a19b12bce4-xxxxx.us-east-1.elb.amazonaws.com

$ kubectl get services -o wide -l appname=${APP_FULLNAME_SYSTEST},stage=${APP_SYSTEST_ENV}
NAME                                        TYPE           CLUSTER-IP      EXTERNAL-IP                                                               PORT(S)         AGE       SELECTOR
test-systest-lb-https   LoadBalancer   123.45.xxx.21   afea383cbf72c11e8924c0a19b12bce4-xxxxx.us-east-1.elb.amazonaws.com   443:30316/TCP   9d        appname=test-systest,stage=systest

How can I have a static external IP (elb) so that I can link that to route 53. Do I have to include something on my Kubernates deployment yml file.

Additional details: I am using below loadbalancer

spec:
  type: LoadBalancer
  ports:
  - name: http
    port: 443
    targetPort: 8080
    protocol: TCP
  selector:
    appname: %APP_FULL_NAME%
    stage: %APP_ENV%
-- Vikas Rathore
amazon-elb
kubernetes

1 Answer

12/21/2018

If you are just doing new builds of a single Deployment then you should check what your pipeline is doing to the Service. You want to do a kubectl apply and a rolling update on the Deployment (provided the strategy is set on the Deployment) without modifying the Service (so not a delete and a create). If you do kubectl get services you should see its age (your output shows 9d so that's all good) and kubectl describe service <service_name> will show any events on it.

I'm guessing do just want an external IP entry you can point to like 'afea383cbf72c11e8924c0a19b12bce4-xxxxx.us-east-1.elb.amazonaws.com' and not a truly static IP. If you do want a true static IP you won't get it like this but you can now try NLB.

If you mean you want multiple Deployments (different microservices) to share a single IP then you could install an ingress controller and expose that with an ELB. Then when you deploy new apps you use an Ingress resource for each to tell the controller to expose them externally. So you can then put all your apps on the same external IP but routed under different paths or subdomains. The nginx ingress controller is a good option.

-- Ryan Dawson
Source: StackOverflow