AWS Load Balancer Controller on EKS only creates Network LB

0

AWS Load Balancer Controller only creates Network LB for services that are of type LoadBalancer.

I specify in the helm chart to create an ALB but it keeps creating NLB

Helm chart:

kubernetes.io/ingress.class: "alb"

2 Answers
0

adding more configuration details:

service:
   enabled: true
   labels: {}
   labelsHeadless: {}
   type: LoadBalancer
   publishNotReadyAddresses: false
   nodePort: ""
   annotations:
    kubernetes.io/ingress.class: "alb"
    alb.ingress.kubernetes.io/target-type: "ip"
    alb.ingress.kubernetes.io/scheme: "internal"

The problem is not with the controller or role as it normally creates the NLB in AWS and the cluster appears with the ExternalIP pointing to the newly created NLB.

But I can't make it create an ALB

marlon
answered a month ago
0

In Kubernetes, an Ingress is typically used to manage access to services over a common entry point. An ALB, when used with the AWS Load Balancer Controller in a Kubernetes cluster, is usually managed through Ingress resources rather than Service resources of type LoadBalancer. The annotations you've provided (like kubernetes.io/ingress.class: "alb") are meant for Ingress resources, not for Service resources.

On the other hand, when you create a Service with type: LoadBalancer, Kubernetes interacts with the cloud provider's (in this case, AWS) load balancer support to provision a load balancer for your service. In AWS's case, this often defaults to creating an NLB or a Classic Load Balancer, depending on the configuration and the Kubernetes version.

Having said that, to create an ALB, you'll need to use an Ingress resource instead of specifying the load balancer type in your Service resource.

  1. Ensure the AWS Load Balancer Controller is Installed: This controller is responsible for managing ALBs for Ingress resources in AWS.

  2. Define an Ingress Resource: Create an Ingress resource that uses the kubernetes.io/ingress.class: "alb" annotation. This tells the AWS Load Balancer Controller to create an ALB.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    kubernetes.io/ingress.class: "alb"
    alb.ingress.kubernetes.io/target-type: "ip"
    alb.ingress.kubernetes.io/scheme: "internal"
spec:
  rules:
  - http:
      paths:
      - path: /testpath
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80

  1. Adjust Your Service: Ensure your Service resources are correctly defined to serve traffic behind the Ingress. Typically, these don't need to be of type: LoadBalancer when used with an Ingress; type: ClusterIP is usually sufficient.
apiVersion: v1
kind: Service
metadata:
  name: test
spec:
  ports:
  - port: 80
    targetPort: 9376
  selector:
    app: MyApp

  1. Deploy the Ingress and Service: Apply these configurations to your cluster.

By following these steps, the AWS Load Balancer Controller should create an ALB based on the Ingress definition, and route traffic to your services accordingly.

The Service of type: LoadBalancer and its annotations for the ALB are not necessary and can be removed or replaced with a standard type: ClusterIP service that the Ingress will use to route traffic to your pods.

profile picture
EXPERT
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions