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 | c7258f4 | 2019-06-21 00:24:09 +0200 | [diff] [blame] | 4 | |
Sergiusz Bazanski | af3be42 | 2019-01-17 18:57:19 +0100 | [diff] [blame] | 5 | local calico = import "lib/calico.libsonnet"; |
Sergiusz Bazanski | c7258f4 | 2019-06-21 00:24:09 +0200 | [diff] [blame] | 6 | local certmanager = import "lib/cert-manager.libsonnet"; |
| 7 | local cockroachdb = import "lib/cockroachdb.libsonnet"; |
| 8 | local coredns = import "lib/coredns.libsonnet"; |
Sergiusz Bazanski | 1e565dc | 2019-01-18 09:40:59 +0100 | [diff] [blame] | 9 | local metallb = import "lib/metallb.libsonnet"; |
Sergiusz Bazanski | c7258f4 | 2019-06-21 00:24:09 +0200 | [diff] [blame] | 10 | local metrics = import "lib/metrics.libsonnet"; |
Sergiusz Bazanski | a9c7e86 | 2019-04-01 17:56:28 +0200 | [diff] [blame] | 11 | local nginx = import "lib/nginx.libsonnet"; |
Sergiusz Bazanski | 4d61d20 | 2019-07-21 16:56:41 +0200 | [diff] [blame] | 12 | local registry = import "lib/registry.libsonnet"; |
Sergiusz Bazanski | b7fcc67 | 2019-04-01 18:40:50 +0200 | [diff] [blame] | 13 | local rook = import "lib/rook.libsonnet"; |
Sergiusz Bazanski | 4d9e72c | 2019-01-13 22:06:33 +0100 | [diff] [blame] | 14 | |
| 15 | local Cluster(fqdn) = { |
| 16 | local cluster = self, |
Sergiusz Bazanski | 4d61d20 | 2019-07-21 16:56:41 +0200 | [diff] [blame] | 17 | local cfg = cluster.cfg, |
| 18 | |
| 19 | cfg:: { |
| 20 | // Storage class used for internal services (like registry). This must |
| 21 | // be set to a valid storage class. This can either be a cloud provider class |
| 22 | // (when running on GKE &co) or a storage class created using rook. |
| 23 | storageClassNameRedundant: error "storageClassNameRedundant must be set", |
| 24 | }, |
Sergiusz Bazanski | 4d9e72c | 2019-01-13 22:06:33 +0100 | [diff] [blame] | 25 | |
| 26 | // These are required to let the API Server contact kubelets. |
| 27 | crAPIServerToKubelet: kube.ClusterRole("system:kube-apiserver-to-kubelet") { |
| 28 | metadata+: { |
| 29 | annotations+: { |
| 30 | "rbac.authorization.kubernetes.io/autoupdate": "true", |
| 31 | }, |
| 32 | labels+: { |
| 33 | "kubernets.io/bootstrapping": "rbac-defaults", |
| 34 | }, |
| 35 | }, |
| 36 | rules: [ |
| 37 | { |
| 38 | apiGroups: [""], |
| 39 | resources: ["nodes/%s" % r for r in [ "proxy", "stats", "log", "spec", "metrics" ]], |
| 40 | verbs: ["*"], |
| 41 | }, |
| 42 | ], |
| 43 | }, |
Sergiusz Bazanski | 5bebbeb | 2019-01-13 22:08:05 +0100 | [diff] [blame] | 44 | crbAPIServer: kube.ClusterRoleBinding("system:kube-apiserver") { |
Sergiusz Bazanski | 4d9e72c | 2019-01-13 22:06:33 +0100 | [diff] [blame] | 45 | roleRef: { |
| 46 | apiGroup: "rbac.authorization.k8s.io", |
| 47 | kind: "ClusterRole", |
| 48 | name: cluster.crAPIServerToKubelet.metadata.name, |
| 49 | }, |
| 50 | subjects: [ |
| 51 | { |
| 52 | apiGroup: "rbac.authorization.k8s.io", |
| 53 | kind: "User", |
| 54 | # A cluster API Server authenticates with a certificate whose CN is == to the FQDN of the cluster. |
| 55 | name: fqdn, |
| 56 | }, |
| 57 | ], |
Sergiusz Bazanski | 49b9a13 | 2019-01-14 00:02:59 +0100 | [diff] [blame] | 58 | }, |
| 59 | |
Sergiusz Bazanski | af3be42 | 2019-01-17 18:57:19 +0100 | [diff] [blame] | 60 | // Calico network fabric |
| 61 | calico: calico.Environment {}, |
Sergiusz Bazanski | 49b9a13 | 2019-01-14 00:02:59 +0100 | [diff] [blame] | 62 | // CoreDNS for this cluster. |
Sergiusz Bazanski | af3be42 | 2019-01-17 18:57:19 +0100 | [diff] [blame] | 63 | dns: coredns.Environment {}, |
| 64 | // Metrics Server |
| 65 | metrics: metrics.Environment {}, |
Sergiusz Bazanski | 1e565dc | 2019-01-18 09:40:59 +0100 | [diff] [blame] | 66 | // Metal Load Balancer |
Sergiusz Bazanski | 14cbacb | 2019-04-01 18:00:44 +0200 | [diff] [blame] | 67 | metallb: metallb.Environment { |
| 68 | cfg+: { |
| 69 | addressPools: [ |
| 70 | { name: "public-v4-1", protocol: "layer2", addresses: ["185.236.240.50-185.236.240.63"] }, |
| 71 | ], |
| 72 | }, |
| 73 | }, |
Sergiusz Bazanski | a9c7e86 | 2019-04-01 17:56:28 +0200 | [diff] [blame] | 74 | // Main nginx Ingress Controller |
| 75 | nginx: nginx.Environment {}, |
Piotr Dobrowolski | 79ddbc5 | 2019-04-02 13:20:15 +0200 | [diff] [blame] | 76 | certmanager: certmanager.Environment {}, |
Piotr Dobrowolski | 3187c59 | 2019-04-02 14:44:04 +0200 | [diff] [blame] | 77 | issuer: certmanager.ClusterIssuer("letsencrypt-prod") { |
| 78 | spec: { |
| 79 | acme: { |
| 80 | server: "https://acme-v02.api.letsencrypt.org/directory", |
| 81 | email: "bofh@hackerspace.pl", |
| 82 | privateKeySecretRef: { |
| 83 | name: "letsencrypt-prod" |
| 84 | }, |
| 85 | http01: {}, |
| 86 | }, |
| 87 | }, |
| 88 | }, |
Sergiusz Bazanski | c6da127 | 2019-04-02 00:06:13 +0200 | [diff] [blame] | 89 | |
Sergiusz Bazanski | b7fcc67 | 2019-04-01 18:40:50 +0200 | [diff] [blame] | 90 | // Rook Ceph storage |
Sergiusz Bazanski | c3b0f76 | 2019-06-20 16:42:19 +0200 | [diff] [blame] | 91 | rook: rook.Operator { |
| 92 | operator+: { |
| 93 | spec+: { |
| 94 | // TODO(q3k): Bring up the operator again when stability gets fixed |
| 95 | // See: https://github.com/rook/rook/issues/3059#issuecomment-492378873 |
Sergiusz Bazanski | d07861b | 2019-08-08 17:48:25 +0200 | [diff] [blame] | 96 | replicas: 1, |
Sergiusz Bazanski | c3b0f76 | 2019-06-20 16:42:19 +0200 | [diff] [blame] | 97 | }, |
| 98 | }, |
| 99 | }, |
Sergiusz Bazanski | 4d61d20 | 2019-07-21 16:56:41 +0200 | [diff] [blame] | 100 | |
| 101 | // Docker registry |
| 102 | registry: registry.Environment { |
| 103 | cfg+: { |
| 104 | domain: "registry.%s" % [fqdn], |
Sergiusz Bazanski | d07861b | 2019-08-08 17:48:25 +0200 | [diff] [blame] | 105 | storageClassName: cfg.storageClassNameParanoid, |
| 106 | objectStorageName: "waw-hdd-redundant-2-object", |
Sergiusz Bazanski | 4d61d20 | 2019-07-21 16:56:41 +0200 | [diff] [blame] | 107 | }, |
| 108 | }, |
Sergiusz Bazanski | 4d9e72c | 2019-01-13 22:06:33 +0100 | [diff] [blame] | 109 | }; |
| 110 | |
Sergiusz Bazanski | 49b9a13 | 2019-01-14 00:02:59 +0100 | [diff] [blame] | 111 | |
Sergiusz Bazanski | 4d9e72c | 2019-01-13 22:06:33 +0100 | [diff] [blame] | 112 | { |
Sergiusz Bazanski | c7258f4 | 2019-06-21 00:24:09 +0200 | [diff] [blame] | 113 | k0: { |
| 114 | local k0 = self, |
Sergiusz Bazanski | 4d61d20 | 2019-07-21 16:56:41 +0200 | [diff] [blame] | 115 | cluster: Cluster("k0.hswaw.net") { |
| 116 | cfg+: { |
Sergiusz Bazanski | d07861b | 2019-08-08 17:48:25 +0200 | [diff] [blame] | 117 | storageClassNameParanoid: k0.ceph.blockParanoid.name, |
Sergiusz Bazanski | 4d61d20 | 2019-07-21 16:56:41 +0200 | [diff] [blame] | 118 | }, |
| 119 | }, |
Sergiusz Bazanski | c7258f4 | 2019-06-21 00:24:09 +0200 | [diff] [blame] | 120 | cockroach: { |
Sergiusz Bazanski | d533892 | 2019-08-09 14:13:50 +0200 | [diff] [blame] | 121 | waw2: cockroachdb.Cluster("crdb-waw1") { |
Sergiusz Bazanski | c7258f4 | 2019-06-21 00:24:09 +0200 | [diff] [blame] | 122 | cfg+: { |
| 123 | topology: [ |
Sergiusz Bazanski | 184678b | 2019-06-22 02:07:41 +0200 | [diff] [blame] | 124 | { name: "bc01n01", node: "bc01n01.hswaw.net" }, |
| 125 | { name: "bc01n02", node: "bc01n02.hswaw.net" }, |
| 126 | { name: "bc01n03", node: "bc01n03.hswaw.net" }, |
Sergiusz Bazanski | c7258f4 | 2019-06-21 00:24:09 +0200 | [diff] [blame] | 127 | ], |
Sergiusz Bazanski | d533892 | 2019-08-09 14:13:50 +0200 | [diff] [blame] | 128 | hostPath: "/var/db/crdb-waw1", |
Sergiusz Bazanski | c7258f4 | 2019-06-21 00:24:09 +0200 | [diff] [blame] | 129 | }, |
| 130 | }, |
| 131 | }, |
| 132 | ceph: { |
Sergiusz Bazanski | d07861b | 2019-08-08 17:48:25 +0200 | [diff] [blame] | 133 | // waw1 cluster - dead as of 2019/08/06, data corruption |
| 134 | // waw2 cluster |
| 135 | waw2: rook.Cluster(k0.cluster.rook, "ceph-waw2") { |
Sergiusz Bazanski | c7258f4 | 2019-06-21 00:24:09 +0200 | [diff] [blame] | 136 | spec: { |
| 137 | mon: { |
| 138 | count: 3, |
| 139 | allowMultiplePerNode: false, |
| 140 | }, |
| 141 | storage: { |
| 142 | useAllNodes: false, |
| 143 | useAllDevices: false, |
| 144 | config: { |
| 145 | databaseSizeMB: "1024", |
| 146 | journalSizeMB: "1024", |
| 147 | }, |
| 148 | nodes: [ |
| 149 | { |
| 150 | name: "bc01n01.hswaw.net", |
| 151 | location: "rack=dcr01 chassis=bc01 host=bc01n01", |
| 152 | devices: [ { name: "sda" } ], |
| 153 | }, |
| 154 | { |
| 155 | name: "bc01n02.hswaw.net", |
| 156 | location: "rack=dcr01 chassis=bc01 host=bc01n02", |
| 157 | devices: [ { name: "sda" } ], |
| 158 | }, |
| 159 | { |
| 160 | name: "bc01n03.hswaw.net", |
| 161 | location: "rack=dcr01 chassis=bc01 host=bc01n03", |
| 162 | devices: [ { name: "sda" } ], |
| 163 | }, |
| 164 | ], |
| 165 | }, |
| 166 | }, |
| 167 | }, |
| 168 | // redundant block storage |
Sergiusz Bazanski | d07861b | 2019-08-08 17:48:25 +0200 | [diff] [blame] | 169 | blockRedundant: rook.ECBlockPool(k0.ceph.waw2, "waw-hdd-redundant-2") { |
Sergiusz Bazanski | c7258f4 | 2019-06-21 00:24:09 +0200 | [diff] [blame] | 170 | spec: { |
| 171 | failureDomain: "host", |
| 172 | erasureCoded: { |
| 173 | dataChunks: 2, |
| 174 | codingChunks: 1, |
| 175 | }, |
| 176 | }, |
| 177 | }, |
Sergiusz Bazanski | d07861b | 2019-08-08 17:48:25 +0200 | [diff] [blame] | 178 | // paranoid block storage (3 replicas) |
| 179 | blockParanoid: rook.ReplicatedBlockPool(k0.ceph.waw2, "waw-hdd-paranoid-2") { |
| 180 | spec: { |
| 181 | failureDomain: "host", |
| 182 | replicated: { |
| 183 | size: 3, |
| 184 | }, |
| 185 | }, |
| 186 | }, |
Sergiusz Bazanski | c7258f4 | 2019-06-21 00:24:09 +0200 | [diff] [blame] | 187 | // yolo block storage (no replicas!) |
Sergiusz Bazanski | d07861b | 2019-08-08 17:48:25 +0200 | [diff] [blame] | 188 | blockYolo: rook.ReplicatedBlockPool(k0.ceph.waw2, "waw-hdd-yolo-2") { |
Sergiusz Bazanski | c7258f4 | 2019-06-21 00:24:09 +0200 | [diff] [blame] | 189 | spec: { |
| 190 | failureDomain: "host", |
| 191 | replicated: { |
| 192 | size: 1, |
| 193 | }, |
| 194 | }, |
| 195 | }, |
Sergiusz Bazanski | d07861b | 2019-08-08 17:48:25 +0200 | [diff] [blame] | 196 | objectRedundant: rook.S3ObjectStore(k0.ceph.waw2, "waw-hdd-redundant-2-object") { |
Sergiusz Bazanski | c7258f4 | 2019-06-21 00:24:09 +0200 | [diff] [blame] | 197 | spec: { |
| 198 | metadataPool: { |
| 199 | failureDomain: "host", |
| 200 | replicated: { size: 3 }, |
| 201 | }, |
| 202 | dataPool: { |
| 203 | failureDomain: "host", |
| 204 | erasureCoded: { |
| 205 | dataChunks: 2, |
| 206 | codingChunks: 1, |
| 207 | }, |
| 208 | }, |
| 209 | }, |
| 210 | }, |
| 211 | }, |
| 212 | }, |
Sergiusz Bazanski | 4d9e72c | 2019-01-13 22:06:33 +0100 | [diff] [blame] | 213 | } |