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

Commit

Permalink
feat: AwsLoadBalancePolicy class
Browse files Browse the repository at this point in the history
  • Loading branch information
neilkuan committed Oct 25, 2020
1 parent 8ce6459 commit 8f8ae6a
Show file tree
Hide file tree
Showing 7 changed files with 451 additions and 17 deletions.
9 changes: 4 additions & 5 deletions .projenrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { ConstructLibraryCdk8s, Semver } = require('projen');
const PROJECT_DESCRIPTION = 'cdk8s-aws-alb-ingress-controller is an CDK8S construct library that provides AWS Alb Ingress Controller Deplyment Configure.';

const CDK_VERSION = '1.70.0';
const project = new ConstructLibraryCdk8s({
description: PROJECT_DESCRIPTION,
authorAddress: "guan840912@gmail.com",
Expand All @@ -11,9 +11,6 @@ const project = new ConstructLibraryCdk8s({
keywords: ['aws', 'cdk8s', 'alb-ingress-controller'],
defaultReleaseBranch: 'main',
releaseBranches: ['main'],
devDependencies: {
'constructs': Semver.caret('3.0.4')
},
catalog: {
twitter: 'neil_kuan',
announce: true,
Expand All @@ -24,7 +21,9 @@ const project = new ConstructLibraryCdk8s({
},
});
project.addPeerDependencies({
'constructs': Semver.caret('3.0.4'),
'constructs': Semver.caret('3.1.3'),
'@aws-cdk/aws-iam': Semver.caret(CDK_VERSION),
'@aws-cdk/core': Semver.caret(CDK_VERSION),
});

const common_exclude = ['cdk.out', 'cdk.context.json', 'image', 'yarn-error.log','coverage'];
Expand Down
53 changes: 53 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Name|Description
----|-----------
[AlbIngressController](#cdk8s-aws-alb-ingress-controller-albingresscontroller)|Generate alb-ingress-controller config yaml.
[AwsLoadBalancePolicy](#cdk8s-aws-alb-ingress-controller-awsloadbalancepolicy)|awsLoadBalancePolicy class ,help you add policy to your Iam Role for service account.


**Structs**
Expand All @@ -15,6 +16,13 @@ Name|Description
[EnvVar](#cdk8s-aws-alb-ingress-controller-envvar)|*No description*


**Enums**

Name|Description
----|-----------
[VersionsLists](#cdk8s-aws-alb-ingress-controller-versionslists)|*No description*



## class AlbIngressController <a id="cdk8s-aws-alb-ingress-controller-albingresscontroller"></a>

Expand Down Expand Up @@ -60,6 +68,41 @@ Name | Type | Description



## class AwsLoadBalancePolicy <a id="cdk8s-aws-alb-ingress-controller-awsloadbalancepolicy"></a>

awsLoadBalancePolicy class ,help you add policy to your Iam Role for service account.


### Initializer




```ts
new AwsLoadBalancePolicy()
```



### Methods


#### *static* addPolicy(version, role) <a id="cdk8s-aws-alb-ingress-controller-awsloadbalancepolicy-addpolicy"></a>



```ts
static addPolicy(version: string, role: Role): any
```

* **version** (<code>string</code>) *No description*
* **role** (<code>[Role](#aws-cdk-aws-iam-role)</code>) *No description*

__Returns__:
* <code>any</code>



## struct AlbIngressControllerOptions <a id="cdk8s-aws-alb-ingress-controller-albingresscontrolleroptions"></a>


Expand Down Expand Up @@ -94,3 +137,13 @@ Name | Type | Description



## enum VersionsLists <a id="cdk8s-aws-alb-ingress-controller-versionslists"></a>



Name | Description
-----|-----
**AWS_LOAD_BALANCER_CONTROLLER_POLICY_V1** |
**AWS_LOAD_BALANCER_CONTROLLER_POLICY_V2** |


40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,46 @@ new MyChart(app, 'testcdk8s');
app.synth();
```

# Featrue For Add IAM Policy.
- For IRSA add IAM Policy version 1.
```ts
// CDK APP like eks_cluster.ts
import { AwsLoadBalancePolicy, VersionsLists } from 'cdk8s-aws-alb-ingress-controller';
import * as eks from '@aws-cdk/aws-eks';
const cluster = new eks.Cluster(this, 'MyK8SCluster', {
defaultCapacity: 0,
mastersRole: clusterAdmin,
version: eks.KubernetesVersion.V1_18,
});

const albServiceAccount = cluster.addServiceAccount('alb-ingress-controller', {
name: 'alb-ingress-controller',
namespace: 'kube-system',
});
// will help you add policy to IAM Role .
AwsLoadBalancePolicy.addPolicy(VersionsLists.AWS_LOAD_BALANCER_CONTROLLER_POLICY_V1, albServiceAccount);
```

- For IRSA add IAM Policy version 2.
```ts
// CDK APP like eks_cluster.ts
import { AwsLoadBalancePolicy, VersionsLists } from 'cdk8s-aws-alb-ingress-controller';
import * as eks from '@aws-cdk/aws-eks';
const cluster = new eks.Cluster(this, 'MyK8SCluster', {
defaultCapacity: 0,
mastersRole: clusterAdmin,
version: eks.KubernetesVersion.V1_18,
});

const albServiceAccount = cluster.addServiceAccount('alb-ingress-controller', {
name: 'alb-ingress-controller',
namespace: 'kube-system',
});
// will help you add policy to IAM Role .
AwsLoadBalancePolicy.addPolicy(VersionsLists.AWS_LOAD_BALANCER_CONTROLLER_POLICY_V2, albServiceAccount);
```

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

Distributed under the [Apache 2.0](./LICENSE) license.
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
"organization": false
},
"devDependencies": {
"@aws-cdk/aws-iam": "1.70.0",
"@aws-cdk/core": "1.70.0",
"@types/jest": "^26.0.7",
"@types/node": "^10.17.0",
"@typescript-eslint/eslint-plugin": "^4.3.0",
"@typescript-eslint/parser": "^4.3.0",
"cdk8s": "0.30.0",
"cdk8s-plus": "0.30.0",
"constructs": "3.0.4",
"constructs": "3.1.3",
"eslint": "^7.11.0",
"eslint-import-resolver-node": "^0.3.4",
"eslint-import-resolver-typescript": "^2.3.0",
Expand All @@ -49,15 +51,17 @@
"jsii-pacmak": "^1.11.0",
"jsii-release": "^0.1.6",
"json-schema": "^0.2.5",
"projen": "^0.3.106",
"projen": "^0.3.122",
"standard-version": "^9.0.0",
"ts-jest": "^26.1.0",
"typescript": "^3.9.5"
},
"peerDependencies": {
"@aws-cdk/aws-iam": "^1.70.0",
"@aws-cdk/core": "^1.70.0",
"cdk8s": "^0.30.0",
"cdk8s-plus": "^0.30.0",
"constructs": "^3.0.4"
"constructs": "^3.1.3"
},
"dependencies": {},
"bundledDependencies": [],
Expand Down
Loading

0 comments on commit 8f8ae6a

Please sign in to comment.