blob: 4eb9eee23b299a72b7412cd9afc2d3c79b217944 [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 Bazanski4d9e72c2019-01-13 22:06:33 +01007
8local Cluster(fqdn) = {
9 local cluster = self,
10
11 // These are required to let the API Server contact kubelets.
12 crAPIServerToKubelet: kube.ClusterRole("system:kube-apiserver-to-kubelet") {
13 metadata+: {
14 annotations+: {
15 "rbac.authorization.kubernetes.io/autoupdate": "true",
16 },
17 labels+: {
18 "kubernets.io/bootstrapping": "rbac-defaults",
19 },
20 },
21 rules: [
22 {
23 apiGroups: [""],
24 resources: ["nodes/%s" % r for r in [ "proxy", "stats", "log", "spec", "metrics" ]],
25 verbs: ["*"],
26 },
27 ],
28 },
Sergiusz Bazanski5bebbeb2019-01-13 22:08:05 +010029 crbAPIServer: kube.ClusterRoleBinding("system:kube-apiserver") {
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +010030 roleRef: {
31 apiGroup: "rbac.authorization.k8s.io",
32 kind: "ClusterRole",
33 name: cluster.crAPIServerToKubelet.metadata.name,
34 },
35 subjects: [
36 {
37 apiGroup: "rbac.authorization.k8s.io",
38 kind: "User",
39 # A cluster API Server authenticates with a certificate whose CN is == to the FQDN of the cluster.
40 name: fqdn,
41 },
42 ],
Sergiusz Bazanski49b9a132019-01-14 00:02:59 +010043 },
44
Sergiusz Bazanskiaf3be422019-01-17 18:57:19 +010045 // Calico network fabric
46 calico: calico.Environment {},
Sergiusz Bazanski49b9a132019-01-14 00:02:59 +010047 // CoreDNS for this cluster.
Sergiusz Bazanskiaf3be422019-01-17 18:57:19 +010048 dns: coredns.Environment {},
49 // Metrics Server
50 metrics: metrics.Environment {},
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +010051};
52
Sergiusz Bazanski49b9a132019-01-14 00:02:59 +010053
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +010054{
55 k0: Cluster("k0.hswaw.net"),
56}