Sergiusz Bazanski | 4d9e72c | 2019-01-13 22:06:33 +0100 | [diff] [blame] | 1 | # Top level cluster configuration. |
| 2 | |
| 3 | local kube = import "../../kube/kube.libsonnet"; |
Sergiusz Bazanski | 49b9a13 | 2019-01-14 00:02:59 +0100 | [diff] [blame] | 4 | local coredns = import "lib/coredns.libsonnet"; |
Sergiusz Bazanski | af3be42 | 2019-01-17 18:57:19 +0100 | [diff] [blame] | 5 | local metrics = import "lib/metrics.libsonnet"; |
| 6 | local calico = import "lib/calico.libsonnet"; |
Sergiusz Bazanski | 1e565dc | 2019-01-18 09:40:59 +0100 | [diff] [blame] | 7 | local metallb = import "lib/metallb.libsonnet"; |
Sergiusz Bazanski | a9c7e86 | 2019-04-01 17:56:28 +0200 | [diff] [blame] | 8 | local nginx = import "lib/nginx.libsonnet"; |
Sergiusz Bazanski | b7fcc67 | 2019-04-01 18:40:50 +0200 | [diff] [blame] | 9 | local rook = import "lib/rook.libsonnet"; |
Piotr Dobrowolski | 79ddbc5 | 2019-04-02 13:20:15 +0200 | [diff] [blame] | 10 | local certmanager = import "lib/cert-manager.libsonnet"; |
Sergiusz Bazanski | 4d9e72c | 2019-01-13 22:06:33 +0100 | [diff] [blame] | 11 | |
| 12 | local Cluster(fqdn) = { |
| 13 | local cluster = self, |
| 14 | |
| 15 | // These are required to let the API Server contact kubelets. |
| 16 | crAPIServerToKubelet: kube.ClusterRole("system:kube-apiserver-to-kubelet") { |
| 17 | metadata+: { |
| 18 | annotations+: { |
| 19 | "rbac.authorization.kubernetes.io/autoupdate": "true", |
| 20 | }, |
| 21 | labels+: { |
| 22 | "kubernets.io/bootstrapping": "rbac-defaults", |
| 23 | }, |
| 24 | }, |
| 25 | rules: [ |
| 26 | { |
| 27 | apiGroups: [""], |
| 28 | resources: ["nodes/%s" % r for r in [ "proxy", "stats", "log", "spec", "metrics" ]], |
| 29 | verbs: ["*"], |
| 30 | }, |
| 31 | ], |
| 32 | }, |
Sergiusz Bazanski | 5bebbeb | 2019-01-13 22:08:05 +0100 | [diff] [blame] | 33 | crbAPIServer: kube.ClusterRoleBinding("system:kube-apiserver") { |
Sergiusz Bazanski | 4d9e72c | 2019-01-13 22:06:33 +0100 | [diff] [blame] | 34 | roleRef: { |
| 35 | apiGroup: "rbac.authorization.k8s.io", |
| 36 | kind: "ClusterRole", |
| 37 | name: cluster.crAPIServerToKubelet.metadata.name, |
| 38 | }, |
| 39 | subjects: [ |
| 40 | { |
| 41 | apiGroup: "rbac.authorization.k8s.io", |
| 42 | kind: "User", |
| 43 | # A cluster API Server authenticates with a certificate whose CN is == to the FQDN of the cluster. |
| 44 | name: fqdn, |
| 45 | }, |
| 46 | ], |
Sergiusz Bazanski | 49b9a13 | 2019-01-14 00:02:59 +0100 | [diff] [blame] | 47 | }, |
| 48 | |
Sergiusz Bazanski | af3be42 | 2019-01-17 18:57:19 +0100 | [diff] [blame] | 49 | // Calico network fabric |
| 50 | calico: calico.Environment {}, |
Sergiusz Bazanski | 49b9a13 | 2019-01-14 00:02:59 +0100 | [diff] [blame] | 51 | // CoreDNS for this cluster. |
Sergiusz Bazanski | af3be42 | 2019-01-17 18:57:19 +0100 | [diff] [blame] | 52 | dns: coredns.Environment {}, |
| 53 | // Metrics Server |
| 54 | metrics: metrics.Environment {}, |
Sergiusz Bazanski | 1e565dc | 2019-01-18 09:40:59 +0100 | [diff] [blame] | 55 | // Metal Load Balancer |
Sergiusz Bazanski | 14cbacb | 2019-04-01 18:00:44 +0200 | [diff] [blame] | 56 | metallb: metallb.Environment { |
| 57 | cfg+: { |
| 58 | addressPools: [ |
| 59 | { name: "public-v4-1", protocol: "layer2", addresses: ["185.236.240.50-185.236.240.63"] }, |
| 60 | ], |
| 61 | }, |
| 62 | }, |
Sergiusz Bazanski | a9c7e86 | 2019-04-01 17:56:28 +0200 | [diff] [blame] | 63 | // Main nginx Ingress Controller |
| 64 | nginx: nginx.Environment {}, |
Piotr Dobrowolski | 79ddbc5 | 2019-04-02 13:20:15 +0200 | [diff] [blame] | 65 | certmanager: certmanager.Environment {}, |
Piotr Dobrowolski | 3187c59 | 2019-04-02 14:44:04 +0200 | [diff] [blame] | 66 | issuer: certmanager.ClusterIssuer("letsencrypt-prod") { |
| 67 | spec: { |
| 68 | acme: { |
| 69 | server: "https://acme-v02.api.letsencrypt.org/directory", |
| 70 | email: "bofh@hackerspace.pl", |
| 71 | privateKeySecretRef: { |
| 72 | name: "letsencrypt-prod" |
| 73 | }, |
| 74 | http01: {}, |
| 75 | }, |
| 76 | }, |
| 77 | }, |
Sergiusz Bazanski | c6da127 | 2019-04-02 00:06:13 +0200 | [diff] [blame] | 78 | |
Sergiusz Bazanski | b7fcc67 | 2019-04-01 18:40:50 +0200 | [diff] [blame] | 79 | // Rook Ceph storage |
Sergiusz Bazanski | c6da127 | 2019-04-02 00:06:13 +0200 | [diff] [blame] | 80 | rook: rook.Operator {}, |
| 81 | // waw1 ceph cluster |
| 82 | cephWaw1: rook.Cluster(cluster.rook, "ceph-waw1") { |
| 83 | spec: { |
| 84 | mon: { |
| 85 | count: 3, |
| 86 | allowMultiplePerNode: false, |
| 87 | }, |
| 88 | storage: { |
| 89 | useAllNodes: false, |
| 90 | useAllDevices: false, |
| 91 | config: { |
| 92 | databaseSizeMB: "1024", |
| 93 | journalSizeMB: "1024", |
| 94 | }, |
| 95 | nodes: [ |
| 96 | { |
| 97 | name: "bc01n01.hswaw.net", |
| 98 | location: "rack=dcr01 chassis=bc01 host=bc01n01", |
| 99 | devices: [ { name: "sda" } ], |
| 100 | }, |
| 101 | { |
| 102 | name: "bc01n02.hswaw.net", |
| 103 | location: "rack=dcr01 chassis=bc01 host=bc01n02", |
| 104 | devices: [ { name: "sda" } ], |
| 105 | }, |
| 106 | { |
| 107 | name: "bc01n03.hswaw.net", |
| 108 | location: "rack=dcr01 chassis=bc01 host=bc01n03", |
| 109 | devices: [ { name: "sda" } ], |
| 110 | }, |
| 111 | ], |
| 112 | }, |
| 113 | }, |
| 114 | }, |
Sergiusz Bazanski | 65f3b1d | 2019-04-02 01:05:38 +0200 | [diff] [blame] | 115 | // redundant block storage |
| 116 | cephWaw1Redundant: rook.ECBlockPool(cluster.cephWaw1, "waw-hdd-redundant-1") { |
| 117 | spec: { |
| 118 | failureDomain: "host", |
| 119 | erasureCoded: { |
| 120 | dataChunks: 2, |
| 121 | codingChunks: 1, |
| 122 | }, |
| 123 | }, |
| 124 | }, |
Piotr Dobrowolski | 5ac85c6 | 2019-04-09 21:45:32 +0200 | [diff] [blame] | 125 | cephWaw1Object: rook.S3ObjectStore(cluster.cephWaw1, "waw-hdd-redundant-1-object") { |
Piotr Dobrowolski | 6da3b28 | 2019-04-07 18:49:41 +0200 | [diff] [blame] | 126 | spec: { |
| 127 | metadataPool: { |
| 128 | failureDomain: "host", |
| 129 | replicated: { size: 3 }, |
| 130 | }, |
| 131 | dataPool: { |
| 132 | failureDomain: "host", |
| 133 | erasureCoded: { |
| 134 | dataChunks: 2, |
| 135 | codingChunks: 1, |
| 136 | }, |
| 137 | }, |
Piotr Dobrowolski | 6da3b28 | 2019-04-07 18:49:41 +0200 | [diff] [blame] | 138 | }, |
| 139 | }, |
Sergiusz Bazanski | 4d9e72c | 2019-01-13 22:06:33 +0100 | [diff] [blame] | 140 | }; |
| 141 | |
Sergiusz Bazanski | 49b9a13 | 2019-01-14 00:02:59 +0100 | [diff] [blame] | 142 | |
Sergiusz Bazanski | 4d9e72c | 2019-01-13 22:06:33 +0100 | [diff] [blame] | 143 | { |
| 144 | k0: Cluster("k0.hswaw.net"), |
| 145 | } |