-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
163 lines (153 loc) · 5.04 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import * as k8s from "@pulumi/kubernetes";
import * as pulumi from "@pulumi/pulumi";
import * as fs from "fs";
let config = new pulumi.Config();
const replicas = config.getNumber("replicas") || 3;
const serviceType = config.get("serviceType") || "NodePort"; // or use LoadBalancer
const labels = { app: "ignite" };
const namespace = new k8s.core.v1.Namespace("ignite", {
metadata: {
name: "ignite"
}
});
const service = new k8s.core.v1.Service("ignite-service", {
metadata: {
name: "ignite-service",
namespace: namespace.metadata.name,
labels: labels
},
spec:
{
type: serviceType,
ports: [
{name: "rest", port: 8080, targetPort: 8080},
{name: "thin", port: 10800, targetPort: 10800}
],
// use ClientIP if client are deployed in Kubernetes
// sessionAffinity: "ClientIP",
selector: labels
}
});
const serviceAccount = new k8s.core.v1.ServiceAccount("ignite", {
metadata: {
namespace: namespace.metadata.name
}
});
const clusterRole = new k8s.rbac.v1.ClusterRole("ignite", {
metadata: {
namespace: namespace.metadata.name
},
rules: [{
apiGroups: [""],
resources: ["pods", "endpoints"],
verbs: ["get", "list", "watch"]
}]
});
const clusterRoleBinding = new k8s.rbac.v1.ClusterRoleBinding("ignite", {
metadata: {
namespace: namespace.metadata.name
},
roleRef: {
kind: "ClusterRole",
apiGroup: "rbac.authorization.k8s.io",
name: clusterRole.metadata.name
},
subjects: [{
kind: "ServiceAccount",
name: serviceAccount.metadata.name,
namespace: namespace.metadata.name
}]
});
const configMap = new k8s.core.v1.ConfigMap("ignite-config", {
metadata: {
namespace: namespace.metadata.name
},
data: {
"ignite-configuration.xml": fs.readFileSync("ignite-configuration.xml").toString()
}
});
const statefulSet = new k8s.apps.v1.StatefulSet("ignite-custer", {
metadata: {
namespace: namespace.metadata.name
},
spec: {
replicas: replicas,
serviceName: "ignite",
selector: {matchLabels: labels},
template: {
metadata: {
labels: labels
},
spec: {
serviceAccountName: serviceAccount.metadata.name,
terminationGracePeriodSeconds: 60000,
containers: [{
name: "ignite-node",
image: "apacheignite/ignite:2.9.0",
env: [
{ name: "OPTION_LIBS", value: "ignite-kubernetes,ignite-rest-http" },
{ name: "CONFIG_URI", value: "file:///ignite/config/ignite-configuration.xml" },
{ name: "JVM_OPTS", value: "-DIGNITE_WAL_MMAP=false" }
],
ports: [
{ containerPort: 47100 }, // communication SPI port
{ containerPort: 47500 }, // discovery SPI port
{ containerPort: 49112 }, // JMX port
{ containerPort: 10800 }, // thin clients/JDBC driver port
{ containerPort: 8080 } // REST API
],
volumeMounts: [
{ name: "config-vol", mountPath: "/ignite/config" },
{ name: "work-vol", mountPath: "/ignite/work" },
{ name: "wal-vol", mountPath: "/ignite/wal" },
{ name: "walarchive-vol", mountPath: "/ignite/walarchive" }
]
}],
securityContext: {
// try removing this if you have permission issues
fsGroup: 2000
},
volumes: [{
name: "config-vol",
configMap: { name: configMap.metadata.name }
}]
}
},
volumeClaimTemplates: [
{
metadata: { name: "work-vol" },
spec: {
accessModes: [ "ReadWriteOnce" ],
resources: {
requests: {
storage: "1Gi"
}
}
}
},
{
metadata: { name: "wal-vol" },
spec: {
accessModes: [ "ReadWriteOnce" ],
resources: {
requests: {
storage: "1Gi"
}
}
}
},
{
metadata: { name: "walarchive-vol" },
spec: {
accessModes: [ "ReadWriteOnce" ],
resources: {
requests: {
storage: "1Gi"
}
}
}
}
]
}
});
export const clusterName = statefulSet.metadata.name;