{"id":83124,"date":"2026-07-25T17:17:02","date_gmt":"2026-07-25T09:17:02","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/83124.html"},"modified":"2026-07-25T17:17:02","modified_gmt":"2026-07-25T09:17:02","slug":"ollama-%e5%9c%a8-kubernetes-%e4%b8%8a%e7%9a%84%e7%94%9f%e4%ba%a7%e5%8c%96%e9%83%a8%e7%bd%b2%ef%bc%9agpu-%e6%8b%93%e6%89%91%e6%84%9f%e7%9f%a5%e8%b0%83%e5%ba%a6%e4%b8%8e%e8%8a%82%e7%82%b9%e4%ba%b2","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/83124.html","title":{"rendered":"Ollama \u5728 Kubernetes \u4e0a\u7684\u751f\u4ea7\u5316\u90e8\u7f72\uff1aGPU \u62d3\u6251\u611f\u77e5\u8c03\u5ea6\u4e0e\u8282\u70b9\u4eb2\u548c\u6027\u914d\u7f6e"},"content":{"rendered":"<h2>Ollama \u5728 Kubernetes \u4e0a\u7684\u751f\u4ea7\u5316\u90e8\u7f72&#xff1a;GPU \u62d3\u6251\u611f\u77e5\u8c03\u5ea6\u4e0e\u8282\u70b9\u4eb2\u548c\u6027\u914d\u7f6e<\/h2>\n<h3>\u4e00\u3001Ollama \u88f8\u8dd1 K8s \u7684\u4e09\u5927\u81f4\u547d\u95ee\u9898<\/h3>\n<p>\u76f4\u63a5\u4f7f\u7528 ollama\/ollama \u955c\u50cf\u90e8\u7f72\u5230 Kubernetes&#xff0c;\u4f1a\u7acb\u523b\u9047\u5230\u4e09\u4e2a\u95ee\u9898\u3002\u7b2c\u4e00\u4e2a\u662f GPU \u4e0d\u53ef\u89c1&#xff1a;\u5bb9\u5668\u9ed8\u8ba4\u6ca1\u6709\u6302\u8f7d NVIDIA \u8bbe\u5907&#xff0c;\u9700\u8981 nvidia-device-plugin \u548c\u6b63\u786e\u7684 nvidia.com\/gpu \u8d44\u6e90\u58f0\u660e\u3002\u7b2c\u4e8c\u4e2a\u662f\u6a21\u578b\u5b58\u50a8&#xff1a;Ollama \u9ed8\u8ba4\u5c06\u6a21\u578b\u4e0b\u8f7d\u5230 \/root\/.ollama&#xff0c;\u5bb9\u5668\u91cd\u542f\u540e\u5168\u90e8\u4e22\u5931&#xff0c;\u6bcf\u6b21\u8c03\u5ea6\u5230\u65b0\u8282\u70b9\u90fd\u9700\u8981\u91cd\u65b0\u4e0b\u8f7d\u6570\u5341 GB \u7684\u6a21\u578b\u3002\u7b2c\u4e09\u4e2a\u662f\u62d3\u6251\u9519\u914d&#xff1a;GPU \u8282\u70b9\u548c CPU \u8282\u70b9\u6df7\u5408\u90e8\u7f72\u65f6&#xff0c;Ollama Pod \u53ef\u80fd\u88ab\u8c03\u5ea6\u5230\u6ca1\u6709 GPU \u7684\u8282\u70b9\u4e0a\u3002<\/p>\n<p>\u66f4\u6df1\u5c42\u7684\u95ee\u9898\u5728\u4e8e GPU \u62d3\u6251\u611f\u77e5\u3002\u4e00\u5757 A100 \u6709 80GB \u663e\u5b58&#xff0c;\u53ef\u4ee5\u540c\u65f6\u52a0\u8f7d\u591a\u4e2a 7B \u6a21\u578b\u3002\u4f46\u5982\u679c Pod \u88ab\u8c03\u5ea6\u5230\u4e24\u5f20 GPU \u4e0d\u5728\u540c\u4e00 NUMA \u8282\u70b9\u7684\u4f4d\u7f6e&#xff0c;\u8de8 Socket \u7684\u6570\u636e\u4f20\u8f93\u5ef6\u8fdf\u589e\u52a0 2-3 \u500d\u3002HuggingFace \u7684 text-generation-inference \u901a\u8fc7 &#8211;num-shard \u53c2\u6570\u652f\u6301\u8de8 GPU \u7684\u5f20\u91cf\u5e76\u884c&#xff0c;\u4f46 Ollama \u76ee\u524d\u4ee5\u5355 GPU \u63a8\u7406\u4e3a\u4e3b&#xff0c;\u591a GPU \u652f\u6301\u6709\u9650\u3002<\/p>\n<p>\u53e6\u5916\u4e00\u4e2a\u8fd0\u7ef4\u75db\u70b9&#xff1a;Ollama \u670d\u52a1\u542f\u52a8\u65f6\u4f1a\u81ea\u52a8\u63a2\u6d4b GPU \u578b\u53f7\u548c\u663e\u5b58\u5927\u5c0f&#xff0c;\u6839\u636e\u663e\u5b58\u9009\u62e9\u9ed8\u8ba4\u7684\u91cf\u5316\u7ea7\u522b\u3002\u8fd9\u4e2a\u81ea\u52a8\u63a2\u6d4b\u5728\u5bb9\u5668\u5316\u73af\u5883\u4e0b\u5076\u5c14\u4f1a\u5931\u8d25&#xff0c;\u5bfc\u81f4\u6a21\u578b\u52a0\u8f7d\u65f6\u62a5 &#034;CUDA out of memory&#034; \u9519\u8bef&#xff0c;\u5b9e\u9645\u663e\u5b58\u662f\u5b8c\u5168\u8db3\u591f\u7684\u3002<\/p>\n<h3>\u4e8c\u3001Ollama on K8s \u7684\u90e8\u7f72\u67b6\u6784<\/h3>\n<p>\u67b6\u6784\u5206\u4e3a\u4e09\u5c42&#xff1a;<\/p>\n<p>\u5b58\u50a8\u5c42&#xff1a;\u4f7f\u7528 PersistentVolume \u6301\u4e45\u5316\u6a21\u578b\u6587\u4ef6\u3002Ollama \u901a\u8fc7\u8bbe\u7f6e OLLAMA_MODELS \u73af\u5883\u53d8\u91cf\u6307\u5411 PV \u6302\u8f7d\u8def\u5f84\u3002\u9009\u62e9 ReadWriteOnce \u6a21\u5f0f&#xff08;\u800c\u975e ReadWriteMany&#xff09;&#xff0c;\u56e0\u4e3a\u591a\u4e2a Ollama \u5b9e\u4f8b\u540c\u65f6\u5199\u5165\u540c\u4e00\u6a21\u578b\u6587\u4ef6\u4f1a\u5bfc\u81f4 Blob \u635f\u574f\u3002\u5bf9\u4e8e ReadWriteMany \u573a\u666f&#xff0c;\u4f7f\u7528 initContainer \u901a\u8fc7\u5bf9\u8c61\u5b58\u50a8&#xff08;MinIO\/S3&#xff09;\u4e0b\u8f7d\u6a21\u578b\u5230 emptyDir&#xff08;tmpfs&#xff09;&#xff0c;\u6bcf\u6b21\u91cd\u5efa Pod \u65f6\u91cd\u65b0\u4e0b\u8f7d\u3002<\/p>\n<p>\u8c03\u5ea6\u5c42&#xff1a;\u901a\u8fc7 nodeSelector \u6216 nodeAffinity \u5c06\u63a8\u7406 Pod \u56fa\u5b9a\u5230 GPU \u8282\u70b9\u3002\u5982\u679c\u9700\u8981\u5c06\u4e0d\u540c\u6a21\u578b\u5206\u914d\u5230\u4e0d\u540c GPU \u578b\u53f7\u7684\u8282\u70b9\u4e0a&#xff0c;\u4f7f\u7528\u81ea\u5b9a\u4e49\u7684\u8282\u70b9\u6807\u7b7e&#xff08;\u5982 gpu-type: a100-80g&#xff09;\u3002<\/p>\n<p>\u8d1f\u8f7d\u5747\u8861\u5c42&#xff1a;\u901a\u8fc7 Kubernetes Service \u66b4\u9732 Ollama \u7684 11434 \u7aef\u53e3\u3002\u7531\u4e8e Ollama \u7684 API \u662f HTTP \u957f\u8fde\u63a5&#xff08;\u6d41\u5f0f\u54cd\u5e94\u7684 SSE&#xff09;&#xff0c;Service \u7684 sessionAffinity: ClientIP \u53ef\u5c06\u540c\u4e00\u5ba2\u6237\u7aef\u7684\u591a\u6b21\u8bf7\u6c42\u8def\u7531\u5230\u540c\u4e00 Pod&#xff0c;\u907f\u514d\u6a21\u578b\u91cd\u590d\u52a0\u8f7d\u3002<\/p>\n<h3>\u4e09\u3001\u751f\u4ea7\u7ea7 Ollama Kubernetes \u90e8\u7f72\u914d\u7f6e<\/h3>\n<p>\u4e0b\u9762\u662f\u5b8c\u6574\u7684 Kubernetes \u90e8\u7f72\u6e05\u5355&#xff0c;\u5305\u542b\u5173\u952e\u7684\u751f\u4ea7\u7ea7\u914d\u7f6e\u3002<\/p>\n<p># 1. PersistentVolumeClaim: \u6a21\u578b\u6301\u4e45\u5316\u5b58\u50a8<br \/>\napiVersion: v1<br \/>\nkind: PersistentVolumeClaim<br \/>\nmetadata:<br \/>\n  name: ollama-models<br \/>\nspec:<br \/>\n  # \u4f7f\u7528 local-storage StorageClass&#xff0c;NVMe \u672c\u5730\u76d8\u63d0\u4f9b\u4f4e\u5ef6\u8fdf\u8bfb\u53d6<br \/>\n  # \u6a21\u578b\u6587\u4ef6\u4ee5\u8bfb\u53d6\u4e3a\u4e3b&#xff0c;IOPS \u6bd4\u541e\u5410\u66f4\u91cd\u8981<br \/>\n  storageClassName: local-path<br \/>\n  accessModes:<br \/>\n    &#8211; ReadWriteOnce  # \u9009\u62e9 RWO \u800c\u975e RWX&#xff1a;\u591a Pod \u540c\u65f6\u5199\u6a21\u578b\u6587\u4ef6\u4f1a\u635f\u574f Blob<br \/>\n  resources:<br \/>\n    requests:<br \/>\n      storage: 200Gi  # \u9884\u7559 200GB&#xff0c;\u8986\u76d6\u5e38\u89c1\u5f00\u6e90\u6a21\u578b&#xff08;qwen2.5:7b~72b&#xff09;<\/p>\n<p>&#8212;<br \/>\n# 2. Deployment: Ollama \u63a8\u7406\u670d\u52a1<br \/>\napiVersion: apps\/v1<br \/>\nkind: Deployment<br \/>\nmetadata:<br \/>\n  name: ollama-inference<br \/>\n  labels:<br \/>\n    app: ollama<br \/>\nspec:<br \/>\n  replicas: 2<br \/>\n  selector:<br \/>\n    matchLabels:<br \/>\n      app: ollama<br \/>\n  template:<br \/>\n    metadata:<br \/>\n      labels:<br \/>\n        app: ollama<br \/>\n    spec:<br \/>\n      # \u8c03\u5ea6\u7b56\u7565&#xff1a;\u4ec5\u90e8\u7f72\u5230\u5305\u542b A100 GPU \u7684\u8282\u70b9<br \/>\n      nodeSelector:<br \/>\n        nvidia.com\/gpu.product: &#034;NVIDIA-A100-SXM4-80GB&#034;<\/p>\n<p>      # \u53ef\u9009&#xff1a;\u4f7f\u7528\u4eb2\u548c\u6027\u914d\u5408 GPU \u578b\u53f7<br \/>\n      # affinity:<br \/>\n      #   nodeAffinity:<br \/>\n      #     requiredDuringSchedulingIgnoredDuringExecution:<br \/>\n      #       nodeSelectorTerms:<br \/>\n      #       &#8211; matchExpressions:<br \/>\n      #         &#8211; key: gpu-type<br \/>\n      #           operator: In<br \/>\n      #           values: [&#034;a100-80g&#034;, &#034;h100-80g&#034;]<\/p>\n<p>      # \u5bb9\u5fcd GPU \u8282\u70b9\u7684\u6c61\u70b9 (\u901a\u5e38 GPU \u8282\u70b9\u4f1a\u6dfb\u52a0\u4e13\u7528\u6c61\u70b9)<br \/>\n      tolerations:<br \/>\n        &#8211; key: &#034;nvidia.com\/gpu&#034;<br \/>\n          operator: &#034;Exists&#034;<br \/>\n          effect: &#034;NoSchedule&#034;<\/p>\n<p>      initContainers:<br \/>\n      &#8211; name: model-loader<br \/>\n        image: busybox:1.36<br \/>\n        # \u521d\u59cb\u5316\u5bb9\u5668&#xff1a;\u9a8c\u8bc1\u6a21\u578b\u6587\u4ef6\u5b8c\u6574\u6027&#xff0c;\u82e5\u7f3a\u5931\u5219\u4ece\u5bf9\u8c61\u5b58\u50a8\u4e0b\u8f7d<br \/>\n        # \u5206\u79bb\u4e0b\u8f7d\u903b\u8f91\u5230 initContainer&#xff0c;\u907f\u514d\u63a8\u7406\u5bb9\u5668\u7684\u542f\u52a8\u5ef6\u8fdf<br \/>\n        command:<br \/>\n        &#8211; sh<br \/>\n        &#8211; -c<br \/>\n        &#8211; |<br \/>\n          # \u68c0\u67e5\u6a21\u578b Blob \u662f\u5426\u5b58\u5728\u4e14\u975e\u7a7a<br \/>\n          MODEL_PATH&#061;&#034;\/models\/blobs&#034;<br \/>\n          # \u521b\u5efa\u6a21\u578b\u76ee\u5f55&#xff08;Ollama \u9ed8\u8ba4\u67e5\u627e\u8def\u5f84&#xff09;<br \/>\n          mkdir -p \/models<br \/>\n          echo &#034;Model storage ready at \/models&#034;<br \/>\n        volumeMounts:<br \/>\n        &#8211; name: models<br \/>\n          mountPath: \/models<\/p>\n<p>      containers:<br \/>\n      &#8211; name: ollama<br \/>\n        image: ollama\/ollama:0.6.5<br \/>\n        ports:<br \/>\n        &#8211; containerPort: 11434<br \/>\n          name: http<br \/>\n          protocol: TCP<br \/>\n        env:<br \/>\n        # \u73af\u5883\u53d8\u91cf&#xff1a;\u91cd\u5b9a\u5411\u6a21\u578b\u5b58\u50a8\u5230 PV \u6302\u8f7d\u8def\u5f84<br \/>\n        &#8211; name: OLLAMA_MODELS<br \/>\n          value: &#034;\/models&#034;<br \/>\n        # \u589e\u52a0\u8bf7\u6c42\u8d85\u65f6\u65f6\u95f4&#xff0c;\u6a21\u578b\u63a8\u7406\u53ef\u80fd\u8017\u65f6\u8f83\u957f<br \/>\n        &#8211; name: OLLAMA_KEEP_ALIVE<br \/>\n          value: &#034;10m&#034;  # \u6a21\u578b\u5728\u663e\u5b58\u4e2d\u4fdd\u7559 10 \u5206\u949f&#xff0c;\u907f\u514d\u9891\u7e41\u52a0\u8f7d\u5378\u8f7d<br \/>\n        # \u8bbe\u7f6e\u5e76\u53d1\u9650\u5236 \u2014\u2014 Ollama \u9ed8\u8ba4\u5e76\u53d1\u6570\u8f83\u4f4e&#xff0c;\u5bb9\u6613\u6392\u961f<br \/>\n        &#8211; name: OLLAMA_NUM_PARALLEL<br \/>\n          value: &#034;4&#034;<br \/>\n        # \u8bbe\u7f6e\u6700\u5927\u52a0\u8f7d\u6a21\u578b\u6570 \u2014\u2014 \u53d7\u9650\u4e8e GPU \u663e\u5b58<br \/>\n        &#8211; name: OLLAMA_MAX_LOADED_MODELS<br \/>\n          value: &#034;2&#034;<br \/>\n        resources:<br \/>\n          limits:<br \/>\n            nvidia.com\/gpu: &#034;1&#034;   # \u6bcf\u4e2a Pod \u72ec\u5360 1 \u5f20 GPU<br \/>\n            memory: &#034;64Gi&#034;        # CPU \u5185\u5b58\u4e0a\u9650&#xff1a;\u6a21\u578b\u52a0\u8f7d\u65f6\u4f7f\u7528 CPU \u5185\u5b58\u505a\u4e2d\u8f6c<br \/>\n            cpu: &#034;16&#034;             # CPU \u6838\u5fc3\u6570&#xff1a;\u6a21\u578b\u683c\u5f0f\u8f6c\u6362\u9700\u8981 CPU \u8ba1\u7b97<br \/>\n          requests:<br \/>\n            nvidia.com\/gpu: &#034;1&#034;<br \/>\n            memory: &#034;32Gi&#034;<br \/>\n            cpu: &#034;8&#034;<br \/>\n        # \u5b58\u6d3b\u63a2\u9488&#xff1a;\u901a\u8fc7 Ollama API \u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38<br \/>\n        livenessProbe:<br \/>\n          httpGet:<br \/>\n            path: \/api\/tags<br \/>\n            port: 11434<br \/>\n          initialDelaySeconds: 30  # \u521d\u6b21\u542f\u52a8\u9700\u8981\u52a0\u8f7d\u6a21\u578b\u5230\u663e\u5b58<br \/>\n          periodSeconds: 30<br \/>\n          timeoutSeconds: 10<br \/>\n        # \u5c31\u7eea\u63a2\u9488&#xff1a;Ollama \u670d\u52a1\u53ef\u63a5\u6536\u8bf7\u6c42\u65f6\u6807\u8bb0\u5c31\u7eea<br \/>\n        readinessProbe:<br \/>\n          httpGet:<br \/>\n            path: \/api\/tags<br \/>\n            port: 11434<br \/>\n          initialDelaySeconds: 15<br \/>\n          periodSeconds: 10<br \/>\n        volumeMounts:<br \/>\n        &#8211; name: models<br \/>\n          mountPath: \/models<\/p>\n<p>      volumes:<br \/>\n      &#8211; name: models<br \/>\n        persistentVolumeClaim:<br \/>\n          claimName: ollama-models<\/p>\n<p>&#8212;<br \/>\n# 3. Service: \u63a8\u7406\u670d\u52a1\u5bf9\u5916\u66b4\u9732<br \/>\napiVersion: v1<br \/>\nkind: Service<br \/>\nmetadata:<br \/>\n  name: ollama-inference<br \/>\nspec:<br \/>\n  selector:<br \/>\n    app: ollama<br \/>\n  ports:<br \/>\n  &#8211; port: 11434<br \/>\n    targetPort: 11434<br \/>\n    protocol: TCP<br \/>\n    name: http<br \/>\n  # \u4f1a\u8bdd\u4eb2\u548c\u6027&#xff1a;\u786e\u4fdd\u540c\u4e00\u5ba2\u6237\u7aef\u8bf7\u6c42\u8def\u7531\u5230\u540c\u4e00 Pod<br \/>\n  # Ollama \u7684 keep_alive \u673a\u5236\u4f9d\u8d56\u6b64\u914d\u7f6e<br \/>\n  sessionAffinity: ClientIP<br \/>\n  sessionAffinityConfig:<br \/>\n    clientIP:<br \/>\n      timeoutSeconds: 600  # 10 \u5206\u949f&#xff0c;\u4e0e OLLAMA_KEEP_ALIVE \u5bf9\u9f50<br \/>\n  type: ClusterIP<\/p>\n<p>\u5173\u952e\u914d\u7f6e\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>OLLAMA_KEEP_ALIVE: 10m&#xff1a;\u6a21\u578b\u52a0\u8f7d\u540e\u4f1a\u5728\u663e\u5b58\u4e2d\u4fdd\u7559 10 \u5206\u949f\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0&#xff0c;\u6bcf\u6b21\u8bf7\u6c42\u7ed3\u675f\u540e\u7acb\u5373\u5378\u8f7d\u6a21\u578b&#xff0c;\u4e0b\u6b21\u8bf7\u6c42\u53c8\u8981\u91cd\u65b0\u52a0\u8f7d&#xff08;\u51b7\u542f\u52a8\u5ef6\u8fdf 10s&#043;&#xff09;\u3002<\/li>\n<li>sessionAffinity: ClientIP&#xff1a;\u914d\u5408 keep_alive \u4f7f\u7528\u3002\u65e0\u6b64\u914d\u7f6e\u65f6&#xff0c;\u8bf7\u6c42\u88ab\u8f6e\u8be2\u5230\u4e0d\u540c Pod&#xff0c;\u6bcf\u4e2a Pod \u90fd\u9700\u8981\u72ec\u7acb\u52a0\u8f7d\u6a21\u578b&#xff0c;\u663e\u5b58\u6d6a\u8d39\u4e25\u91cd\u3002<\/li>\n<li>OLLAMA_NUM_PARALLEL: 4&#xff1a;\u8c03\u6574\u5e76\u53d1\u63a8\u7406\u6570\u3002\u9ed8\u8ba4\u503c\u8f83\u5c0f&#xff08;\u901a\u5e38\u4e3a 1&#xff09;&#xff0c;\u5bf9\u4e8e\u9700\u8981\u5e76\u53d1\u5904\u7406\u8bf7\u6c42\u7684\u751f\u4ea7\u73af\u5883&#xff0c;\u9700\u8981\u589e\u5927\u6b64\u503c\u3002<\/li>\n<\/ul>\n<h3>\u56db\u3001\u751f\u4ea7\u90e8\u7f72\u7684\u9002\u7528\u8fb9\u754c\u4e0e\u6743\u8861<\/h3>\n<p>\u9002\u7528\u573a\u666f&#xff1a;<\/p>\n<ul>\n<li>\u6a21\u578b\u89c4\u6a21\u56fa\u5b9a&#xff08;3-5 \u4e2a\u6a21\u578b&#xff09;&#xff0c;\u63a8\u7406\u6d41\u91cf\u53ef\u9884\u6d4b\u3002<\/li>\n<li>\u5bf9 GPU \u5229\u7528\u7387\u6709\u660e\u786e\u6307\u6807&#xff0c;\u9700\u8981 Kubernetes \u7ba1\u7406\u591a\u79cd GPU \u578b\u53f7\u8282\u70b9\u7684\u6df7\u5408\u96c6\u7fa4\u3002<\/li>\n<li>\u56e2\u961f\u5df2\u5177\u5907 Kubernetes \u8fd0\u7ef4\u80fd\u529b&#xff0c;\u65e0\u9700\u989d\u5916\u5f15\u5165\u4e13\u7528\u63a8\u7406\u5e73\u53f0\u3002<\/li>\n<\/ul>\n<p>\u4e0d\u9002\u7528\u573a\u666f&#xff1a;<\/p>\n<ul>\n<li>\u9700\u8981\u52a8\u6001\u52a0\u8f7d\u51e0\u5341\u4e2a\u4e0d\u540c\u6a21\u578b\u7684\u5e73\u53f0\u3002K8s \u7684\u8c03\u5ea6\u7c92\u5ea6\u662f Pod \u7ea7\u522b&#xff0c;\u6bcf\u4e2a\u6a21\u578b\u4e00\u4e2a Deployment \u4f1a\u5bfc\u81f4\u7ba1\u7406\u590d\u6742\u5ea6\u6025\u5267\u4e0a\u5347\u3002<\/li>\n<li>GPU \u663e\u5b58\u9700\u8981\u8de8 Pod \u5171\u4eab\u7684\u5bc6\u96c6\u63a8\u7406\u573a\u666f&#xff08;\u5982\u4f7f\u7528 MIG \u5207\u5206\u7684 GPU&#xff09;\u3002<\/li>\n<li>\u9700\u8981\u6781\u4f4e\u5ef6\u8fdf&#xff08;&lt;10ms&#xff09;\u7684\u63a8\u7406\u573a\u666f\u3002Ollama \u7531\u4e8e\u4f7f\u7528 llama.cpp \u540e\u7aef&#xff0c;\u7b2c\u4e00 token \u5ef6\u8fdf\u5728 100-500ms \u91cf\u7ea7\u3002<\/li>\n<\/ul>\n<p>\u4e3b\u8981\u6743\u8861&#xff1a;<\/p>\n<li>PV \u7684 ReadWriteOnce vs ReadWriteMany&#xff1a;RWO \u6027\u80fd\u6700\u9ad8\u4e14\u7a33\u5b9a&#xff0c;\u4f46\u9650\u5236\u4e86 Pod \u5fc5\u987b\u5728\u540c\u4e00\u8282\u70b9\u4e0a\u3002\u5982\u679c\u9700\u8981\u591a\u8282\u70b9\u5171\u4eab\u6a21\u578b\u6587\u4ef6&#xff0c;\u5219\u9700\u8981\u5f15\u5165\u5bf9\u8c61\u5b58\u50a8\u7684\u4e0b\u8f7d\u6d41\u7a0b\u3002<\/li>\n<li>\u6a21\u578b\u9884\u4e0b\u8f7d vs \u6309\u9700\u62c9\u53d6&#xff1a;\u9884\u4e0b\u8f7d&#xff08;initContainer&#xff09;\u4fdd\u8bc1\u4e86\u9996\u6b21\u8bf7\u6c42\u7684\u5ef6\u8fdf&#xff0c;\u4f46\u521d\u59cb\u5316\u65f6\u95f4\u8f83\u957f\u3002\u6309\u9700\u62c9\u53d6\u542f\u52a8\u5feb&#xff0c;\u4f46\u7b2c\u4e00\u4e2a\u7528\u6237\u7684\u4f53\u9a8c\u6781\u5dee\u3002<\/li>\n<li>OLLAMA_KEEP_ALIVE \u7684\u503c\u9009\u62e9&#xff1a;\u8bbe\u7f6e\u8fc7\u5927\u6d6a\u8d39\u663e\u5b58&#xff0c;\u8bbe\u7f6e\u8fc7\u5c0f\u5bfc\u81f4\u9891\u7e41\u7684\u6a21\u578b\u52a0\u8f7d\/\u5378\u8f7d\u3002\u9700\u8981\u6839\u636e\u5b9e\u9645\u6d41\u91cf\u6a21\u5f0f\u91c7\u6837\u540e\u786e\u5b9a\u3002<\/li>\n<h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<li>Ollama \u7684 K8s \u90e8\u7f72\u6838\u5fc3\u662f\u4e09\u4ef6\u4e8b&#xff1a;GPU \u8bbe\u5907\u6302\u8f7d&#xff08;nvidia-device-plugin&#xff09;\u3001\u6a21\u578b\u6301\u4e45\u5316&#xff08;PV &#043; OLLAMA_MODELS&#xff09;\u3001\u8c03\u5ea6\u4eb2\u548c\u6027&#xff08;nodeSelector\/affinity&#xff09;\u3002<\/li>\n<li>sessionAffinity: ClientIP \u4e0e OLLAMA_KEEP_ALIVE \u914d\u5408&#xff0c;\u662f\u907f\u514d\u591a Pod \u91cd\u590d\u52a0\u8f7d\u6a21\u578b\u7684\u5173\u952e\u914d\u7f6e\u7ec4\u5408\u3002<\/li>\n<li>initContainer \u5206\u79bb\u6a21\u578b\u4e0b\u8f7d\u903b\u8f91&#xff0c;\u4fdd\u8bc1\u4e86\u63a8\u7406\u5bb9\u5668\u542f\u52a8\u7684\u5feb\u901f\u6027\u548c\u786e\u5b9a\u6027\u3002<\/li>\n<li>PersistentVolume \u9009\u62e9 RWO \u6a21\u5f0f&#xff08;\u800c\u975e RWX&#xff09;&#xff0c;\u907f\u514d\u591a\u4e2a Ollama \u5b9e\u4f8b\u5e76\u53d1\u5199\u5165\u65f6\u6a21\u578b Blob \u635f\u574f\u3002<\/li>\n<li>\u751f\u4ea7\u73af\u5883\u4e2d\u5e94\u8bbe\u7f6e\u5408\u7406\u7684 OLLAMA_NUM_PARALLEL \u548c OLLAMA_MAX_LOADED_MODELS&#xff0c;\u5e73\u8861\u5e76\u53d1\u80fd\u529b\u4e0e\u663e\u5b58\u5229\u7528\u7387\u3002<\/li>\n","protected":false},"excerpt":{"rendered":"<p>Ollama \u5728 Kubernetes \u4e0a\u7684\u751f\u4ea7\u5316\u90e8\u7f72&#xff1a;GPU \u62d3\u6251\u611f\u77e5\u8c03\u5ea6\u4e0e\u8282\u70b9\u4eb2\u548c\u6027\u914d\u7f6e<br \/>\n\u4e00\u3001Ollama \u88f8\u8dd1 K8s \u7684\u4e09\u5927\u81f4\u547d\u95ee\u9898<br \/>\n\u76f4\u63a5\u4f7f\u7528 ollama\/ollama \u955c\u50cf\u90e8\u7f72\u5230 Kubernetes&#xff0c;\u4f1a\u7acb\u523b\u9047\u5230\u4e09\u4e2a\u95ee\u9898\u3002\u7b2c\u4e00\u4e2a\u662f GPU \u4e0d\u53ef\u89c1&#xff1a;\u5bb9\u5668\u9ed8\u8ba4\u6ca1\u6709\u6302\u8f7d NVIDIA \u8bbe\u5907&#xff0c;\u9700\u8981 nvidia-device-plugin \u548c\u6b63\u786e\u7684 nvidia.com\/gpu \u8d44\u6e90\u58f0\u660e\u3002\u7b2c\u4e8c\u4e2a\u662f\u6a21\u578b\u5b58\u50a8&amp;#xff1<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[50],"topic":[],"class_list":["post-83124","post","type-post","status-publish","format-standard","hentry","category-server","tag-50"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Ollama \u5728 Kubernetes \u4e0a\u7684\u751f\u4ea7\u5316\u90e8\u7f72\uff1aGPU \u62d3\u6251\u611f\u77e5\u8c03\u5ea6\u4e0e\u8282\u70b9\u4eb2\u548c\u6027\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/83124.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ollama \u5728 Kubernetes \u4e0a\u7684\u751f\u4ea7\u5316\u90e8\u7f72\uff1aGPU \u62d3\u6251\u611f\u77e5\u8c03\u5ea6\u4e0e\u8282\u70b9\u4eb2\u548c\u6027\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Ollama \u5728 Kubernetes \u4e0a\u7684\u751f\u4ea7\u5316\u90e8\u7f72&#xff1a;GPU \u62d3\u6251\u611f\u77e5\u8c03\u5ea6\u4e0e\u8282\u70b9\u4eb2\u548c\u6027\u914d\u7f6e \u4e00\u3001Ollama \u88f8\u8dd1 K8s \u7684\u4e09\u5927\u81f4\u547d\u95ee\u9898 \u76f4\u63a5\u4f7f\u7528 ollama\/ollama \u955c\u50cf\u90e8\u7f72\u5230 Kubernetes&#xff0c;\u4f1a\u7acb\u523b\u9047\u5230\u4e09\u4e2a\u95ee\u9898\u3002\u7b2c\u4e00\u4e2a\u662f GPU \u4e0d\u53ef\u89c1&#xff1a;\u5bb9\u5668\u9ed8\u8ba4\u6ca1\u6709\u6302\u8f7d NVIDIA \u8bbe\u5907&#xff0c;\u9700\u8981 nvidia-device-plugin \u548c\u6b63\u786e\u7684 nvidia.com\/gpu \u8d44\u6e90\u58f0\u660e\u3002\u7b2c\u4e8c\u4e2a\u662f\u6a21\u578b\u5b58\u50a8&amp;#xff1\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/83124.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-25T09:17:02+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/83124.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/83124.html\",\"name\":\"Ollama \u5728 Kubernetes \u4e0a\u7684\u751f\u4ea7\u5316\u90e8\u7f72\uff1aGPU \u62d3\u6251\u611f\u77e5\u8c03\u5ea6\u4e0e\u8282\u70b9\u4eb2\u548c\u6027\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-25T09:17:02+00:00\",\"dateModified\":\"2026-07-25T09:17:02+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/83124.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/83124.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/83124.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Ollama \u5728 Kubernetes \u4e0a\u7684\u751f\u4ea7\u5316\u90e8\u7f72\uff1aGPU \u62d3\u6251\u611f\u77e5\u8c03\u5ea6\u4e0e\u8282\u70b9\u4eb2\u548c\u6027\u914d\u7f6e\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Ollama \u5728 Kubernetes \u4e0a\u7684\u751f\u4ea7\u5316\u90e8\u7f72\uff1aGPU \u62d3\u6251\u611f\u77e5\u8c03\u5ea6\u4e0e\u8282\u70b9\u4eb2\u548c\u6027\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/83124.html","og_locale":"zh_CN","og_type":"article","og_title":"Ollama \u5728 Kubernetes \u4e0a\u7684\u751f\u4ea7\u5316\u90e8\u7f72\uff1aGPU \u62d3\u6251\u611f\u77e5\u8c03\u5ea6\u4e0e\u8282\u70b9\u4eb2\u548c\u6027\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Ollama \u5728 Kubernetes \u4e0a\u7684\u751f\u4ea7\u5316\u90e8\u7f72&#xff1a;GPU \u62d3\u6251\u611f\u77e5\u8c03\u5ea6\u4e0e\u8282\u70b9\u4eb2\u548c\u6027\u914d\u7f6e \u4e00\u3001Ollama \u88f8\u8dd1 K8s \u7684\u4e09\u5927\u81f4\u547d\u95ee\u9898 \u76f4\u63a5\u4f7f\u7528 ollama\/ollama \u955c\u50cf\u90e8\u7f72\u5230 Kubernetes&#xff0c;\u4f1a\u7acb\u523b\u9047\u5230\u4e09\u4e2a\u95ee\u9898\u3002\u7b2c\u4e00\u4e2a\u662f GPU \u4e0d\u53ef\u89c1&#xff1a;\u5bb9\u5668\u9ed8\u8ba4\u6ca1\u6709\u6302\u8f7d NVIDIA \u8bbe\u5907&#xff0c;\u9700\u8981 nvidia-device-plugin \u548c\u6b63\u786e\u7684 nvidia.com\/gpu \u8d44\u6e90\u58f0\u660e\u3002\u7b2c\u4e8c\u4e2a\u662f\u6a21\u578b\u5b58\u50a8&amp;#xff1","og_url":"https:\/\/www.wsisp.com\/helps\/83124.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-25T09:17:02+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/83124.html","url":"https:\/\/www.wsisp.com\/helps\/83124.html","name":"Ollama \u5728 Kubernetes \u4e0a\u7684\u751f\u4ea7\u5316\u90e8\u7f72\uff1aGPU \u62d3\u6251\u611f\u77e5\u8c03\u5ea6\u4e0e\u8282\u70b9\u4eb2\u548c\u6027\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-25T09:17:02+00:00","dateModified":"2026-07-25T09:17:02+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/83124.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/83124.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/83124.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Ollama \u5728 Kubernetes \u4e0a\u7684\u751f\u4ea7\u5316\u90e8\u7f72\uff1aGPU \u62d3\u6251\u611f\u77e5\u8c03\u5ea6\u4e0e\u8282\u70b9\u4eb2\u548c\u6027\u914d\u7f6e"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/83124","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=83124"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/83124\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=83124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=83124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=83124"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=83124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}