How to share an AWS NLB between two EKS Services?

869 views Asked by At

We have a cross AZ deployment in an EKS cluster inside an AWS region where every AZ is independent, meaning that components do not talk to other components that are not in the same AZ.

We are using Contour as our ingress and have different Daemon Sets, one for each AZ. As a result, we also have different Services defined for every Daemon Set.

When deploying the Services to EKS, two different NLBs are created.

We would like to have only one NLB that will be shared between the Services.

The question is: can it be achieved and if it can then how?

1

There are 1 answers

0
Jonas On BEST ANSWER

Yes, you should be able to do this, by using an appropriate selector in your Service.

In each DaemonSet that you use, you have set the label in the Pod-template for the pods.

E.g.

template:
  metadata:
    labels:
      app: contour
      az: az-1

and

template:
  metadata:
    labels:
      app: contour
      az: az-2

Now, in your Loadbalancer Service, you need to use a selector that matches the Pods on both your DaemonSets, e.g. app: contour

Example Service

apiVersion: v1
kind: Service
metadata:
  name: my-service
  annotation:
    service.beta.kubernetes.io/aws-load-balancer-type: nlb
spec:
  selector:
    app: contour    # this needs to match the Pods in all your DaemonSets
  ports:
    - protocol: TCP
      port: 80
  type: LoadBalancer