blob: fc0db19a7fdcf5f1cf0d5cb1294dcc56299458e5 [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 Bazanskib7fcc672019-04-01 18:40:50 +020012local rook = import "lib/rook.libsonnet";
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +010013
14local Cluster(fqdn) = {
15 local cluster = self,
16
17 // These are required to let the API Server contact kubelets.
18 crAPIServerToKubelet: kube.ClusterRole("system:kube-apiserver-to-kubelet") {
19 metadata+: {
20 annotations+: {
21 "rbac.authorization.kubernetes.io/autoupdate": "true",
22 },
23 labels+: {
24 "kubernets.io/bootstrapping": "rbac-defaults",
25 },
26 },
27 rules: [
28 {
29 apiGroups: [""],
30 resources: ["nodes/%s" % r for r in [ "proxy", "stats", "log", "spec", "metrics" ]],
31 verbs: ["*"],
32 },
33 ],
34 },
Sergiusz Bazanski5bebbeb2019-01-13 22:08:05 +010035 crbAPIServer: kube.ClusterRoleBinding("system:kube-apiserver") {
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +010036 roleRef: {
37 apiGroup: "rbac.authorization.k8s.io",
38 kind: "ClusterRole",
39 name: cluster.crAPIServerToKubelet.metadata.name,
40 },
41 subjects: [
42 {
43 apiGroup: "rbac.authorization.k8s.io",
44 kind: "User",
45 # A cluster API Server authenticates with a certificate whose CN is == to the FQDN of the cluster.
46 name: fqdn,
47 },
48 ],
Sergiusz Bazanski49b9a132019-01-14 00:02:59 +010049 },
50
Sergiusz Bazanskiaf3be422019-01-17 18:57:19 +010051 // Calico network fabric
52 calico: calico.Environment {},
Sergiusz Bazanski49b9a132019-01-14 00:02:59 +010053 // CoreDNS for this cluster.
Sergiusz Bazanskiaf3be422019-01-17 18:57:19 +010054 dns: coredns.Environment {},
55 // Metrics Server
56 metrics: metrics.Environment {},
Sergiusz Bazanski1e565dc2019-01-18 09:40:59 +010057 // Metal Load Balancer
Sergiusz Bazanski14cbacb2019-04-01 18:00:44 +020058 metallb: metallb.Environment {
59 cfg+: {
60 addressPools: [
61 { name: "public-v4-1", protocol: "layer2", addresses: ["185.236.240.50-185.236.240.63"] },
62 ],
63 },
64 },
Sergiusz Bazanskia9c7e862019-04-01 17:56:28 +020065 // Main nginx Ingress Controller
66 nginx: nginx.Environment {},
Piotr Dobrowolski79ddbc52019-04-02 13:20:15 +020067 certmanager: certmanager.Environment {},
Piotr Dobrowolski3187c592019-04-02 14:44:04 +020068 issuer: certmanager.ClusterIssuer("letsencrypt-prod") {
69 spec: {
70 acme: {
71 server: "https://acme-v02.api.letsencrypt.org/directory",
72 email: "bofh@hackerspace.pl",
73 privateKeySecretRef: {
74 name: "letsencrypt-prod"
75 },
76 http01: {},
77 },
78 },
79 },
Sergiusz Bazanskic6da1272019-04-02 00:06:13 +020080
Sergiusz Bazanskib7fcc672019-04-01 18:40:50 +020081 // Rook Ceph storage
Sergiusz Bazanskic3b0f762019-06-20 16:42:19 +020082 rook: rook.Operator {
83 operator+: {
84 spec+: {
85 // TODO(q3k): Bring up the operator again when stability gets fixed
86 // See: https://github.com/rook/rook/issues/3059#issuecomment-492378873
87 replicas: 0,
88 },
89 },
90 },
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +010091};
92
Sergiusz Bazanski49b9a132019-01-14 00:02:59 +010093
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +010094{
Sergiusz Bazanskic7258f42019-06-21 00:24:09 +020095 k0: {
96 local k0 = self,
97 cluster: Cluster("k0.hswaw.net"),
98 cockroach: {
99 waw1: cockroachdb.Cluster("crdb-waw1") {
100 cfg+: {
101 topology: [
Sergiusz Bazanski184678b2019-06-22 02:07:41 +0200102 { name: "bc01n01", node: "bc01n01.hswaw.net" },
103 { name: "bc01n02", node: "bc01n02.hswaw.net" },
104 { name: "bc01n03", node: "bc01n03.hswaw.net" },
Sergiusz Bazanskic7258f42019-06-21 00:24:09 +0200105 ],
106 hostPath: "/var/db/crdb-waw1",
107 },
108 },
109 },
110 ceph: {
111 // waw1 cluster
112 waw1: rook.Cluster(k0.cluster.rook, "ceph-waw1") {
113 spec: {
114 mon: {
115 count: 3,
116 allowMultiplePerNode: false,
117 },
118 storage: {
119 useAllNodes: false,
120 useAllDevices: false,
121 config: {
122 databaseSizeMB: "1024",
123 journalSizeMB: "1024",
124 },
125 nodes: [
126 {
127 name: "bc01n01.hswaw.net",
128 location: "rack=dcr01 chassis=bc01 host=bc01n01",
129 devices: [ { name: "sda" } ],
130 },
131 {
132 name: "bc01n02.hswaw.net",
133 location: "rack=dcr01 chassis=bc01 host=bc01n02",
134 devices: [ { name: "sda" } ],
135 },
136 {
137 name: "bc01n03.hswaw.net",
138 location: "rack=dcr01 chassis=bc01 host=bc01n03",
139 devices: [ { name: "sda" } ],
140 },
141 ],
142 },
143 },
144 },
145 // redundant block storage
146 blockRedundant: rook.ECBlockPool(k0.ceph.waw1, "waw-hdd-redundant-1") {
147 spec: {
148 failureDomain: "host",
149 erasureCoded: {
150 dataChunks: 2,
151 codingChunks: 1,
152 },
153 },
154 },
155 // yolo block storage (no replicas!)
156 blockYolo: rook.ReplicatedBlockPool(k0.ceph.waw1, "waw-hdd-yolo-1") {
157 spec: {
158 failureDomain: "host",
159 replicated: {
160 size: 1,
161 },
162 },
163 },
164 objectRedundant: rook.S3ObjectStore(k0.ceph.waw1, "waw-hdd-redundant-1-object") {
165 spec: {
166 metadataPool: {
167 failureDomain: "host",
168 replicated: { size: 3 },
169 },
170 dataPool: {
171 failureDomain: "host",
172 erasureCoded: {
173 dataChunks: 2,
174 codingChunks: 1,
175 },
176 },
177 },
178 },
179 },
180 },
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +0100181}