forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fargate-cluster.ts
49 lines (45 loc) · 1.52 KB
/
fargate-cluster.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
import { Construct } from 'constructs';
import { Cluster, ClusterOptions, CoreDnsComputeType } from './cluster';
import { FargateProfile, FargateProfileOptions } from './fargate-profile';
/**
* Configuration props for EKS Fargate.
*/
export interface FargateClusterProps extends ClusterOptions {
/**
* Fargate Profile to create along with the cluster.
*
* @default - A profile called "default" with 'default' and 'kube-system'
* selectors will be created if this is left undefined.
*/
readonly defaultProfile?: FargateProfileOptions;
}
/**
* Defines an EKS cluster that runs entirely on AWS Fargate.
*
* The cluster is created with a default Fargate Profile that matches the
* "default" and "kube-system" namespaces. You can add additional profiles using
* `addFargateProfile`.
*/
export class FargateCluster extends Cluster {
/**
* Fargate Profile that was created with the cluster.
*/
public readonly defaultProfile: FargateProfile;
constructor(scope: Construct, id: string, props: FargateClusterProps) {
super(scope, id, {
...props,
defaultCapacity: 0,
coreDnsComputeType: props.coreDnsComputeType ?? CoreDnsComputeType.FARGATE,
version: props.version,
});
this.defaultProfile = this.addFargateProfile(
props.defaultProfile?.fargateProfileName ?? (props.defaultProfile ? 'custom' : 'default'),
props.defaultProfile ?? {
selectors: [
{ namespace: 'default' },
{ namespace: 'kube-system' },
],
},
);
}
}