-
Notifications
You must be signed in to change notification settings - Fork 18
/
gitpod.ts
56 lines (43 loc) · 2.05 KB
/
gitpod.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
import {
Construct,
Stack,
StackProps
} from '@aws-cdk/core';
import { KubernetesManifest } from '@aws-cdk/aws-eks';
import { readYamlDocument, loadYaml } from './charts/utils';
import { importCluster } from './charts/cluster-utils';
export interface GitpodProps extends StackProps {
domain: string
certificateArn?: string
}
export class GitpodStack extends Stack {
constructor(scope: Construct, id: string, props: GitpodProps) {
super(scope, id, props);
const cluster = importCluster(this, process.env.CLUSTER_NAME);
const doc = readYamlDocument(__dirname + '/charts/assets/ingress.yaml');
const manifest = loadYaml(doc) as any;
// configure TLS termination in the load balancer
if (props.certificateArn) {
manifest.metadata.annotations["alb.ingress.kubernetes.io/certificate-arn"] = props.certificateArn;
manifest.metadata.annotations["alb.ingress.kubernetes.io/ssl-policy"] = "ELBSecurityPolicy-FS-1-2-Res-2020-10";
}
manifest.metadata.annotations["alb.ingress.kubernetes.io/load-balancer-name"] = `${process.env.CLUSTER_NAME}-${props.env?.region}`;
// if we have a route53 zone ID, enable external-dns.
if (process.env.ROUTE53_ZONEID) {
manifest.metadata.annotations["external-dns.alpha.kubernetes.io/hostname"] = `${props.domain}, *.${props.domain}, *.ws.${props.domain}`;
}
if (process.env.USE_INTERNAL_ALB && process.env.USE_INTERNAL_ALB.toLowerCase() === 'true') {
manifest.metadata.annotations["alb.ingress.kubernetes.io/scheme"] = 'internal';
} else {
manifest.metadata.annotations["alb.ingress.kubernetes.io/scheme"] = 'internet-facing';
}
if (process.env.ALB_SUBNETS) {
manifest.metadata.annotations["alb.ingress.kubernetes.io/subnets"] = `${process.env.ALB_SUBNETS}`;
}
const gitpodIngress = new KubernetesManifest(this, "gitpod-ingress", {
cluster,
overwrite: true,
manifest: [manifest],
});
}
}