AWS ALB service in Kubernetes

1.8k Views Asked by At

I want to deploy Application Load Balancer for Traefik running in Kubernetes. So, I tried the following:

kind: Service
apiVersion: v1
metadata:
  name: traefik-application-elb
  namespace: kube-system
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "tcp"
    service.beta.kubernetes.io/aws-load-balancer-type: "elb"
    service.beta.kubernetes.io/aws-load-balancer-name: "eks-traefik-application-elb"
    service.beta.kubernetes.io/aws-load-balancer-additional-resource-tags: "App=traefik,Env=dev"
spec:
  type: LoadBalancer
  ports:
    - protocol: TCP
      name: web
      port: 80
    - protocol: TCP
      name: websecure
      port: 443
  selector:
    app: traefik

But internet-facing Classic load balancer was created. Also tried service.beta.kubernetes.io/aws-load-balancer-type: "alb" but nothing changed.

What is wrong here ?

1

There are 1 best solutions below

0
On

From the docs: https://docs.aws.amazon.com/eks/latest/userguide/network-load-balancing.html

When you create a Kubernetes Service of type LoadBalancer, the AWS cloud provider load balancer controller creates AWS Classic Load Balancers by default, but can also create AWS Network Load Balancers.

ALB is not supported as a k8s load balancer. You can specify an NLB if desired.

However you can use ALB as an ingress controller with a deployment like this - https://aws.amazon.com/blogs/containers/introducing-aws-load-balancer-controller/

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: SearchApp
  annotations:
    # share a single ALB with all ingress rules with search-app-ingress
    alb.ingress.kubernetes.io/group.name: search-app-ingress
spec:
  defaultBackend:
    service:
      name: search-svc # route traffic to the service search-svc
      port:
        number: 80