blob: 9b65e954d75d88a7d62bbbeaeaef250786b03033 [file] [log] [blame]
Sergiusz Bazanski36cc4fb2019-05-17 18:08:48 +02001# bazel-cache.k0.hswaw.net, a Bazel Cache based on buchgr/bazel-remote.
2# Once https://github.com/bazelbuild/bazel/pull/4889 gets merged, this will
3# likely be replaced with just an Rados GW instance.
4
5local kube = import "../../kube/kube.libsonnet";
6
7{
8 local app = self,
9 local cfg = app.cfg,
10 cfg:: {
11 namespace: "bazel-cache",
12 domain: "k0.hswaw.net",
13 storageClassName: "waw-hdd-yolo-1",
14 },
15
16 metadata(component):: {
17 namespace: cfg.namespace,
18 labels: {
19 "app.kubernetes.io/name": "bazel-cache",
20 "app.kubernetes.io/managed-by": "kubecfg",
21 "app.kubernetes.io/component": component,
22 },
23 },
24
25 namespace: kube.Namespace(cfg.namespace),
26
27 volumeClaim: kube.PersistentVolumeClaim("bazel-cache-storage") {
28 metadata+: app.metadata("bazel-cache-storage"),
29 spec+: {
30 storageClassName: cfg.storageClassName,
31 accessModes: [ "ReadWriteOnce" ],
32 resources: {
33 requests: {
34 storage: "40Gi",
35 },
36 },
37 },
38 },
39
40
41 deployment: kube.Deployment("bazel-remote") {
42 metadata+: app.metadata("bazel-cache"),
43 spec+: {
44 replicas: 1,
45 template+: {
46 spec+: {
47 volumes_: {
48 data: kube.PersistentVolumeClaimVolume(app.volumeClaim),
49 },
50 containers_: {
51 auth: kube.Container("bazel-remote") {
52 image: "buchgr/bazel-remote-cache",
53 volumeMounts_: {
54 data: { mountPath: "/data" },
55 },
56 ports_: {
57 http: {
58 containerPort: 8080,
59 protocol: "TCP",
60 },
61 },
62 },
63 },
64 },
65 },
66 },
67 },
68
69 service: kube.Service("bazel-cache") {
70 metadata+: app.metadata("bazel-cache"),
71 target_pod:: app.deployment.spec.template,
72 spec+: {
73 type: "ClusterIP",
74 ports: [
75 { name: "http", port: 8080, targetPort: 8080, protocol: "TCP" },
76 ],
77 }
78 },
79
80 ingress: kube.Ingress("bazel-cache") {
81 metadata+: app.metadata("bazel-cache") {
82 annotations+: {
83 "kubernetes.io/tls-acme": "true",
84 "certmanager.k8s.io/cluster-issuer": "letsencrypt-prod",
85 "nginx.ingress.kubernetes.io/backend-protocol": "HTTP",
86 "nginx.ingress.kubernetes.io/proxy-body-size": "0",
87 },
88 },
89 spec+: {
90 tls: [
91 {
92 hosts: ["bazel-cache.%s" % [cfg.domain]],
93 secretName: "bazel-cache-tls",
94 },
95 ],
96 rules: [
97 {
98 host: "bazel-cache.%s" % [cfg.domain],
99 http: {
100 paths: [
101 { path: "/", backend: app.service.name_port },
102 ]
103 },
104 }
105 ],
106 },
107 },
108}