- Newest
- Most votes
- Most comments
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
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.
-
Ensure the AWS Load Balancer Controller is Installed: This controller is responsible for managing ALBs for Ingress resources in AWS.
-
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
- 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
- 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.
Relevant content
- AWS OFFICIALUpdated a year ago
- How can I troubleshoot issues when I use the AWS Load Balancer Controller to create a load balancer?AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 8 months ago