let appName = "tclip"; litestreamImage = "litestream/litestream:sha-749bc0d"; tclipImage = "git.gmem.ca/arch/tclip:arm"; in { kubernetes.resources."monitoring.coreos.com"."v1".ServiceMonitor.tclip = { spec = { selector.matchLabels.app = appName; endpoints = [ { port = "metrics"; interval = "30s"; } ]; }; }; kubernetes.resources.services.tclip = { metadata.labels.app = appName; spec = { selector.app = appName; ports.metrics = { port = 9090; targetPort = 9090; }; }; }; kubernetes.resources.statefulSets.tclip.spec = { selector.matchLabels.app = appName; serviceName = appName; template = { metadata.labels.app = appName; spec = { volumes = { litestream.configMap.name = "tclip-litestream"; config.configMap.name = "tclip"; }; initContainers.init-litestream = { image = litestreamImage; args = ["restore" "-if-db-not-exists" "-if-replica-exists" "-v" "/data/data.db"]; volumeMounts = [ { name = "data"; mountPath = "/data"; } { name = "litestream"; mountPath = "/etc/litestream.yml"; subPath = "tclip.yml"; } ]; envFrom = [{secretRef.name = "tclip-litestream-s3";}]; }; containers = { tclip = { image = tclipImage; imagePullPolicy = "Always"; volumeMounts = [ { name = "data"; mountPath = "/data"; } ]; env = [ { name = "DATA_DIR"; value = "/data"; } { name = "USE_FUNNEL"; value = "true"; } ]; }; litestream = { image = litestreamImage; args = ["replicate"]; volumeMounts = [ { name = "data"; mountPath = "/data"; } { name = "litestream"; mountPath = "/etc/litestream.yml"; subPath = "tclip.yml"; } ]; envFrom = [{secretRef.name = "tclip-litestream-s3";}]; ports.metrics = { containerPort = 9090; name = "metrics"; }; }; }; }; }; volumeClaimTemplates = [ { metadata.name = "data"; spec = { storageClassName = "nfs-client"; accessModes = ["ReadWriteOnce"]; resources.requests.storage = "1Gi"; }; } ]; }; }