-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
62 lines (55 loc) · 1.45 KB
/
main.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
import { Construct } from "constructs";
import { App, Chart, ChartProps } from "cdk8s";
import { KubeService, IntOrString, KubeDeployment } from "./imports/k8s";
export class MyChart extends Chart {
constructor(scope: Construct, id: string, props: ChartProps = {}) {
super(scope, id, props);
// define resources here
//Create Label
const label = { app: "hello-k8s" };
//Create Service
new KubeService(this, "service", {
spec: {
type: "LoadBalancer",
ports: [
{
port: 80,
targetPort: IntOrString.fromNumber(8080),
},
],
selector: label,
},
});
//Create Deployment
new KubeDeployment(this, "deployment", {
spec: {
replicas: 1,
selector: {
matchLabels: label,
},
template: {
metadata: { labels: label },
spec: {
containers: [
{
name: "hello-kubernetes",
image: "paulbouwer/hello-kubernetes:1.8",
ports: [{ containerPort: 8080 }],
env: [
{
name: "MESSAGE",
value:
"I just deployed this on AWS EKS using CDK for Kubernetes",
},
],
},
],
},
},
},
});
}
}
const app = new App();
new MyChart(app, "aws-cdk8s-demo");
app.synth();