local kube = import "k8s/configs/base.libsonnet"; local linuxserver = import "k8s/configs/templates/core/linuxserver.libsonnet"; local images = import "k8s/configs/images.libsonnet"; local probe(delaySeconds) = { initialDelaySeconds: delaySeconds, periodSeconds: 30, tcpSocket: { port: "http", }, }; local WebPort = 11434; local Params = kube.simpleFieldStruct([ "namespace", "name", "filePath", "storageClaimName", ]) { labels: {}, gatekeeperSidecar: null, gpuNodeSelectorName: "nvidia", lsParams: linuxserver.AppParams { name: $.name, namespace: $.namespace, filePath: $.filePath, templatePath: std.thisFile, baseAppName: "ollama", imageName: "ollama/ollama", labels+: $.labels, gatekeeperSidecar: $.gatekeeperSidecar, nodeSelector: { "gpu": $.gpuNodeSelectorName, }, services: [ linuxserver.Service { suffix: "ui", spec: kube.SvcUtil.BasicHttpClusterIpSpec(WebPort) }, ], env: linuxserver.Env { others: [ kube.NameVal("NVIDIA_VISIBLE_DEVICES", "all"), kube.NameVal("NVIDIA_DRIVER_CAPABILITIES", "all"), kube.NameVal("OLLAMA_KEEP_ALIVE", "20m"), ], }, ports: [ kube.DeployUtil.ContainerPort("http", WebPort), ], hostPaths: [ linuxserver.HostPath { name: "storage-local", hostPath: "/home/core/local_volumes/ollama", mountPath: "/root/.ollama", }, ], pvcs: [ linuxserver.Pvc{ name: "storage", mountPath: "/root/.ollama-remote", bindName: $.storageClaimName, }, ], resources: { requests: { cpu: "500m", memory: "1Gi", }, limits: { cpu: "1000m", memory: "2Gi", }, }, livenessProbe: probe(/*delaySeconds=*/120), readinessProbe: probe(/*delaySeconds=*/120), }, }; local App(params) = linuxserver.App(params.lsParams); { Params: Params, WebPort: WebPort, App(params): App(params), }