blob: 6ff2e693d4ad703e8e5ef6b31f2d0ba845860a04 [file] [log] [blame]
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +01001# Top level cluster configuration.
2
3local kube = import "../../kube/kube.libsonnet";
Sergiusz Bazanskic7258f42019-06-21 00:24:09 +02004
Sergiusz Bazanskiaf3be422019-01-17 18:57:19 +01005local calico = import "lib/calico.libsonnet";
Sergiusz Bazanskic7258f42019-06-21 00:24:09 +02006local certmanager = import "lib/cert-manager.libsonnet";
7local cockroachdb = import "lib/cockroachdb.libsonnet";
8local coredns = import "lib/coredns.libsonnet";
Sergiusz Bazanski1e565dc2019-01-18 09:40:59 +01009local metallb = import "lib/metallb.libsonnet";
Sergiusz Bazanskic7258f42019-06-21 00:24:09 +020010local metrics = import "lib/metrics.libsonnet";
Sergiusz Bazanskia9c7e862019-04-01 17:56:28 +020011local nginx = import "lib/nginx.libsonnet";
Sergiusz Bazanski4d61d202019-07-21 16:56:41 +020012local registry = import "lib/registry.libsonnet";
Sergiusz Bazanskib7fcc672019-04-01 18:40:50 +020013local rook = import "lib/rook.libsonnet";
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +010014
15local Cluster(fqdn) = {
16 local cluster = self,
Sergiusz Bazanski4d61d202019-07-21 16:56:41 +020017 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 Bazanski4d9e72c2019-01-13 22:06:33 +010025
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 Bazanski5bebbeb2019-01-13 22:08:05 +010044 crbAPIServer: kube.ClusterRoleBinding("system:kube-apiserver") {
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +010045 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 Bazanski49b9a132019-01-14 00:02:59 +010058 },
59
Sergiusz Bazanskiaf3be422019-01-17 18:57:19 +010060 // Calico network fabric
61 calico: calico.Environment {},
Sergiusz Bazanski49b9a132019-01-14 00:02:59 +010062 // CoreDNS for this cluster.
Sergiusz Bazanskiaf3be422019-01-17 18:57:19 +010063 dns: coredns.Environment {},
64 // Metrics Server
65 metrics: metrics.Environment {},
Sergiusz Bazanski1e565dc2019-01-18 09:40:59 +010066 // Metal Load Balancer
Sergiusz Bazanski14cbacb2019-04-01 18:00:44 +020067 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 Bazanskia9c7e862019-04-01 17:56:28 +020074 // Main nginx Ingress Controller
75 nginx: nginx.Environment {},
Piotr Dobrowolski79ddbc52019-04-02 13:20:15 +020076 certmanager: certmanager.Environment {},
Piotr Dobrowolski3187c592019-04-02 14:44:04 +020077 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 Bazanskic6da1272019-04-02 00:06:13 +020089
Sergiusz Bazanskib7fcc672019-04-01 18:40:50 +020090 // Rook Ceph storage
Sergiusz Bazanskic3b0f762019-06-20 16:42:19 +020091 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 Bazanskid07861b2019-08-08 17:48:25 +020096 replicas: 1,
Sergiusz Bazanskic3b0f762019-06-20 16:42:19 +020097 },
98 },
99 },
Sergiusz Bazanski4d61d202019-07-21 16:56:41 +0200100
101 // Docker registry
102 registry: registry.Environment {
103 cfg+: {
104 domain: "registry.%s" % [fqdn],
Sergiusz Bazanskid07861b2019-08-08 17:48:25 +0200105 storageClassName: cfg.storageClassNameParanoid,
106 objectStorageName: "waw-hdd-redundant-2-object",
Sergiusz Bazanski4d61d202019-07-21 16:56:41 +0200107 },
108 },
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +0100109};
110
Sergiusz Bazanski49b9a132019-01-14 00:02:59 +0100111
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +0100112{
Sergiusz Bazanskic7258f42019-06-21 00:24:09 +0200113 k0: {
114 local k0 = self,
Sergiusz Bazanski4d61d202019-07-21 16:56:41 +0200115 cluster: Cluster("k0.hswaw.net") {
116 cfg+: {
Sergiusz Bazanskid07861b2019-08-08 17:48:25 +0200117 storageClassNameParanoid: k0.ceph.blockParanoid.name,
Sergiusz Bazanski4d61d202019-07-21 16:56:41 +0200118 },
119 },
Sergiusz Bazanskic7258f42019-06-21 00:24:09 +0200120 cockroach: {
Sergiusz Bazanskid5338922019-08-09 14:13:50 +0200121 waw2: cockroachdb.Cluster("crdb-waw1") {
Sergiusz Bazanskic7258f42019-06-21 00:24:09 +0200122 cfg+: {
123 topology: [
Sergiusz Bazanski184678b2019-06-22 02:07:41 +0200124 { name: "bc01n01", node: "bc01n01.hswaw.net" },
125 { name: "bc01n02", node: "bc01n02.hswaw.net" },
126 { name: "bc01n03", node: "bc01n03.hswaw.net" },
Sergiusz Bazanskic7258f42019-06-21 00:24:09 +0200127 ],
Sergiusz Bazanskid5338922019-08-09 14:13:50 +0200128 hostPath: "/var/db/crdb-waw1",
Sergiusz Bazanskic7258f42019-06-21 00:24:09 +0200129 },
130 },
131 },
132 ceph: {
Sergiusz Bazanskid07861b2019-08-08 17:48:25 +0200133 // waw1 cluster - dead as of 2019/08/06, data corruption
134 // waw2 cluster
135 waw2: rook.Cluster(k0.cluster.rook, "ceph-waw2") {
Sergiusz Bazanskic7258f42019-06-21 00:24:09 +0200136 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 Bazanskid07861b2019-08-08 17:48:25 +0200169 blockRedundant: rook.ECBlockPool(k0.ceph.waw2, "waw-hdd-redundant-2") {
Sergiusz Bazanskic7258f42019-06-21 00:24:09 +0200170 spec: {
171 failureDomain: "host",
172 erasureCoded: {
173 dataChunks: 2,
174 codingChunks: 1,
175 },
176 },
177 },
Sergiusz Bazanskid07861b2019-08-08 17:48:25 +0200178 // 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 Bazanskic7258f42019-06-21 00:24:09 +0200187 // yolo block storage (no replicas!)
Sergiusz Bazanskid07861b2019-08-08 17:48:25 +0200188 blockYolo: rook.ReplicatedBlockPool(k0.ceph.waw2, "waw-hdd-yolo-2") {
Sergiusz Bazanskic7258f42019-06-21 00:24:09 +0200189 spec: {
190 failureDomain: "host",
191 replicated: {
192 size: 1,
193 },
194 },
195 },
Sergiusz Bazanskid07861b2019-08-08 17:48:25 +0200196 objectRedundant: rook.S3ObjectStore(k0.ceph.waw2, "waw-hdd-redundant-2-object") {
Sergiusz Bazanskic7258f42019-06-21 00:24:09 +0200197 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 Bazanski4d9e72c2019-01-13 22:06:33 +0100213}