blob: 2ba604029525cd66ec2ca2ca687b7eb5e9888941 [file] [log] [blame]
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +02001// k0.hswaw.net kubernetes cluster
2// This defines the cluster as a single object.
3// Use the sibling k0*.jsonnet 'view' files to actually apply the configuration.
4
5local kube = import "../../kube/kube.libsonnet";
6local policies = import "../../kube/policies.libsonnet";
7
8local cluster = import "cluster.libsonnet";
9
Serge Bazanski3c5d8362021-02-06 17:27:02 +000010local admitomatic = import "lib/admitomatic.libsonnet";
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +020011local cockroachdb = import "lib/cockroachdb.libsonnet";
12local registry = import "lib/registry.libsonnet";
13local rook = import "lib/rook.libsonnet";
14
15{
16 k0: {
17 local k0 = self,
18 cluster: cluster.Cluster("k0", "hswaw.net") {
19 cfg+: {
Serge Bazanski3d294842020-08-04 01:34:07 +020020 storageClassNameParanoid: k0.ceph.waw3Pools.blockRedundant.name,
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +020021 },
22 metallb+: {
23 cfg+: {
Serge Bazanskia5ed6442020-09-20 22:52:57 +000024 // Peer with calico running on same node.
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +020025 peers: [
26 {
Serge Bazanskia5ed6442020-09-20 22:52:57 +000027 "peer-address": "127.0.0.1",
28 "peer-asn": 65003,
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +020029 "my-asn": 65002,
30 },
31 ],
Serge Bazanskia5ed6442020-09-20 22:52:57 +000032 // Public IP address pools. Keep in sync with k0.calico.yaml.
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +020033 addressPools: [
34 {
35 name: "public-v4-1",
36 protocol: "bgp",
37 addresses: [
38 "185.236.240.48/28",
39 ],
40 },
41 {
42 name: "public-v4-2",
43 protocol: "bgp",
44 addresses: [
45 "185.236.240.112/28"
46 ],
47 },
48 ],
49 },
50 },
51 },
52
53 // Docker registry
54 registry: registry.Environment {
55 cfg+: {
56 domain: "registry.%s" % [k0.cluster.fqdn],
57 storageClassName: k0.cluster.cfg.storageClassNameParanoid,
Serge Bazanski3d294842020-08-04 01:34:07 +020058 objectStorageName: "waw-hdd-redundant-3-object",
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +020059 },
60 },
61
62 // CockroachDB, running on bc01n{01,02,03}.
63 cockroach: {
64 waw2: cockroachdb.Cluster("crdb-waw1") {
65 cfg+: {
66 topology: [
67 { name: "bc01n01", node: "bc01n01.hswaw.net" },
68 { name: "bc01n02", node: "bc01n02.hswaw.net" },
Patryk Jakuszewedf14cc2021-01-23 23:00:29 +010069 { name: "dcr01s22", node: "dcr01s22.hswaw.net" },
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +020070 ],
71 // Host path on SSD.
72 hostPath: "/var/db/crdb-waw1",
Serge Bazanski509ab6e2020-07-30 22:43:20 +020073 extraDNS: [
74 "crdb-waw1.hswaw.net",
75 ],
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +020076 },
77 },
78 clients: {
79 cccampix: k0.cockroach.waw2.Client("cccampix"),
80 cccampixDev: k0.cockroach.waw2.Client("cccampix-dev"),
81 buglessDev: k0.cockroach.waw2.Client("bugless-dev"),
82 sso: k0.cockroach.waw2.Client("sso"),
Serge Bazanski509ab6e2020-07-30 22:43:20 +020083 herpDev: k0.cockroach.waw2.Client("herp-dev"),
Patryk Jakuszewf3153882021-01-23 15:38:50 +010084 gitea: k0.cockroach.waw2.Client("gitea"),
Piotr Dobrowolskif4a6a562021-02-01 21:32:25 +010085 issues: k0.cockroach.waw2.Client("issues"),
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +020086 },
87 },
88
89 ceph: {
90 // waw1 cluster - dead as of 2019/08/06, data corruption
Serge Bazanski61f978a2021-01-22 16:26:07 +010091 // waw2 cluster - dead as of 2021/01/22, torn down (horrible M610 RAID controllers are horrible)
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +020092
93 // waw3: 6TB SAS 3.5" HDDs
94 waw3: rook.Cluster(k0.cluster.rook, "ceph-waw3") {
95 spec: {
96 mon: {
Serge Bazanskicf842b02021-01-19 20:08:23 +010097 count: 1,
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +020098 allowMultiplePerNode: false,
99 },
Serge Bazanski793ca1b2021-03-07 00:07:19 +0000100 resources: {
101 osd: {
102 requests: {
103 cpu: "2"
104 memory: "6G"
105 },
106 limits: {
107 cpu: "2"
108 memory: "8G"
109 },
110 },
111
112 },
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200113 storage: {
114 useAllNodes: false,
115 useAllDevices: false,
116 config: {
117 databaseSizeMB: "1024",
118 journalSizeMB: "1024",
119 },
120 nodes: [
121 {
122 name: "dcr01s22.hswaw.net",
123 location: "rack=dcr01 host=dcr01s22",
124 devices: [
125 // https://github.com/rook/rook/issues/1228
126 //{ name: "disk/by-id/wwan-0x" + wwan }
127 //for wwan in [
128 // "5000c5008508c433",
129 // "5000c500850989cf",
130 // "5000c5008508f843",
131 // "5000c5008508baf7",
132 //]
133 { name: "sdn" },
134 { name: "sda" },
135 { name: "sdb" },
136 { name: "sdc" },
137 ],
138 },
139 {
140 name: "dcr01s24.hswaw.net",
141 location: "rack=dcr01 host=dcr01s22",
142 devices: [
143 // https://github.com/rook/rook/issues/1228
144 //{ name: "disk/by-id/wwan-0x" + wwan }
145 //for wwan in [
146 // "5000c5008508ee03",
147 // "5000c5008508c9ef",
148 // "5000c5008508df33",
149 // "5000c5008508dd3b",
150 //]
151 { name: "sdm" },
152 { name: "sda" },
153 { name: "sdb" },
154 { name: "sdc" },
155 ],
156 },
157 ],
158 },
159 benji:: {
160 metadataStorageClass: "waw-hdd-redundant-3",
161 encryptionPassword: std.split((importstr "../secrets/plain/k0-benji-encryption-password"), '\n')[0],
162 pools: [
163 "waw-hdd-redundant-3",
164 "waw-hdd-redundant-3-metadata",
165 "waw-hdd-yolo-3",
166 ],
167 s3Configuration: {
168 awsAccessKeyId: "RPYZIROFXNLQVU2WJ4R3",
169 awsSecretAccessKey: std.split((importstr "../secrets/plain/k0-benji-secret-access-key"), '\n')[0],
170 bucketName: "benji-k0-backups-waw3",
171 endpointUrl: "https://s3.eu-central-1.wasabisys.com/",
172 },
173 }
174 },
175 },
176 waw3Pools: {
177 // redundant block storage
178 blockRedundant: rook.ECBlockPool(k0.ceph.waw3, "waw-hdd-redundant-3") {
179 metadataReplicas: 2,
180 spec: {
181 failureDomain: "host",
182 replicated: {
183 size: 2,
184 },
185 },
186 },
187 // yolo block storage (low usage, no host redundancy)
188 blockYolo: rook.ReplicatedBlockPool(k0.ceph.waw3, "waw-hdd-yolo-3") {
189 spec: {
190 failureDomain: "osd",
191 erasureCoded: {
Serge Bazanskicf842b02021-01-19 20:08:23 +0100192 dataChunks: 2,
193 codingChunks: 1,
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200194 },
195 },
196 },
Serge Bazanski242ec582020-09-20 15:36:11 +0000197 // q3k's personal pool, used externally from k8s.
198 q3kRedundant: rook.ECBlockPool(k0.ceph.waw3, "waw-hdd-redundant-q3k-3") {
199 metadataReplicas: 2,
200 spec: {
201 failureDomain: "host",
202 replicated: {
203 size: 2,
204 },
205 },
206 },
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200207 objectRedundant: rook.S3ObjectStore(k0.ceph.waw3, "waw-hdd-redundant-3-object") {
208 spec: {
209 metadataPool: {
210 failureDomain: "host",
211 replicated: { size: 2 },
212 },
213 dataPool: {
214 failureDomain: "host",
215 replicated: { size: 2 },
216 },
217 },
218 },
219 },
220
221 // Clients for S3/radosgw storage.
222 clients: {
223 # Used for owncloud.hackerspace.pl, which for now lives on boston-packets.hackerspace.pl.
224 nextcloudWaw3: kube.CephObjectStoreUser("nextcloud") {
225 metadata+: {
226 namespace: "ceph-waw3",
227 },
228 spec: {
229 store: "waw-hdd-redundant-3-object",
230 displayName: "nextcloud",
231 },
232 },
Piotr Dobrowolski3b8a43f2021-02-01 21:19:48 +0100233 # issues.hackerspace.pl (redmine) attachments bucket
234 issuesWaw3: kube.CephObjectStoreUser("issues") {
235 metadata+: {
236 namespace: "ceph-waw3",
237 },
238 spec: {
239 store: "waw-hdd-redundant-3-object",
240 displayName: "issues",
241 },
242 },
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200243
244 # nuke@hackerspace.pl's personal storage.
245 nukePersonalWaw3: kube.CephObjectStoreUser("nuke-personal") {
246 metadata+: {
247 namespace: "ceph-waw3",
248 },
249 spec: {
250 store: "waw-hdd-redundant-3-object",
251 displayName: "nuke-personal",
252 },
253 },
254
255 # patryk@hackerspace.pl's ArmA3 mod bucket.
256 cz2ArmaModsWaw3: kube.CephObjectStoreUser("cz2-arma3mods") {
257 metadata+: {
258 namespace: "ceph-waw3",
259 },
260 spec: {
261 store: "waw-hdd-redundant-3-object",
262 displayName: "cz2-arma3mods",
263 },
264 },
Bartosz Stebeld9df5872020-06-13 21:19:40 +0200265 # Buckets for spark pipelines
266 # TODO(implr): consider a second yolo-backed one for temp data
267 implrSparkWaw3: kube.CephObjectStoreUser("implr-spark") {
268 metadata+: {
269 namespace: "ceph-waw3",
270 },
271 spec: {
272 store: "waw-hdd-redundant-3-object",
273 displayName: "implr-spark",
274 },
275 },
Sergiusz Bazanskib1aadd82020-06-24 19:06:17 +0200276 # q3k's personal user
277 q3kWaw3: kube.CephObjectStoreUser("q3k") {
278 metadata+: {
279 namespace: "ceph-waw3",
280 },
281 spec: {
282 store: "waw-hdd-redundant-3-object",
283 displayName: "q3k",
284 },
285 },
Serge Bazanskibfe9bb02020-10-27 20:50:50 +0100286 # woju's personal user
287 wojuWaw3: kube.CephObjectStoreUser("woju") {
288 metadata+: {
289 namespace: "ceph-waw3",
290 },
291 spec: {
292 store: "waw-hdd-redundant-3-object",
293 displayName: "woju",
294 },
Patryk Jakuszewcae7cf72020-11-28 14:36:48 +0100295 },
Patryk Jakuszew34668a52020-11-28 13:45:25 +0100296 # cz3's (patryk@hackerspace.pl) personal user
297 cz3Waw3: kube.CephObjectStoreUser("cz3") {
298 metadata+: {
299 namespace: "ceph-waw3",
300 },
301 spec: {
302 store: "waw-hdd-redundant-3-object",
303 displayName: "cz3",
304 },
Serge Bazanskibfe9bb02020-10-27 20:50:50 +0100305 },
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200306 },
307 },
308
309
310 # These are policies allowing for Insecure pods in some namespaces.
311 # A lot of them are spurious and come from the fact that we deployed
312 # these namespaces before we deployed the draconian PodSecurityPolicy
313 # we have now. This should be fixed by setting up some more granular
314 # policies, or fixing the workloads to not need some of the permission
315 # bits they use, whatever those might be.
316 # TODO(q3k): fix this?
317 unnecessarilyInsecureNamespaces: [
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200318 policies.AllowNamespaceInsecure("ceph-waw3"),
319 policies.AllowNamespaceInsecure("matrix"),
320 policies.AllowNamespaceInsecure("registry"),
321 policies.AllowNamespaceInsecure("internet"),
322 # TODO(implr): restricted policy with CAP_NET_ADMIN and tuntap, but no full root
323 policies.AllowNamespaceInsecure("implr-vpn"),
324 ],
Serge Bazanski3c5d8362021-02-06 17:27:02 +0000325
326 # Admission controller that permits non-privileged users to manage
327 # their namespaces without danger of hijacking important URLs.
328 admitomatic: admitomatic.Environment {
329 cfg+: {
330 proto: {
331 // Domains allowed in given namespaces. If a domain exists
332 // anywhere, ingresses will only be permitted to be created
333 // within namespaces in which it appears here. This works
334 // the same way for wildcards, if a wildcard exists in this
335 // list it blocks all unauthorized uses of that domain
336 // elsewhere.
337 //
338 // See //cluster/admitomatic for more information.
339 //
340 // Or, tl;dr:
341 //
342 // If you do a wildcard CNAME onto the k0 ingress, you
343 // should explicitly state *.your.name.com here.
344 //
345 // If you just want to protect your host from being
346 // hijacked by other cluster users, you should also state
347 // it here (either as a wildcard, or unary domains).
348 allow_domain: [
349 { namespace: "covid-formity", dns: "covid19.hackerspace.pl" },
350 { namespace: "covid-formity", dns: "covid.hackerspace.pl" },
351 { namespace: "covid-formity", dns: "www.covid.hackerspace.pl" },
352 { namespace: "devtools-prod", dns: "hackdoc.hackerspace.pl" },
353 { namespace: "devtools-prod", dns: "cs.hackerspace.pl" },
354 { namespace: "engelsystem-prod", dns: "engelsystem.hackerspace.pl" },
355 { namespace: "gerrit", dns: "gerrit.hackerspace.pl" },
356 { namespace: "gitea-prod", dns: "gitea.hackerspace.pl" },
357 { namespace: "hswaw-prod", dns: "*.hackerspace.pl" },
358 { namespace: "internet", dns: "internet.hackerspace.pl" },
359 { namespace: "matrix", dns: "matrix.hackerspace.pl" },
360 { namespace: "onlyoffice-prod", dns: "office.hackerspace.pl" },
361 { namespace: "redmine", dns: "issues.hackerspace.pl" },
Serge Bazanski877cf0a2021-02-08 00:34:34 +0100362 { namespace: "redmine", dns: "b.hackerspace.pl" },
363 { namespace: "redmine", dns: "b.hswaw.net" },
364 { namespace: "redmine", dns: "xn--137h.hackerspace.pl" },
365 { namespace: "redmine", dns: "xn--137h.hswaw.net" },
Serge Bazanski3c5d8362021-02-06 17:27:02 +0000366 { namespace: "speedtest", dns: "speedtest.hackerspace.pl" },
367 { namespace: "sso", dns: "sso.hackerspace.pl" },
368
369 { namespace: "ceph-waw3", dns: "ceph-waw3.hswaw.net" },
370 { namespace: "ceph-waw3", dns: "object.ceph-waw3.hswaw.net" },
371 { namespace: "monitoring-global-k0", dns: "*.hswaw.net" },
372 { namespace: "registry", dns: "*.hswaw.net" },
373
374 // q3k's legacy namespace (pre-prodvider)
375 { namespace: "q3k", dns: "*.q3k.org" },
376 { namespace: "personal-q3k", dns: "*.q3k.org" },
377 ],
378 },
379 },
380 },
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200381 },
382}