local kube = import "k8s/configs/base.libsonnet"; local images = import "k8s/configs/images.libsonnet"; local linuxserver = import "k8s/configs/templates/core/linuxserver.libsonnet"; local WebPort = 80; local bookstackProbe(delaySeconds) = { initialDelaySeconds: delaySeconds, periodSeconds: 20, httpGet: { path: "/", port: WebPort, }, }; local Params = kube.simpleFieldStruct([ "namespace", "name", "filePath", "mariaDbUser", "mariaDbDatabase", "mariaDbService", "mariaDbNamespace", "secretName", "secretDbPwdKey", "ingressHost", "configClaimName", ]) { labels: {}, gatekeeperSidecar: null, lsParams: linuxserver.AppParams { name: $.name, namespace: $.namespace, filePath: $.filePath, templatePath: std.thisFile, baseAppName: "bookstack", imageName: "linuxserver/bookstack", labels+: $.labels, gatekeeperSidecar: $.gatekeeperSidecar, env: linuxserver.Env { others: [ kube.NameVal("DB_HOST", $.mariaDbService + "." + $.mariaDbNamespace + ".svc.cluster.local"), kube.NameVal("DB_USERNAME", $.mariaDbUser), kube.NameVal("DB_DATABASE", $.mariaDbDatabase), kube.NameVal("APP_URL", "https://" + $.ingressHost), { name: "DB_PASSWORD", valueFrom: { secretKeyRef: { name: $.secretName, key: $.secretDbPwdKey, } } }, { name: "APP_KEY", valueFrom: { secretKeyRef: { name: $.secretName, key: "bookstack-app-key", } } } ] }, services: [ linuxserver.Service { suffix: "ui", spec: kube.SvcUtil.BasicHttpClusterIpSpec(WebPort) }, ], ports: [ kube.DeployUtil.ContainerPort("http", WebPort), ], pvcs: [ linuxserver.Pvc{ name: "bookstack-config", mountPath: "/config", bindName: $.configClaimName, }, ], resources: { requests: { cpu: "100m", memory: "200Mi", }, limits: { cpu: "200m", memory: "400Mi", }, }, livenessProbe: bookstackProbe(/*delaySeconds=*/120), readinessProbe: bookstackProbe(/*delaySeconds=*/120), }, }; local App(params) = linuxserver.App(params.lsParams); { WebPort: WebPort, Params: Params, App(params): App(params), }