blob: fd9e2d1f3bc5bfed0cebf8031e4588e72945b30a [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: [
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +020067 { name: "bc01n02", node: "bc01n02.hswaw.net" },
Patryk Jakuszewedf14cc2021-01-23 23:00:29 +010068 { name: "dcr01s22", node: "dcr01s22.hswaw.net" },
Serge Bazanskibdd403c2021-10-28 23:37:38 +000069 { name: "dcr01s24", node: "dcr01s24.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 },
Serge Bazanskibdd403c2021-10-28 23:37:38 +000077 initJob:: null,
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +020078 },
79 clients: {
80 cccampix: k0.cockroach.waw2.Client("cccampix"),
81 cccampixDev: k0.cockroach.waw2.Client("cccampix-dev"),
82 buglessDev: k0.cockroach.waw2.Client("bugless-dev"),
83 sso: k0.cockroach.waw2.Client("sso"),
Serge Bazanski509ab6e2020-07-30 22:43:20 +020084 herpDev: k0.cockroach.waw2.Client("herp-dev"),
Patryk Jakuszewf3153882021-01-23 15:38:50 +010085 gitea: k0.cockroach.waw2.Client("gitea"),
Piotr Dobrowolskif4a6a562021-02-01 21:32:25 +010086 issues: k0.cockroach.waw2.Client("issues"),
Serge Bazanskibf266c62021-03-17 21:48:58 +000087 dns: k0.cockroach.waw2.Client("dns"),
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +020088 },
89 },
90
91 ceph: {
92 // waw1 cluster - dead as of 2019/08/06, data corruption
Serge Bazanski61f978a2021-01-22 16:26:07 +010093 // waw2 cluster - dead as of 2021/01/22, torn down (horrible M610 RAID controllers are horrible)
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +020094
Serge Bazanski464fb042021-09-11 20:24:27 +000095 // waw3: 6TB SAS 3.5" HDDs, internal Rook cluster.
96 //
97 // Suffers from rook going apeshit and nuking all mons if enough of
98 // a control plane is up for rook to run but if nodes are
99 // unavailable to the point of it deciding that no mon exists and
100 // it should create some new ones, fully nuking the monmap and
101 // making recovery a pain.
102 //
103 // Supposedly new versions of Rook slowly fix these issues, but q3k
104 // doesn't personally trust this codebase anymore. He'd rather
105 // manage the actual Ceph cluster myself, we don't need all of this
106 // magic.
107 //
108 // See: b.hswaw.net/6
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200109 waw3: rook.Cluster(k0.cluster.rook, "ceph-waw3") {
110 spec: {
111 mon: {
Serge Bazanski16842112022-11-17 19:30:05 +0000112 count: 3,
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200113 allowMultiplePerNode: false,
114 },
Serge Bazanski793ca1b2021-03-07 00:07:19 +0000115 resources: {
116 osd: {
117 requests: {
Serge Bazanski64de7af2021-03-17 21:47:29 +0000118 cpu: "2",
119 memory: "6G",
Serge Bazanski793ca1b2021-03-07 00:07:19 +0000120 },
121 limits: {
Serge Bazanski64de7af2021-03-17 21:47:29 +0000122 cpu: "2",
123 memory: "8G",
Serge Bazanski793ca1b2021-03-07 00:07:19 +0000124 },
125 },
126
127 },
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200128 storage: {
129 useAllNodes: false,
130 useAllDevices: false,
131 config: {
132 databaseSizeMB: "1024",
133 journalSizeMB: "1024",
134 },
Serge Bazanski464fb042021-09-11 20:24:27 +0000135
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200136 nodes: [
137 {
138 name: "dcr01s22.hswaw.net",
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200139 devices: [
Serge Bazanski464fb042021-09-11 20:24:27 +0000140 { name: "/dev/disk/by-id/wwn-0x" + id }
141 for id in [
142 "5000c5008508c433",
143 "5000c500850989cf",
Serge Bazanski464fb042021-09-11 20:24:27 +0000144 "5000c5008508baf7",
145 ]
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200146 ],
147 },
148 {
149 name: "dcr01s24.hswaw.net",
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200150 devices: [
Serge Bazanski464fb042021-09-11 20:24:27 +0000151 { name: "/dev/disk/by-id/wwn-0x" + id }
152 for id in [
Serge Bazanski464fb042021-09-11 20:24:27 +0000153 "5000c5008508c9ef",
154 "5000c5008508df33",
155 "5000c5008508dd3b",
156 ]
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200157 ],
158 },
159 ],
160 },
161 benji:: {
162 metadataStorageClass: "waw-hdd-redundant-3",
163 encryptionPassword: std.split((importstr "../secrets/plain/k0-benji-encryption-password"), '\n')[0],
164 pools: [
165 "waw-hdd-redundant-3",
166 "waw-hdd-redundant-3-metadata",
167 "waw-hdd-yolo-3",
168 ],
169 s3Configuration: {
170 awsAccessKeyId: "RPYZIROFXNLQVU2WJ4R3",
171 awsSecretAccessKey: std.split((importstr "../secrets/plain/k0-benji-secret-access-key"), '\n')[0],
172 bucketName: "benji-k0-backups-waw3",
173 endpointUrl: "https://s3.eu-central-1.wasabisys.com/",
174 },
175 }
176 },
177 },
178 waw3Pools: {
179 // redundant block storage
180 blockRedundant: rook.ECBlockPool(k0.ceph.waw3, "waw-hdd-redundant-3") {
181 metadataReplicas: 2,
182 spec: {
183 failureDomain: "host",
184 replicated: {
185 size: 2,
186 },
187 },
188 },
189 // yolo block storage (low usage, no host redundancy)
190 blockYolo: rook.ReplicatedBlockPool(k0.ceph.waw3, "waw-hdd-yolo-3") {
191 spec: {
192 failureDomain: "osd",
193 erasureCoded: {
Serge Bazanskicf842b02021-01-19 20:08:23 +0100194 dataChunks: 2,
195 codingChunks: 1,
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200196 },
197 },
198 },
Serge Bazanski242ec582020-09-20 15:36:11 +0000199 // q3k's personal pool, used externally from k8s.
200 q3kRedundant: rook.ECBlockPool(k0.ceph.waw3, "waw-hdd-redundant-q3k-3") {
201 metadataReplicas: 2,
202 spec: {
203 failureDomain: "host",
204 replicated: {
205 size: 2,
206 },
207 },
208 },
Serge Bazanski38f72fe2021-09-13 23:43:47 +0000209
210 object: {
211 local poolSpec = {
212 failureDomain: "host",
213 replicated: { size: 2 },
214 },
215
216 realm: rook.S3ObjectRealm(k0.ceph.waw3, "hscloud"),
217 zonegroup: rook.S3ObjectZoneGroup(self.realm, "eu"),
218 // This is serving at object.ceph-waw3.hswaw.net, but
219 // internally to Ceph it is known as
220 // waw-hdd-redundant-3-object (name of radosgw zone).
221 store: rook.S3ObjectStore(self.zonegroup, "waw-hdd-redundant-3-object") {
222 cfg+: {
223 // Override so that this radosgw serves on
224 // object.ceph-{waw3,eu}.hswaw.net instead of
225 // ceph-{waw-hdd-redundant-3-object,eu}.
226 domainParts: [
227 "waw3", "eu",
228 ],
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200229 },
Serge Bazanski38f72fe2021-09-13 23:43:47 +0000230 spec: {
231 metadataPool: poolSpec,
232 dataPool: poolSpec,
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200233 },
234 },
235 },
236 },
237
238 // Clients for S3/radosgw storage.
239 clients: {
240 # Used for owncloud.hackerspace.pl, which for now lives on boston-packets.hackerspace.pl.
241 nextcloudWaw3: kube.CephObjectStoreUser("nextcloud") {
242 metadata+: {
243 namespace: "ceph-waw3",
244 },
245 spec: {
246 store: "waw-hdd-redundant-3-object",
247 displayName: "nextcloud",
248 },
249 },
Piotr Dobrowolski3b8a43f2021-02-01 21:19:48 +0100250 # issues.hackerspace.pl (redmine) attachments bucket
251 issuesWaw3: kube.CephObjectStoreUser("issues") {
252 metadata+: {
253 namespace: "ceph-waw3",
254 },
255 spec: {
256 store: "waw-hdd-redundant-3-object",
257 displayName: "issues",
258 },
259 },
Piotr Dobrowolskie839f952021-09-14 22:21:22 +0200260 # matrix.hackerspace.pl media storage bucket
261 matrixWaw3: kube.CephObjectStoreUser("matrix") {
262 metadata+: {
263 namespace: "ceph-waw3",
264 },
265 spec: {
266 store: "waw-hdd-redundant-3-object",
267 displayName: "matrix",
268 },
269 },
Bartosz Stebel54a34b22022-03-05 23:20:56 +0100270 # tape staging temporary storage
271 tapeStaging: kube.CephObjectStoreUser("tape-staging") {
272 metadata+: {
273 namespace: "ceph-waw3",
274 },
275 spec: {
276 store: "waw-hdd-redundant-3-object",
277 displayName: "tape-staging",
278 },
279 },
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200280
281 # nuke@hackerspace.pl's personal storage.
282 nukePersonalWaw3: kube.CephObjectStoreUser("nuke-personal") {
283 metadata+: {
284 namespace: "ceph-waw3",
285 },
286 spec: {
287 store: "waw-hdd-redundant-3-object",
288 displayName: "nuke-personal",
289 },
290 },
291
292 # patryk@hackerspace.pl's ArmA3 mod bucket.
293 cz2ArmaModsWaw3: kube.CephObjectStoreUser("cz2-arma3mods") {
294 metadata+: {
295 namespace: "ceph-waw3",
296 },
297 spec: {
298 store: "waw-hdd-redundant-3-object",
299 displayName: "cz2-arma3mods",
300 },
301 },
Bartosz Stebeld9df5872020-06-13 21:19:40 +0200302 # Buckets for spark pipelines
303 # TODO(implr): consider a second yolo-backed one for temp data
304 implrSparkWaw3: kube.CephObjectStoreUser("implr-spark") {
305 metadata+: {
306 namespace: "ceph-waw3",
307 },
308 spec: {
309 store: "waw-hdd-redundant-3-object",
310 displayName: "implr-spark",
311 },
312 },
Sergiusz Bazanskib1aadd82020-06-24 19:06:17 +0200313 # q3k's personal user
314 q3kWaw3: kube.CephObjectStoreUser("q3k") {
315 metadata+: {
316 namespace: "ceph-waw3",
317 },
318 spec: {
319 store: "waw-hdd-redundant-3-object",
320 displayName: "q3k",
321 },
322 },
Serge Bazanskibfe9bb02020-10-27 20:50:50 +0100323 # woju's personal user
324 wojuWaw3: kube.CephObjectStoreUser("woju") {
325 metadata+: {
326 namespace: "ceph-waw3",
327 },
328 spec: {
329 store: "waw-hdd-redundant-3-object",
330 displayName: "woju",
331 },
Patryk Jakuszewcae7cf72020-11-28 14:36:48 +0100332 },
Patryk Jakuszew34668a52020-11-28 13:45:25 +0100333 # cz3's (patryk@hackerspace.pl) personal user
334 cz3Waw3: kube.CephObjectStoreUser("cz3") {
335 metadata+: {
336 namespace: "ceph-waw3",
337 },
338 spec: {
339 store: "waw-hdd-redundant-3-object",
340 displayName: "cz3",
341 },
Serge Bazanskibfe9bb02020-10-27 20:50:50 +0100342 },
Piotr Dobrowolskie839f952021-09-14 22:21:22 +0200343 # informatic's personal user
344 informaticWaw3: kube.CephObjectStoreUser("informatic") {
345 metadata+: {
346 namespace: "ceph-waw3",
347 },
348 spec: {
349 store: "waw-hdd-redundant-3-object",
350 displayName: "informatic",
351 },
352 },
Serge Bazanski16842112022-11-17 19:30:05 +0000353 # mastodon qa and prod
354 mastodonWaw3: {
355 qa: kube.CephObjectStoreUser("mastodon-qa") {
356 metadata+: {
357 namespace: "ceph-waw3",
358 },
359 spec: {
360 store: "waw-hdd-redundant-3-object",
361 displayName: "mastodon-qa",
362 },
363 },
364 prod: kube.CephObjectStoreUser("mastodon-prod") {
365 metadata+: {
366 namespace: "ceph-waw3",
367 },
368 spec: {
369 store: "waw-hdd-redundant-3-object",
370 displayName: "mastodon-prod",
371 },
372 },
373 },
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200374 },
375 },
376
377
378 # These are policies allowing for Insecure pods in some namespaces.
379 # A lot of them are spurious and come from the fact that we deployed
380 # these namespaces before we deployed the draconian PodSecurityPolicy
381 # we have now. This should be fixed by setting up some more granular
382 # policies, or fixing the workloads to not need some of the permission
383 # bits they use, whatever those might be.
384 # TODO(q3k): fix this?
385 unnecessarilyInsecureNamespaces: [
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200386 policies.AllowNamespaceInsecure("ceph-waw3"),
387 policies.AllowNamespaceInsecure("matrix"),
388 policies.AllowNamespaceInsecure("registry"),
389 policies.AllowNamespaceInsecure("internet"),
390 # TODO(implr): restricted policy with CAP_NET_ADMIN and tuntap, but no full root
391 policies.AllowNamespaceInsecure("implr-vpn"),
392 ],
Serge Bazanski3c5d8362021-02-06 17:27:02 +0000393
394 # Admission controller that permits non-privileged users to manage
395 # their namespaces without danger of hijacking important URLs.
396 admitomatic: admitomatic.Environment {
397 cfg+: {
398 proto: {
399 // Domains allowed in given namespaces. If a domain exists
400 // anywhere, ingresses will only be permitted to be created
401 // within namespaces in which it appears here. This works
402 // the same way for wildcards, if a wildcard exists in this
403 // list it blocks all unauthorized uses of that domain
404 // elsewhere.
405 //
406 // See //cluster/admitomatic for more information.
407 //
408 // Or, tl;dr:
409 //
410 // If you do a wildcard CNAME onto the k0 ingress, you
411 // should explicitly state *.your.name.com here.
412 //
413 // If you just want to protect your host from being
414 // hijacked by other cluster users, you should also state
415 // it here (either as a wildcard, or unary domains).
416 allow_domain: [
417 { namespace: "covid-formity", dns: "covid19.hackerspace.pl" },
418 { namespace: "covid-formity", dns: "covid.hackerspace.pl" },
419 { namespace: "covid-formity", dns: "www.covid.hackerspace.pl" },
420 { namespace: "devtools-prod", dns: "hackdoc.hackerspace.pl" },
421 { namespace: "devtools-prod", dns: "cs.hackerspace.pl" },
422 { namespace: "engelsystem-prod", dns: "engelsystem.hackerspace.pl" },
423 { namespace: "gerrit", dns: "gerrit.hackerspace.pl" },
424 { namespace: "gitea-prod", dns: "gitea.hackerspace.pl" },
425 { namespace: "hswaw-prod", dns: "*.hackerspace.pl" },
Serge Bazanski99b91b12021-03-28 17:34:32 +0000426 { namespace: "hswaw-prod", dns: "*.hswaw.net" },
Serge Bazanski3c5d8362021-02-06 17:27:02 +0000427 { namespace: "internet", dns: "internet.hackerspace.pl" },
428 { namespace: "matrix", dns: "matrix.hackerspace.pl" },
429 { namespace: "onlyoffice-prod", dns: "office.hackerspace.pl" },
430 { namespace: "redmine", dns: "issues.hackerspace.pl" },
Serge Bazanski877cf0a2021-02-08 00:34:34 +0100431 { namespace: "redmine", dns: "b.hackerspace.pl" },
432 { namespace: "redmine", dns: "b.hswaw.net" },
433 { namespace: "redmine", dns: "xn--137h.hackerspace.pl" },
434 { namespace: "redmine", dns: "xn--137h.hswaw.net" },
Serge Bazanski3c5d8362021-02-06 17:27:02 +0000435 { namespace: "speedtest", dns: "speedtest.hackerspace.pl" },
436 { namespace: "sso", dns: "sso.hackerspace.pl" },
Serge Bazanski16842112022-11-17 19:30:05 +0000437 { namespace: "mastodon-hackerspace-qa", dns: "social-qa-2.hackerspace.pl" },
438 { namespace: "mastodon-hackerspace-prod", dns: "social.hackerspace.pl" },
Serge Bazanski3c5d8362021-02-06 17:27:02 +0000439
440 { namespace: "ceph-waw3", dns: "ceph-waw3.hswaw.net" },
441 { namespace: "ceph-waw3", dns: "object.ceph-waw3.hswaw.net" },
Serge Bazanski38f72fe2021-09-13 23:43:47 +0000442 { namespace: "ceph-waw3", dns: "object.ceph-eu.hswaw.net" },
Serge Bazanski3c5d8362021-02-06 17:27:02 +0000443 { namespace: "monitoring-global-k0", dns: "*.hswaw.net" },
444 { namespace: "registry", dns: "*.hswaw.net" },
445
446 // q3k's legacy namespace (pre-prodvider)
447 { namespace: "q3k", dns: "*.q3k.org" },
448 { namespace: "personal-q3k", dns: "*.q3k.org" },
449 ],
450 },
451 },
452 },
Sergiusz Bazanskidbfa9882020-06-06 01:21:45 +0200453 },
454}