[aws-eks] AWS load balancer controller support
See original GitHub issueIt’s a common use case to deploy ALB ingress controller on EKS, it would be helpful to support it in L2 class level.
Use Case
Deploy ALB ingress controller for using ALB to deploy ingress of K8S.
Proposed Solution
Might implement a new L2 class ALBIngressController
like below,
import * as yaml from 'js-yaml';
import * as request from 'sync-request';
export interface ALBIngressControllerProps {
readonly cluster: Cluster;
readonly version: string;
readonly vpcId: string;
}
class ALBIngressController extends Construct {
constructor(scope: Construct, id: string, props: ALBIngressControllerProps) {
const albBaseResourceBaseUrl = `https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/${props.version}/docs/examples/`;
const albIngressControllerPolicyUrl = `${albBaseResourceBaseUrl}iam-policy.json`;
const albNamespace = 'kube-system';
const albServiceAccount = props.cluster.addServiceAccount('alb-ingress-controller', {
name: 'alb-ingress-controller',
namespace: albNamespace,
});
const policyJson = request('GET', albIngressControllerPolicyUrl).getBody();
((JSON.parse(policyJson))['Statement'] as []).forEach((statement, idx, array) => {
albServiceAccount.addToPolicy(iam.PolicyStatement.fromJson(statement));
});
const rbacRoles = yaml.safeLoadAll(request('GET', `${albBaseResourceBaseUrl}rbac-role.yaml`).getBody())
.filter((rbac: any) => { return rbac['kind'] != 'ServiceAccount' });
const albDeployment = yaml.safeLoad(request('GET', `${albBaseResourceBaseUrl}alb-ingress-controller.yaml`).getBody());
const albResources = props.cluster.addResource('aws-alb-ingress-controller', ...rbacRoles, albDeployment);
const albResourcePatch = new eks.KubernetesPatch(this, `alb-ingress-controller-patch-${props.version}`, {
cluster,
resourceName: "deployment/alb-ingress-controller",
resourceNamespace: albNamespace,
applyPatch: {
spec: {
template: {
spec: {
containers: [
{
name: 'alb-ingress-controller',
args: [
'--ingress-class=alb',
'--feature-gates=wafv2=false',
`--cluster-name=${props.cluster.clusterName}`,
`--aws-vpc-id=${props.vpcId}`,
`--aws-region=${stack.region}`,
]
}
]
}
}
}
},
restorePatch: {
spec: {
template: {
spec: {
containers: [
{
name: 'alb-ingress-controller',
args: [
'--ingress-class=alb',
'--feature-gates=wafv2=false',
`--cluster-name=${props.cluster.clusterName}`,
]
}
]
}
}
}
},
});
albResourcePatch.node.addDependency(albResources);
}
}
Other
- 👋 I may be able to implement this feature request
- ⚠️ This feature might incur a breaking change
This is a 🚀 Feature Request
Issue Analytics
- State:
- Created 3 years ago
- Reactions:35
- Comments:22 (6 by maintainers)
Top Results From Across the Web
Installing the AWS Load Balancer Controller add-on
The AWS Load Balancer Controller manages AWS Elastic Load Balancers for a Kubernetes cluster. The controller provisions the following resources: ... The AWS...
Read more >Welcome - AWS Load Balancer Controller
AWS Load Balancer Controller is a controller to help manage Elastic Load Balancers for a Kubernetes cluster. It satisfies Kubernetes Ingress resources by ......
Read more >Running the Latest AWS Load Balancer Controller in Your ...
The load balancer distributes incoming application traffic across multiple targets, in this case, is our EKS cluster. The ALB Ingress Controller runs as...
Read more >Setting up the LB controller - Amazon EKS Workshop
“AWS Load Balancer Controller” is a controller to help manage Elastic Load Balancers for a Kubernetes cluster. It satisfies Kubernetes Ingress resources by ......
Read more >AWS Load Balancer Controller on EKS Cluster
AWS Load Balancer Controller on EKS Cluster · When the Ingress resource is created in kubernetes API, the alb-ingress-controller observes the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We had the same issue and unfortunately the HelmChart part for Cert Manager did not work for us.
Here is a version we made which works fine using manifests on official documentation but can be improved of course. We encountered some CloudFormation limitations (the size of event payload which cannot exceed 262144 bytes for example) and made some workaround so it can work correctly.
Versions:
Alb Ingress Controller deployment
AwsCertManagerService.ts
AwsAlbIngressController .ts
We had to update manifests because of original descriptions formatting not readabled as is by CloudFormation
For whom is interesting deploying ALB into EKS via CDK, you can refer to the implementation of below solution,
https://github.com/aws-samples/nexus-oss-on-aws/blob/d3a092d72041b65ca1c09d174818b513594d3e11/src/lib/sonatype-nexus3-stack.ts#L207-L242