local kube = import "k8s/configs/base.libsonnet"; local linuxserver = import "k8s/configs/templates/core/linuxserver.libsonnet"; local images = import "k8s/configs/images.libsonnet"; local WebPort = 80; local monicaProbe(delaySeconds) = { initialDelaySeconds: delaySeconds, periodSeconds: 30, tcpSocket: { port: "http", }, }; local Params = kube.simpleFieldStruct([ "namespace", "name", "filePath", "mariaDbService", "mariaDbNamespace", "secretName", "secretDbPwdKey", "ingressHost", "storageClaimName", ]) { labels: {}, gatekeeperSidecar: null, lsParams: linuxserver.AppParams { name: $.name, namespace: $.namespace, filePath: $.filePath, templatePath: std.thisFile, baseAppName: "monica", imageName: "monicahq/monicahq", labels+: $.labels, gatekeeperSidecar: $.gatekeeperSidecar, env: linuxserver.Env { others: [ kube.NameVal("APP_URL", "https://" + $.ingressHost), kube.NameVal("APP_ENV", "production"), kube.NameVal("APP_TRUSTED_PROXIES", "*"), kube.NameVal("DB_HOST", $.mariaDbService + "." + $.mariaDbNamespace + ".svc.cluster.local"), { name: "DB_PASSWORD", valueFrom: { secretKeyRef: { name: $.secretName, key: $.secretDbPwdKey, } } } ] }, services: [ linuxserver.Service { suffix: "ui", spec: kube.SvcUtil.BasicHttpClusterIpSpec(WebPort) }, ], ports: [ kube.DeployUtil.ContainerPort("http", WebPort), ], pvcs: [ linuxserver.Pvc{ name: "data", mountPath: "/var/www/monica/storage", bindName: $.storageClaimName, }, ], resources: { requests: { cpu: "50m", memory: "500Mi", }, limits: { cpu: "100m", memory: "800Mi", }, }, livenessProbe: monicaProbe(/*delaySeconds=*/60), readinessProbe: monicaProbe(/*delaySeconds=*/60), }, }; local App(params) = linuxserver.App(params.lsParams); { WebPort: WebPort, Params: Params, App(params): App(params), }