Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 1 | // 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 | |
| 5 | local kube = import "../../kube/kube.libsonnet"; |
| 6 | local policies = import "../../kube/policies.libsonnet"; |
| 7 | |
| 8 | local cluster = import "cluster.libsonnet"; |
| 9 | |
Serge Bazanski | 3c5d836 | 2021-02-06 17:27:02 +0000 | [diff] [blame] | 10 | local admitomatic = import "lib/admitomatic.libsonnet"; |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 11 | local cockroachdb = import "lib/cockroachdb.libsonnet"; |
| 12 | local registry = import "lib/registry.libsonnet"; |
| 13 | local rook = import "lib/rook.libsonnet"; |
| 14 | |
| 15 | { |
| 16 | k0: { |
| 17 | local k0 = self, |
| 18 | cluster: cluster.Cluster("k0", "hswaw.net") { |
| 19 | cfg+: { |
Serge Bazanski | 3d29484 | 2020-08-04 01:34:07 +0200 | [diff] [blame] | 20 | storageClassNameParanoid: k0.ceph.waw3Pools.blockRedundant.name, |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 21 | }, |
| 22 | metallb+: { |
| 23 | cfg+: { |
Serge Bazanski | a5ed644 | 2020-09-20 22:52:57 +0000 | [diff] [blame] | 24 | // Peer with calico running on same node. |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 25 | peers: [ |
| 26 | { |
Serge Bazanski | a5ed644 | 2020-09-20 22:52:57 +0000 | [diff] [blame] | 27 | "peer-address": "127.0.0.1", |
| 28 | "peer-asn": 65003, |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 29 | "my-asn": 65002, |
| 30 | }, |
| 31 | ], |
Serge Bazanski | a5ed644 | 2020-09-20 22:52:57 +0000 | [diff] [blame] | 32 | // Public IP address pools. Keep in sync with k0.calico.yaml. |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 33 | 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 Bazanski | 3d29484 | 2020-08-04 01:34:07 +0200 | [diff] [blame] | 58 | objectStorageName: "waw-hdd-redundant-3-object", |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 59 | }, |
| 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 Jakuszew | edf14cc | 2021-01-23 23:00:29 +0100 | [diff] [blame] | 69 | { name: "dcr01s22", node: "dcr01s22.hswaw.net" }, |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 70 | ], |
| 71 | // Host path on SSD. |
| 72 | hostPath: "/var/db/crdb-waw1", |
Serge Bazanski | 509ab6e | 2020-07-30 22:43:20 +0200 | [diff] [blame] | 73 | extraDNS: [ |
| 74 | "crdb-waw1.hswaw.net", |
| 75 | ], |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 76 | }, |
| 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 Bazanski | 509ab6e | 2020-07-30 22:43:20 +0200 | [diff] [blame] | 83 | herpDev: k0.cockroach.waw2.Client("herp-dev"), |
Patryk Jakuszew | f315388 | 2021-01-23 15:38:50 +0100 | [diff] [blame] | 84 | gitea: k0.cockroach.waw2.Client("gitea"), |
Piotr Dobrowolski | f4a6a56 | 2021-02-01 21:32:25 +0100 | [diff] [blame] | 85 | issues: k0.cockroach.waw2.Client("issues"), |
Serge Bazanski | bf266c6 | 2021-03-17 21:48:58 +0000 | [diff] [blame] | 86 | dns: k0.cockroach.waw2.Client("dns"), |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 87 | }, |
| 88 | }, |
| 89 | |
| 90 | ceph: { |
| 91 | // waw1 cluster - dead as of 2019/08/06, data corruption |
Serge Bazanski | 61f978a | 2021-01-22 16:26:07 +0100 | [diff] [blame] | 92 | // waw2 cluster - dead as of 2021/01/22, torn down (horrible M610 RAID controllers are horrible) |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 93 | |
| 94 | // waw3: 6TB SAS 3.5" HDDs |
| 95 | waw3: rook.Cluster(k0.cluster.rook, "ceph-waw3") { |
| 96 | spec: { |
| 97 | mon: { |
Serge Bazanski | cf842b0 | 2021-01-19 20:08:23 +0100 | [diff] [blame] | 98 | count: 1, |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 99 | allowMultiplePerNode: false, |
| 100 | }, |
Serge Bazanski | 793ca1b | 2021-03-07 00:07:19 +0000 | [diff] [blame] | 101 | resources: { |
| 102 | osd: { |
| 103 | requests: { |
Serge Bazanski | 64de7af | 2021-03-17 21:47:29 +0000 | [diff] [blame] | 104 | cpu: "2", |
| 105 | memory: "6G", |
Serge Bazanski | 793ca1b | 2021-03-07 00:07:19 +0000 | [diff] [blame] | 106 | }, |
| 107 | limits: { |
Serge Bazanski | 64de7af | 2021-03-17 21:47:29 +0000 | [diff] [blame] | 108 | cpu: "2", |
| 109 | memory: "8G", |
Serge Bazanski | 793ca1b | 2021-03-07 00:07:19 +0000 | [diff] [blame] | 110 | }, |
| 111 | }, |
| 112 | |
| 113 | }, |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 114 | storage: { |
| 115 | useAllNodes: false, |
| 116 | useAllDevices: false, |
| 117 | config: { |
| 118 | databaseSizeMB: "1024", |
| 119 | journalSizeMB: "1024", |
| 120 | }, |
| 121 | nodes: [ |
| 122 | { |
| 123 | name: "dcr01s22.hswaw.net", |
| 124 | location: "rack=dcr01 host=dcr01s22", |
| 125 | devices: [ |
| 126 | // https://github.com/rook/rook/issues/1228 |
| 127 | //{ name: "disk/by-id/wwan-0x" + wwan } |
| 128 | //for wwan in [ |
| 129 | // "5000c5008508c433", |
| 130 | // "5000c500850989cf", |
| 131 | // "5000c5008508f843", |
| 132 | // "5000c5008508baf7", |
| 133 | //] |
| 134 | { name: "sdn" }, |
| 135 | { name: "sda" }, |
| 136 | { name: "sdb" }, |
| 137 | { name: "sdc" }, |
| 138 | ], |
| 139 | }, |
| 140 | { |
| 141 | name: "dcr01s24.hswaw.net", |
| 142 | location: "rack=dcr01 host=dcr01s22", |
| 143 | devices: [ |
| 144 | // https://github.com/rook/rook/issues/1228 |
| 145 | //{ name: "disk/by-id/wwan-0x" + wwan } |
| 146 | //for wwan in [ |
| 147 | // "5000c5008508ee03", |
| 148 | // "5000c5008508c9ef", |
| 149 | // "5000c5008508df33", |
| 150 | // "5000c5008508dd3b", |
| 151 | //] |
| 152 | { name: "sdm" }, |
| 153 | { name: "sda" }, |
| 154 | { name: "sdb" }, |
| 155 | { name: "sdc" }, |
| 156 | ], |
| 157 | }, |
| 158 | ], |
| 159 | }, |
| 160 | benji:: { |
| 161 | metadataStorageClass: "waw-hdd-redundant-3", |
| 162 | encryptionPassword: std.split((importstr "../secrets/plain/k0-benji-encryption-password"), '\n')[0], |
| 163 | pools: [ |
| 164 | "waw-hdd-redundant-3", |
| 165 | "waw-hdd-redundant-3-metadata", |
| 166 | "waw-hdd-yolo-3", |
| 167 | ], |
| 168 | s3Configuration: { |
| 169 | awsAccessKeyId: "RPYZIROFXNLQVU2WJ4R3", |
| 170 | awsSecretAccessKey: std.split((importstr "../secrets/plain/k0-benji-secret-access-key"), '\n')[0], |
| 171 | bucketName: "benji-k0-backups-waw3", |
| 172 | endpointUrl: "https://s3.eu-central-1.wasabisys.com/", |
| 173 | }, |
| 174 | } |
| 175 | }, |
| 176 | }, |
| 177 | waw3Pools: { |
| 178 | // redundant block storage |
| 179 | blockRedundant: rook.ECBlockPool(k0.ceph.waw3, "waw-hdd-redundant-3") { |
| 180 | metadataReplicas: 2, |
| 181 | spec: { |
| 182 | failureDomain: "host", |
| 183 | replicated: { |
| 184 | size: 2, |
| 185 | }, |
| 186 | }, |
| 187 | }, |
| 188 | // yolo block storage (low usage, no host redundancy) |
| 189 | blockYolo: rook.ReplicatedBlockPool(k0.ceph.waw3, "waw-hdd-yolo-3") { |
| 190 | spec: { |
| 191 | failureDomain: "osd", |
| 192 | erasureCoded: { |
Serge Bazanski | cf842b0 | 2021-01-19 20:08:23 +0100 | [diff] [blame] | 193 | dataChunks: 2, |
| 194 | codingChunks: 1, |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 195 | }, |
| 196 | }, |
| 197 | }, |
Serge Bazanski | 242ec58 | 2020-09-20 15:36:11 +0000 | [diff] [blame] | 198 | // q3k's personal pool, used externally from k8s. |
| 199 | q3kRedundant: rook.ECBlockPool(k0.ceph.waw3, "waw-hdd-redundant-q3k-3") { |
| 200 | metadataReplicas: 2, |
| 201 | spec: { |
| 202 | failureDomain: "host", |
| 203 | replicated: { |
| 204 | size: 2, |
| 205 | }, |
| 206 | }, |
| 207 | }, |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 208 | objectRedundant: rook.S3ObjectStore(k0.ceph.waw3, "waw-hdd-redundant-3-object") { |
| 209 | spec: { |
| 210 | metadataPool: { |
| 211 | failureDomain: "host", |
| 212 | replicated: { size: 2 }, |
| 213 | }, |
| 214 | dataPool: { |
| 215 | failureDomain: "host", |
| 216 | replicated: { size: 2 }, |
| 217 | }, |
| 218 | }, |
| 219 | }, |
| 220 | }, |
| 221 | |
| 222 | // Clients for S3/radosgw storage. |
| 223 | clients: { |
| 224 | # Used for owncloud.hackerspace.pl, which for now lives on boston-packets.hackerspace.pl. |
| 225 | nextcloudWaw3: kube.CephObjectStoreUser("nextcloud") { |
| 226 | metadata+: { |
| 227 | namespace: "ceph-waw3", |
| 228 | }, |
| 229 | spec: { |
| 230 | store: "waw-hdd-redundant-3-object", |
| 231 | displayName: "nextcloud", |
| 232 | }, |
| 233 | }, |
Piotr Dobrowolski | 3b8a43f | 2021-02-01 21:19:48 +0100 | [diff] [blame] | 234 | # issues.hackerspace.pl (redmine) attachments bucket |
| 235 | issuesWaw3: kube.CephObjectStoreUser("issues") { |
| 236 | metadata+: { |
| 237 | namespace: "ceph-waw3", |
| 238 | }, |
| 239 | spec: { |
| 240 | store: "waw-hdd-redundant-3-object", |
| 241 | displayName: "issues", |
| 242 | }, |
| 243 | }, |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 244 | |
| 245 | # nuke@hackerspace.pl's personal storage. |
| 246 | nukePersonalWaw3: kube.CephObjectStoreUser("nuke-personal") { |
| 247 | metadata+: { |
| 248 | namespace: "ceph-waw3", |
| 249 | }, |
| 250 | spec: { |
| 251 | store: "waw-hdd-redundant-3-object", |
| 252 | displayName: "nuke-personal", |
| 253 | }, |
| 254 | }, |
| 255 | |
| 256 | # patryk@hackerspace.pl's ArmA3 mod bucket. |
| 257 | cz2ArmaModsWaw3: kube.CephObjectStoreUser("cz2-arma3mods") { |
| 258 | metadata+: { |
| 259 | namespace: "ceph-waw3", |
| 260 | }, |
| 261 | spec: { |
| 262 | store: "waw-hdd-redundant-3-object", |
| 263 | displayName: "cz2-arma3mods", |
| 264 | }, |
| 265 | }, |
Bartosz Stebel | d9df587 | 2020-06-13 21:19:40 +0200 | [diff] [blame] | 266 | # Buckets for spark pipelines |
| 267 | # TODO(implr): consider a second yolo-backed one for temp data |
| 268 | implrSparkWaw3: kube.CephObjectStoreUser("implr-spark") { |
| 269 | metadata+: { |
| 270 | namespace: "ceph-waw3", |
| 271 | }, |
| 272 | spec: { |
| 273 | store: "waw-hdd-redundant-3-object", |
| 274 | displayName: "implr-spark", |
| 275 | }, |
| 276 | }, |
Sergiusz Bazanski | b1aadd8 | 2020-06-24 19:06:17 +0200 | [diff] [blame] | 277 | # q3k's personal user |
| 278 | q3kWaw3: kube.CephObjectStoreUser("q3k") { |
| 279 | metadata+: { |
| 280 | namespace: "ceph-waw3", |
| 281 | }, |
| 282 | spec: { |
| 283 | store: "waw-hdd-redundant-3-object", |
| 284 | displayName: "q3k", |
| 285 | }, |
| 286 | }, |
Serge Bazanski | bfe9bb0 | 2020-10-27 20:50:50 +0100 | [diff] [blame] | 287 | # woju's personal user |
| 288 | wojuWaw3: kube.CephObjectStoreUser("woju") { |
| 289 | metadata+: { |
| 290 | namespace: "ceph-waw3", |
| 291 | }, |
| 292 | spec: { |
| 293 | store: "waw-hdd-redundant-3-object", |
| 294 | displayName: "woju", |
| 295 | }, |
Patryk Jakuszew | cae7cf7 | 2020-11-28 14:36:48 +0100 | [diff] [blame] | 296 | }, |
Patryk Jakuszew | 34668a5 | 2020-11-28 13:45:25 +0100 | [diff] [blame] | 297 | # cz3's (patryk@hackerspace.pl) personal user |
| 298 | cz3Waw3: kube.CephObjectStoreUser("cz3") { |
| 299 | metadata+: { |
| 300 | namespace: "ceph-waw3", |
| 301 | }, |
| 302 | spec: { |
| 303 | store: "waw-hdd-redundant-3-object", |
| 304 | displayName: "cz3", |
| 305 | }, |
Serge Bazanski | bfe9bb0 | 2020-10-27 20:50:50 +0100 | [diff] [blame] | 306 | }, |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 307 | }, |
| 308 | }, |
| 309 | |
| 310 | |
| 311 | # These are policies allowing for Insecure pods in some namespaces. |
| 312 | # A lot of them are spurious and come from the fact that we deployed |
| 313 | # these namespaces before we deployed the draconian PodSecurityPolicy |
| 314 | # we have now. This should be fixed by setting up some more granular |
| 315 | # policies, or fixing the workloads to not need some of the permission |
| 316 | # bits they use, whatever those might be. |
| 317 | # TODO(q3k): fix this? |
| 318 | unnecessarilyInsecureNamespaces: [ |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 319 | policies.AllowNamespaceInsecure("ceph-waw3"), |
| 320 | policies.AllowNamespaceInsecure("matrix"), |
| 321 | policies.AllowNamespaceInsecure("registry"), |
| 322 | policies.AllowNamespaceInsecure("internet"), |
| 323 | # TODO(implr): restricted policy with CAP_NET_ADMIN and tuntap, but no full root |
| 324 | policies.AllowNamespaceInsecure("implr-vpn"), |
| 325 | ], |
Serge Bazanski | 3c5d836 | 2021-02-06 17:27:02 +0000 | [diff] [blame] | 326 | |
| 327 | # Admission controller that permits non-privileged users to manage |
| 328 | # their namespaces without danger of hijacking important URLs. |
| 329 | admitomatic: admitomatic.Environment { |
| 330 | cfg+: { |
| 331 | proto: { |
| 332 | // Domains allowed in given namespaces. If a domain exists |
| 333 | // anywhere, ingresses will only be permitted to be created |
| 334 | // within namespaces in which it appears here. This works |
| 335 | // the same way for wildcards, if a wildcard exists in this |
| 336 | // list it blocks all unauthorized uses of that domain |
| 337 | // elsewhere. |
| 338 | // |
| 339 | // See //cluster/admitomatic for more information. |
| 340 | // |
| 341 | // Or, tl;dr: |
| 342 | // |
| 343 | // If you do a wildcard CNAME onto the k0 ingress, you |
| 344 | // should explicitly state *.your.name.com here. |
| 345 | // |
| 346 | // If you just want to protect your host from being |
| 347 | // hijacked by other cluster users, you should also state |
| 348 | // it here (either as a wildcard, or unary domains). |
| 349 | allow_domain: [ |
| 350 | { namespace: "covid-formity", dns: "covid19.hackerspace.pl" }, |
| 351 | { namespace: "covid-formity", dns: "covid.hackerspace.pl" }, |
| 352 | { namespace: "covid-formity", dns: "www.covid.hackerspace.pl" }, |
| 353 | { namespace: "devtools-prod", dns: "hackdoc.hackerspace.pl" }, |
| 354 | { namespace: "devtools-prod", dns: "cs.hackerspace.pl" }, |
| 355 | { namespace: "engelsystem-prod", dns: "engelsystem.hackerspace.pl" }, |
| 356 | { namespace: "gerrit", dns: "gerrit.hackerspace.pl" }, |
| 357 | { namespace: "gitea-prod", dns: "gitea.hackerspace.pl" }, |
| 358 | { namespace: "hswaw-prod", dns: "*.hackerspace.pl" }, |
| 359 | { namespace: "internet", dns: "internet.hackerspace.pl" }, |
| 360 | { namespace: "matrix", dns: "matrix.hackerspace.pl" }, |
| 361 | { namespace: "onlyoffice-prod", dns: "office.hackerspace.pl" }, |
| 362 | { namespace: "redmine", dns: "issues.hackerspace.pl" }, |
Serge Bazanski | 877cf0a | 2021-02-08 00:34:34 +0100 | [diff] [blame] | 363 | { namespace: "redmine", dns: "b.hackerspace.pl" }, |
| 364 | { namespace: "redmine", dns: "b.hswaw.net" }, |
| 365 | { namespace: "redmine", dns: "xn--137h.hackerspace.pl" }, |
| 366 | { namespace: "redmine", dns: "xn--137h.hswaw.net" }, |
Serge Bazanski | 3c5d836 | 2021-02-06 17:27:02 +0000 | [diff] [blame] | 367 | { namespace: "speedtest", dns: "speedtest.hackerspace.pl" }, |
| 368 | { namespace: "sso", dns: "sso.hackerspace.pl" }, |
| 369 | |
| 370 | { namespace: "ceph-waw3", dns: "ceph-waw3.hswaw.net" }, |
| 371 | { namespace: "ceph-waw3", dns: "object.ceph-waw3.hswaw.net" }, |
| 372 | { namespace: "monitoring-global-k0", dns: "*.hswaw.net" }, |
| 373 | { namespace: "registry", dns: "*.hswaw.net" }, |
| 374 | |
| 375 | // q3k's legacy namespace (pre-prodvider) |
| 376 | { namespace: "q3k", dns: "*.q3k.org" }, |
| 377 | { namespace: "personal-q3k", dns: "*.q3k.org" }, |
| 378 | ], |
| 379 | }, |
| 380 | }, |
| 381 | }, |
Sergiusz Bazanski | dbfa988 | 2020-06-06 01:21:45 +0200 | [diff] [blame] | 382 | }, |
| 383 | } |