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 | 4d9e72c | 2019-01-13 22:06:33 +0100 | [diff] [blame] | 9 | |
| 10 | local Cluster(fqdn) = { |
| 11 | local cluster = self, |
| 12 | |
| 13 | // These are required to let the API Server contact kubelets. |
| 14 | crAPIServerToKubelet: kube.ClusterRole("system:kube-apiserver-to-kubelet") { |
| 15 | metadata+: { |
| 16 | annotations+: { |
| 17 | "rbac.authorization.kubernetes.io/autoupdate": "true", |
| 18 | }, |
| 19 | labels+: { |
| 20 | "kubernets.io/bootstrapping": "rbac-defaults", |
| 21 | }, |
| 22 | }, |
| 23 | rules: [ |
| 24 | { |
| 25 | apiGroups: [""], |
| 26 | resources: ["nodes/%s" % r for r in [ "proxy", "stats", "log", "spec", "metrics" ]], |
| 27 | verbs: ["*"], |
| 28 | }, |
| 29 | ], |
| 30 | }, |
Sergiusz Bazanski | 5bebbeb | 2019-01-13 22:08:05 +0100 | [diff] [blame] | 31 | crbAPIServer: kube.ClusterRoleBinding("system:kube-apiserver") { |
Sergiusz Bazanski | 4d9e72c | 2019-01-13 22:06:33 +0100 | [diff] [blame] | 32 | roleRef: { |
| 33 | apiGroup: "rbac.authorization.k8s.io", |
| 34 | kind: "ClusterRole", |
| 35 | name: cluster.crAPIServerToKubelet.metadata.name, |
| 36 | }, |
| 37 | subjects: [ |
| 38 | { |
| 39 | apiGroup: "rbac.authorization.k8s.io", |
| 40 | kind: "User", |
| 41 | # A cluster API Server authenticates with a certificate whose CN is == to the FQDN of the cluster. |
| 42 | name: fqdn, |
| 43 | }, |
| 44 | ], |
Sergiusz Bazanski | 49b9a13 | 2019-01-14 00:02:59 +0100 | [diff] [blame] | 45 | }, |
| 46 | |
Sergiusz Bazanski | af3be42 | 2019-01-17 18:57:19 +0100 | [diff] [blame] | 47 | // Calico network fabric |
| 48 | calico: calico.Environment {}, |
Sergiusz Bazanski | 49b9a13 | 2019-01-14 00:02:59 +0100 | [diff] [blame] | 49 | // CoreDNS for this cluster. |
Sergiusz Bazanski | af3be42 | 2019-01-17 18:57:19 +0100 | [diff] [blame] | 50 | dns: coredns.Environment {}, |
| 51 | // Metrics Server |
| 52 | metrics: metrics.Environment {}, |
Sergiusz Bazanski | 1e565dc | 2019-01-18 09:40:59 +0100 | [diff] [blame] | 53 | // Metal Load Balancer |
| 54 | metallb: metallb.Environment {}, |
Sergiusz Bazanski | a9c7e86 | 2019-04-01 17:56:28 +0200 | [diff] [blame^] | 55 | // Main nginx Ingress Controller |
| 56 | nginx: nginx.Environment {}, |
Sergiusz Bazanski | 4d9e72c | 2019-01-13 22:06:33 +0100 | [diff] [blame] | 57 | }; |
| 58 | |
Sergiusz Bazanski | 49b9a13 | 2019-01-14 00:02:59 +0100 | [diff] [blame] | 59 | |
Sergiusz Bazanski | 4d9e72c | 2019-01-13 22:06:33 +0100 | [diff] [blame] | 60 | { |
| 61 | k0: Cluster("k0.hswaw.net"), |
| 62 | } |