Skip to content
This repository has been archived by the owner on Dec 23, 2021. It is now read-only.

Commit

Permalink
feat: awsloadbalancecontroller V2
Browse files Browse the repository at this point in the history
  • Loading branch information
neilkuan committed Nov 23, 2020
1 parent f5f32c7 commit 91d442a
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Basic implementation of a [aws alb ingress controller](https://github.com/kubernetes-sigs/aws-alb-ingress-controller) construct for cdk8s. Contributions are welcome!

## Usage

### AWS Load Balance Controller V1
```ts
import { App, Chart } from 'cdk8s';
import { Construct } from 'constructs';
Expand All @@ -31,6 +31,36 @@ new MyChart(app, 'testcdk8s');
app.synth();
```

### AWS Load Balance Controller V2
#### only support install in default namespace now!!!
```ts
import { App, Chart } from 'cdk8s';
import { AwsLoadBalancerController } from 'cdk8s-aws-alb-ingress-controller';
import * as constructs from 'constructs';

export interface MyChartProps {
readonly clusterName: string;
}

export class MyChart extends Chart {
readonly deploymentName: string;
readonly deploymentNameSpace: string;
constructor(scope: Construct, name: string, props: MyChartProps) {
super(scope, name);
const alb = new AwsLoadBalancerController(this, 'alb', {
clusterName: props.clusterName,
createServiceAccount: false,
});
this.deploymentName = alb.deploymentName;
this.deploymentNameSpace = alb.namespace;
}
}
const app = new App();
new MyChart(app, 'testcdk8s');
app.synth();
```


# Featrue For Add IAM Policy.
- For IRSA add IAM Policy version 1.
```ts
Expand Down Expand Up @@ -62,12 +92,12 @@ import * as eks from '@aws-cdk/aws-eks';
version: eks.KubernetesVersion.V1_18,
});

const albServiceAccount = cluster.addServiceAccount('alb-ingress-controller', {
name: 'alb-ingress-controller',
namespace: 'kube-system',
const sa = new eks.ServiceAccount(this, 'albserviceaccount', {
cluster: cluster,
name: 'aws-load-balancer-controller',
});
// will help you add policy to IAM Role .
AwsLoadBalancePolicy.addPolicy(VersionsLists.AWS_LOAD_BALANCER_CONTROLLER_POLICY_V2, albServiceAccount);
AwsLoadBalancePolicy.addPolicy(VersionsLists.AWS_LOAD_BALANCER_CONTROLLER_POLICY_V2, sa );

```

Also can see [example repo](https://github.com/guan840912/cdk8s-cdk-example)
Expand Down

0 comments on commit 91d442a

Please sign in to comment.