|
| 1 | ++++ |
| 2 | +title = "AWS Load Balancer Controller" |
| 3 | +icon = "fa-solid fa-balance-scale" |
| 4 | ++++ |
| 5 | + |
| 6 | +By leveraging CAPI cluster lifecycle hooks, this handler deploys the [AWS Load Balancer Controller] on the new cluster at the `AfterControlPlaneInitialized` phase. |
| 7 | + |
| 8 | +The AWS Load Balancer Controller manages AWS Application Load Balancers (ALB) and Network Load Balancers (NLB) for Kubernetes services and ingresses. |
| 9 | + |
| 10 | +Deployment of this controller is opt-in via the [provider-specific cluster configuration]({{< ref ".." >}}). |
| 11 | + |
| 12 | +The hook uses the [Cluster API Add-on Provider for Helm] to deploy the AWS Load Balancer Controller resources. |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +- AWS EKS cluster |
| 17 | +- IAM role with necessary permissions for the AWS Load Balancer Controller |
| 18 | + |
| 19 | +## Example |
| 20 | + |
| 21 | +To enable deployment of the AWS Load Balancer Controller on a cluster, specify the following values: |
| 22 | + |
| 23 | +```yaml |
| 24 | +apiVersion: cluster.x-k8s.io/v1beta1 |
| 25 | +kind: Cluster |
| 26 | +metadata: |
| 27 | + name: <NAME> |
| 28 | +spec: |
| 29 | + topology: |
| 30 | + variables: |
| 31 | + - name: clusterConfig |
| 32 | + value: |
| 33 | + addons: |
| 34 | + # TODO: Define an API |
| 35 | +``` |
| 36 | + |
| 37 | +## IAM Permissions |
| 38 | + |
| 39 | +The AWS Load Balancer Controller requires specific IAM permissions to manage load balancers. |
| 40 | +See [AWS Load Balancer IAM Policies] for the full list of permissions. |
| 41 | +The provided configuration assumes the permissions will be attached to the Nodes. |
| 42 | + |
| 43 | +If attaching these policies to the non-default isntance-profile, you may specify the name in the Cluster using the following configuration: |
| 44 | + |
| 45 | +```yaml |
| 46 | + - name: workerConfig |
| 47 | + value: |
| 48 | + eks: |
| 49 | + ... |
| 50 | + iamInstanceProfile: custom.nodes.cluster-api-provider-aws.sigs.k8s.io |
| 51 | +``` |
| 52 | +
|
| 53 | +## Usage |
| 54 | +
|
| 55 | +Once deployed, the AWS Load Balancer Controller can be used to: |
| 56 | +
|
| 57 | +1. **Create Application Load Balancers (ALB)** for Kubernetes services using the `service.beta.kubernetes.io/aws-load-balancer-type: nlb` annotation |
| 58 | +2. **Create Network Load Balancers (NLB)** for Kubernetes services using the `service.beta.kubernetes.io/aws-load-balancer-type: nlb` annotation |
| 59 | +3. **Manage Ingress resources** with the `kubernetes.io/ingress.class: alb` annotation |
| 60 | +4. **Configure Target Group Bindings** for advanced load balancer configurations |
| 61 | + |
| 62 | +## Example Service |
| 63 | + |
| 64 | +https://kubernetes-sigs.github.io/aws-load-balancer-controller/latest/guide/service/nlb/ |
| 65 | + |
| 66 | +```yaml |
| 67 | +apiVersion: v1 |
| 68 | +kind: Service |
| 69 | +metadata: |
| 70 | + name: my-service |
| 71 | + annotations: |
| 72 | + service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing |
| 73 | +spec: |
| 74 | + type: LoadBalancer |
| 75 | + loadBalancerClass: service.k8s.aws/nlb |
| 76 | + ports: |
| 77 | + - port: 80 |
| 78 | + targetPort: 8080 |
| 79 | + selector: |
| 80 | + app: my-app |
| 81 | +``` |
| 82 | + |
| 83 | +See [AWS Load Balancer Examples] for more details. |
| 84 | + |
| 85 | +[AWS Load Balancer Controller]: https://kubernetes-sigs.github.io/aws-load-balancer-controller/ |
| 86 | +[Cluster API Add-on Provider for Helm]: https://github.com/kubernetes-sigs/cluster-api-addon-provider-helm |
| 87 | +[AWS Load Balancer IAM Policies]: https://kubernetes-sigs.github.io/aws-load-balancer-controller/latest/deploy/installation/#option-b-attach-iam-policies-to-nodes |
| 88 | +[AWS Load Balancer Examples]: https://kubernetes-sigs.github.io/aws-load-balancer-controller/latest/guide/ingress/annotations/ |
0 commit comments