local kube = import 'k8s/configs/base.libsonnet'; local linuxserver = import 'k8s/configs/templates/core/linuxserver.libsonnet'; local Params = kube.simpleFieldStruct([ 'namespace', 'name', 'dataClaimName', 'extraArgs', 'secrets', 'configMaps', ]) { maxSizeGb: 20, lsParams: linuxserver.AppParams { name: $.name, namespace: $.namespace, filePath: std.thisFile, templatePath: std.thisFile, baseAppName: 'bazel-remote-cache', // TODO: Pin this to a specific version tag instead of latest. imageName: 'buchgr/bazel-remote-cache:v2.6.1', args: [ '--max_size=' + $.maxSizeGb, #'--directory=/data', ] + $.extraArgs, secrets: $.secrets, configMaps: $.configMaps, extraVolumes: $.extraVolumes, extraVolumeMounts: $.extraVolumeMounts, ports: [ kube.DeployUtil.ContainerPort('grpc', 9092), kube.DeployUtil.ContainerPort('http', 8080), ], pvcs: [ linuxserver.Pvc { name: 'data', mountPath: '/data', bindName: $.dataClaimName, }, ], services: [ linuxserver.Service { suffix: 'grpc', spec: { type: 'ClusterIP', ports: [ kube.SvcUtil.TCPServicePort('grpc', 9092), ], }, }, linuxserver.Service { suffix: 'http', spec: kube.SvcUtil.BasicHttpClusterIpSpec(8080), }, ], resources: { requests: { cpu: '500m', memory: '512Mi', }, limits: { cpu: '2000m', memory: '4Gi', }, }, }, }; local App(params) = local baseApp = linuxserver.App(params.lsParams); baseApp { // The buchgr/bazel-remote-cache image does not have a corresponding entry // in our images.libsonnet, so we must override the image path directly. deployment+: { spec+: { template+: { spec+: { containers: [ c { image: params.lsParams.imageName } for c in super.containers ], }, }, }, }, }; { Params: Params, App(params): App(params), }