blob: 42dd2e39adb0b4d4755bbccf4b83328676ae60e7 [file] [log] [blame]
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +01001# Top level cluster configuration.
2
3local kube = import "../../kube/kube.libsonnet";
Sergiusz Bazanski49b9a132019-01-14 00:02:59 +01004local coredns = import "lib/coredns.libsonnet";
Sergiusz Bazanskiaf3be422019-01-17 18:57:19 +01005local metrics = import "lib/metrics.libsonnet";
6local calico = import "lib/calico.libsonnet";
Sergiusz Bazanski1e565dc2019-01-18 09:40:59 +01007local metallb = import "lib/metallb.libsonnet";
Sergiusz Bazanskia9c7e862019-04-01 17:56:28 +02008local nginx = import "lib/nginx.libsonnet";
Sergiusz Bazanskib7fcc672019-04-01 18:40:50 +02009local rook = import "lib/rook.libsonnet";
Piotr Dobrowolski79ddbc52019-04-02 13:20:15 +020010local certmanager = import "lib/cert-manager.libsonnet";
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +010011
12local 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 Bazanski5bebbeb2019-01-13 22:08:05 +010033 crbAPIServer: kube.ClusterRoleBinding("system:kube-apiserver") {
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +010034 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 Bazanski49b9a132019-01-14 00:02:59 +010047 },
48
Sergiusz Bazanskiaf3be422019-01-17 18:57:19 +010049 // Calico network fabric
50 calico: calico.Environment {},
Sergiusz Bazanski49b9a132019-01-14 00:02:59 +010051 // CoreDNS for this cluster.
Sergiusz Bazanskiaf3be422019-01-17 18:57:19 +010052 dns: coredns.Environment {},
53 // Metrics Server
54 metrics: metrics.Environment {},
Sergiusz Bazanski1e565dc2019-01-18 09:40:59 +010055 // Metal Load Balancer
Sergiusz Bazanski14cbacb2019-04-01 18:00:44 +020056 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 Bazanskia9c7e862019-04-01 17:56:28 +020063 // Main nginx Ingress Controller
64 nginx: nginx.Environment {},
Piotr Dobrowolski79ddbc52019-04-02 13:20:15 +020065 certmanager: certmanager.Environment {},
Piotr Dobrowolski3187c592019-04-02 14:44:04 +020066 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 Bazanskic6da1272019-04-02 00:06:13 +020078
Sergiusz Bazanskib7fcc672019-04-01 18:40:50 +020079 // Rook Ceph storage
Sergiusz Bazanskic6da1272019-04-02 00:06:13 +020080 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 Bazanski65f3b1d2019-04-02 01:05:38 +0200115 // 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 },
Sergiusz Bazanski36cc4fb2019-05-17 18:08:48 +0200125 // yolo block storage (no replicas!)
126 cephWaw1Yolo: rook.ReplicatedBlockPool(cluster.cephWaw1, "waw-hdd-yolo-1") {
127 spec: {
128 failureDomain: "host",
129 replicated: {
130 size: 1,
131 },
132 },
133 },
Piotr Dobrowolski5ac85c62019-04-09 21:45:32 +0200134 cephWaw1Object: rook.S3ObjectStore(cluster.cephWaw1, "waw-hdd-redundant-1-object") {
Piotr Dobrowolski6da3b282019-04-07 18:49:41 +0200135 spec: {
136 metadataPool: {
137 failureDomain: "host",
138 replicated: { size: 3 },
139 },
140 dataPool: {
141 failureDomain: "host",
142 erasureCoded: {
143 dataChunks: 2,
144 codingChunks: 1,
145 },
146 },
Piotr Dobrowolski6da3b282019-04-07 18:49:41 +0200147 },
148 },
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +0100149};
150
Sergiusz Bazanski49b9a132019-01-14 00:02:59 +0100151
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +0100152{
153 k0: Cluster("k0.hswaw.net"),
154}