-
Notifications
You must be signed in to change notification settings - Fork 204
/
examples.ts
108 lines (98 loc) · 3.23 KB
/
examples.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import * as cdk from 'aws-cdk-lib';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as kms from 'aws-cdk-lib/aws-kms';
import * as bp from '../lib';
import * as bcrypt from 'bcrypt';
import { KubernetesVersion } from 'aws-cdk-lib/aws-eks';
import { IngressNginxAddOn, AwsLoadBalancerControllerAddOn } from '../lib/addons';
/**
* You can run these examples with the following command:
* <code>
* npm run examples list
* npm run examples deploy <blueprint-name>
* </code>
*/
const app = new cdk.App();
const KMS_RESOURCE = "kms-key-22";
const base = bp.EksBlueprint.builder()
.account(process.env.CDK_DEFAULT_ACCOUNT)
.region(process.env.CDK_DEFAULT_REGION)
.resourceProvider(bp.GlobalResources.Vpc, new bp.VpcProvider("default")) // saving time on VPC creation
.resourceProvider(KMS_RESOURCE, {
provide(context): cdk.aws_kms.Key {
return new kms.Key(context.scope, KMS_RESOURCE);
}
});
const kmsKey: kms.Key = bp.getNamedResource(KMS_RESOURCE);
const builder = () => base.clone();
const publicCluster = {
version: KubernetesVersion.V1_30,
vpcSubnets: [{ subnetType: ec2.SubnetType.PUBLIC }]
};
builder()
.clusterProvider(new bp.FargateClusterProvider(publicCluster))
.build(app, "fargate-blueprint");
builder()
.clusterProvider(new bp.MngClusterProvider({
...publicCluster
}))
.addOns(new bp.addons.VpcCniAddOn())
.enableControlPlaneLogTypes(bp.ControlPlaneLogType.API, bp.ControlPlaneLogType.AUDIT)
.build(app, "mng-blueprint");
builder()
.clusterProvider(new bp.MngClusterProvider(publicCluster))
.addOns(buildArgoBootstrap())
.build(app, 'argo-blueprint1');
// New blueprint with IngressNginxAddOn
builder()
.clusterProvider(new bp.MngClusterProvider(publicCluster))
.addOns(
new AwsLoadBalancerControllerAddOn(),
new IngressNginxAddOn({
crossZoneEnabled: true,
internetFacing: true,
targetType: 'ip'
})
)
.build(app, 'ingress-nginx-blueprint');
bp.EksBlueprint.builder()
.account(process.env.CDK_DEFAULT_ACCOUNT)
.region(process.env.CDK_DEFAULT_REGION)
.version(KubernetesVersion.V1_29)
.compatibilityMode(false)
.build(app, 'eks-blueprint');
function buildArgoBootstrap() {
return new bp.addons.ArgoCDAddOn({
bootstrapRepo: {
repoUrl: 'https://github.com/aws-samples/eks-blueprints-add-ons.git',
path: 'chart',
targetRevision: "eks-blueprints-cdk",
},
bootstrapValues: {
spec: {
kmsKey: kmsKey.keyArn
}
},
workloadApplications: [
{
name: "micro-services",
namespace: "argocd",
repository: {
repoUrl: 'https://github.com/aws-samples/eks-blueprints-workloads.git',
path: 'envs/dev',
targetRevision: "main",
},
values: {
domain: ""
}
}
],
values: {
configs: {
secret: {
argocdServerAdminPassword: bcrypt.hash("argopwd1", 10)
}
}
}
});
}