-
Notifications
You must be signed in to change notification settings - Fork 82
/
index.ts
104 lines (91 loc) · 2.83 KB
/
index.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
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
import * as eks from "@pulumi/eks";
const projectName = pulumi.getProject();
// Create an EKS cluster with a non-default configuration.
const vpc = new awsx.ec2.Vpc(`${projectName}-2`, {
tags: { Name: `${projectName}-2` },
});
////////////////////////////
/// EKS Clusters ///
////////////////////////////
// Create an EKS cluster with the default configuration.
const cluster1 = new eks.Cluster(`${projectName}-1`, {
nodeAmiId: "ami-066e69f6f03b5383e",
});
export const defaultAsgName: pulumi.Output<string> = cluster1.defaultNodeGroupAsgName;
const cluster2 = new eks.Cluster(`${projectName}-2`, {
vpcId: vpc.vpcId,
publicSubnetIds: vpc.publicSubnetIds,
desiredCapacity: 2,
minSize: 2,
maxSize: 2,
nodeAmiId: "ami-066e69f6f03b5383e",
enabledClusterLogTypes: [
"api",
"audit",
"authenticator",
],
vpcCniOptions: {
disableTcpEarlyDemux: true,
},
});
const cluster3 = new eks.Cluster(`${projectName}-3`, {
vpcId: vpc.vpcId,
publicSubnetIds: vpc.publicSubnetIds,
corednsAddonOptions: {
enabled: false,
},
nodeGroupOptions: {
amiId: "ami-066e69f6f03b5383e",
desiredCapacity: 1,
minSize: 1,
maxSize: 1,
instanceType: pulumi.output(Promise.resolve("t3.small")),
enableDetailedMonitoring: false,
}
})
// cluster4 is a graviton cluster to test the ARM64 architecture
// can be successfully provisioned.
const cluster4 = new eks.Cluster(`${projectName}-4`, {
vpcId: vpc.vpcId,
publicSubnetIds: vpc.publicSubnetIds,
nodeAmiId: "ami-08f46bde01e01db75",
instanceType: "t4g.small",
})
//////////////////////////
/// EKS Addons ///
//////////////////////////
const corednsVersion = aws.eks.getAddonVersionOutput({
addonName: "coredns",
kubernetesVersion: cluster3.eksCluster.version,
mostRecent: true,
});
// Test that we can create a coredns addon within cluster3.
const coredns = new eks.Addon("coredns", {
cluster: cluster3,
addonName: "coredns",
addonVersion: corednsVersion.version,
resolveConflictsOnUpdate: "PRESERVE",
configurationValues: {
replicaCount: 4,
resources: {
limits: {
cpu: "100m",
memory: "150Mi",
},
requests: {
cpu: "100m",
memory: "150Mi",
},
},
},
});
// Export the clusters' kubeconfig.
export const kubeconfig1: pulumi.Output<any> = cluster1.kubeconfig;
export const kubeconfig2: pulumi.Output<any> = cluster2.kubeconfig;
export const kubeconfig3: pulumi.Output<any> = cluster3.kubeconfig;
export const kubeconfig4: pulumi.Output<any> = cluster4.kubeconfig;
// export the IAM Role ARN of the cluster
export const iamRoleArn: pulumi.Output<string> = cluster1.core.clusterIamRole.arn;