-
Notifications
You must be signed in to change notification settings - Fork 8
feat: deploy AWS Load Balancer controller in EKS clusters #1341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dkoshkin
wants to merge
3
commits into
main
Choose a base branch
from
dkoshkin/feat-aws-load-balancer-controller
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+394
−40
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...r-api-runtime-extensions-nutanix/addons/aws-load-balancer-controller/values-template.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
clusterName: "{{ .ControlPlane.spec.eksClusterName }}" | ||
12 changes: 12 additions & 0 deletions
12
...nsions-nutanix/templates/addons/aws-load-balancer-controller/helm-addon-installation.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright 2025 Nutanix. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
{{- if .Values.hooks.addons.awsLoadBalancerController.defaultValueTemplateConfigMap.create }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: '{{ .Values.hooks.addons.awsLoadBalancerController.defaultValueTemplateConfigMap.name }}' | ||
data: | ||
values.yaml: |- | ||
{{- .Files.Get "addons/aws-load-balancer-controller/values-template.yaml" | nindent 4 }} | ||
{{- end -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
+++ | ||
title = "AWS Load Balancer Controller" | ||
icon = "fa-solid fa-balance-scale" | ||
+++ | ||
|
||
By leveraging CAPI cluster lifecycle hooks, this handler deploys the [AWS Load Balancer Controller] on the new cluster at the `AfterControlPlaneInitialized` phase. | ||
|
||
The AWS Load Balancer Controller manages AWS Application Load Balancers (ALB) and Network Load Balancers (NLB) for Kubernetes services and ingresses. | ||
|
||
Deployment of this controller is opt-in via the [provider-specific cluster configuration]({{< ref ".." >}}). | ||
|
||
The hook uses the [Cluster API Add-on Provider for Helm] to deploy the AWS Load Balancer Controller resources. | ||
|
||
## Prerequisites | ||
|
||
- AWS EKS cluster | ||
- IAM role with necessary permissions for the AWS Load Balancer Controller | ||
|
||
## Example | ||
|
||
To enable deployment of the AWS Load Balancer Controller on a cluster, specify the following values: | ||
|
||
```yaml | ||
apiVersion: cluster.x-k8s.io/v1beta1 | ||
kind: Cluster | ||
metadata: | ||
name: <NAME> | ||
spec: | ||
topology: | ||
variables: | ||
- name: clusterConfig | ||
value: | ||
addons: | ||
# TODO: Define an API | ||
``` | ||
|
||
## IAM Permissions | ||
|
||
The AWS Load Balancer Controller requires specific IAM permissions to manage load balancers. | ||
See [AWS Load Balancer IAM Policies] for the full list of permissions. | ||
The provided configuration assumes the permissions will be attached to the Nodes. | ||
|
||
If attaching these policies to the non-default isntance-profile, you may specify the name in the Cluster using the following configuration: | ||
|
||
```yaml | ||
- name: workerConfig | ||
value: | ||
eks: | ||
... | ||
iamInstanceProfile: custom.nodes.cluster-api-provider-aws.sigs.k8s.io | ||
``` | ||
|
||
## Usage | ||
|
||
Once deployed, the AWS Load Balancer Controller can be used to: | ||
|
||
1. **Create Application Load Balancers (ALB)** for Kubernetes services using the `service.beta.kubernetes.io/aws-load-balancer-type: nlb` annotation | ||
2. **Create Network Load Balancers (NLB)** for Kubernetes services using the `service.beta.kubernetes.io/aws-load-balancer-type: nlb` annotation | ||
3. **Manage Ingress resources** with the `kubernetes.io/ingress.class: alb` annotation | ||
4. **Configure Target Group Bindings** for advanced load balancer configurations | ||
|
||
## Example Service | ||
|
||
See [AWS Load Balancer NLB Example] | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: my-service | ||
annotations: | ||
service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing | ||
spec: | ||
type: LoadBalancer | ||
loadBalancerClass: service.k8s.aws/nlb | ||
ports: | ||
- port: 80 | ||
targetPort: 8080 | ||
selector: | ||
app: my-app | ||
``` | ||
|
||
See other examples in [AWS Load Balancer Example] docs. | ||
|
||
[AWS Load Balancer Controller]: https://kubernetes-sigs.github.io/aws-load-balancer-controller/ | ||
[Cluster API Add-on Provider for Helm]: https://github.com/kubernetes-sigs/cluster-api-addon-provider-helm | ||
[AWS Load Balancer IAM Policies]: https://kubernetes-sigs.github.io/aws-load-balancer-controller/latest/deploy/installation/#option-b-attach-iam-policies-to-nodes | ||
[AWS Load Balancer NLB Example]: https://kubernetes-sigs.github.io/aws-load-balancer-controller/latest/guide/service/nlb/ | ||
[AWS Load Balancer Example]: https://kubernetes-sigs.github.io/aws-load-balancer-controller/latest/guide/ingress/annotations/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
hack/addons/kustomize/aws-load-balancer-controller/kustomization.yaml.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2025 Nutanix. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
metadata: | ||
name: aws-load-balancer-controller | ||
|
||
helmCharts: | ||
- name: aws-load-balancer-controller | ||
namespace: kube-system | ||
repo: https://aws.github.io/eks-charts | ||
releaseName: aws-load-balancer-controller | ||
version: ${AWS_LOAD_BALANCER_CONTROLLER_CHART_VERSION} | ||
includeCRDs: true | ||
skipTests: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright 2025 Nutanix. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Package awsloadbalancercontroller provides lifecycle handlers for deploying the AWS Load Balancer Controller addon. | ||
// | ||
// The AWS Load Balancer Controller manages AWS Application Load Balancers (ALB) and Network Load Balancers (NLB) | ||
// for Kubernetes services and ingresses. This package provides handlers that deploy the controller using | ||
// the Cluster API Add-on Provider for Helm (CAAPH). | ||
// | ||
// The handler automatically installs the AWS Load Balancer Controller during the AfterControlPlaneInitialized | ||
// lifecycle phase, ensuring the controller is available for managing load balancer resources. | ||
package awsloadbalancercontroller |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how this value
.ControlPlane.spec.eksClusterName
is passed to this template? I don't see this is provided from the handler.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CAAPH sets it in https://github.com/kubernetes-sigs/cluster-api-addon-provider-helm/blob/8b802803ebd5c067f3352b974e7f4b1213de2399/internal/value_substitutions.go#L70-L72