Package: cdk8s-aws-load-balancer-controller
cdk8s-aws-load-balancer-controllercdk8s aws load balancer controllerconstructs for cdk8sThis project was formerly known as "CDK AWS ALB Ingress Controller", I just rename it to be "CDK AWS Load Balancer Controller".Basic implementation of aaws load balancer controllerconstruct for cdk8s. Contributions are welcome!Before Usage need to install helmcurl-fsSL-oget_helm.shhttps://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod700get_helm.sh
./get_helm.shUsagenpmicdk8s-aws-load-balancer-controller
npmicdk8s
or
yarnaddcdk8s-aws-load-balancer-controller
yarnaddcdk8sAWS Load Balance Controller V1# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826fromcdk8simportApp,ChartfromconstructsimportConstructfromcdk8s_aws_load_balancer_controllerimportAlbIngressControllerclassMyChart(Chart):def__init__(self,scope,name):super().__init__(scope,name)AlbIngressController(self,"albingresscntroller",cluster_name="EKScluster")app=App()MyChart(app,"testcdk8s")app.synth()AWS Load Balance Controller V2# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826fromcdk8simportApp,Chartfromcdk8s_aws_load_balancer_controllerimportAwsLoadBalancerControllerimportconstructsasconstructsclassMyChart(Chart):def__init__(self,scope,name,*,clusterName):super().__init__(scope,name)alb=AwsLoadBalancerController(self,"alb",cluster_name=cluster_name,create_service_account=False)self.deployment_name=alb.deployment_nameself.deployment_name_space=alb.namespaceapp=App()MyChart(app,"testcdk8s")app.synth()AWS Load Balance Controller V2 specific Namespace.# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826fromcdk8simportApp,Chartfromcdk8s_aws_load_balancer_controllerimportAwsLoadBalancerControllerimportconstructsasconstructsclassMyChart(Chart):def__init__(self,scope,name,*,clusterName):super().__init__(scope,name)alb=AwsLoadBalancerController(self,"alb",cluster_name=cluster_name,create_service_account=False,namespace="kube-system")self.deployment_name=alb.deployment_nameself.deployment_name_space=alb.namespaceapp=App()MyChart(app,"testcdk8s")app.synth()Featrue For Add IAM Policy.For IRSA add IAM Policy version 1.# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826# CDK APP like eks_cluster.tsfromcdk8s_aws_load_balancer_controllerimportAwsLoadBalancePolicy,VersionsListsimportaws_cdk.aws_eksasekscluster=eks.Cluster(self,"MyK8SCluster",default_capacity=0,masters_role=cluster_admin,version=eks.KubernetesVersion.V1_18)alb_service_account=cluster.add_service_account("alb-ingress-controller",name="alb-ingress-controller",namespace="kube-system")# will help you add policy to IAM Role .AwsLoadBalancePolicy.add_policy(VersionsLists.AWS_LOAD_BALANCER_CONTROLLER_POLICY_V1,alb_service_account)For IRSA add IAM Policy version 2.# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826# CDK APP like eks_cluster.tsfromcdk8s_aws_load_balancer_controllerimportAwsLoadBalancePolicy,VersionsListsimportaws_cdk.aws_eksasekscluster=eks.Cluster(self,"MyK8SCluster",default_capacity=0,masters_role=cluster_admin,version=eks.KubernetesVersion.V1_18)sa=eks.ServiceAccount(self,"albserviceaccount",cluster=cluster,name="aws-load-balancer-controller")AwsLoadBalancePolicy.add_policy(VersionsLists.AWS_LOAD_BALANCER_CONTROLLER_POLICY_V2,sa)Also can seeexample repo 1orexample repo 2work with aws cdk.LicenseDistributed under theApache 2.0license.