📎 配套脚本附件正文未内嵌 · 共 4 个 · 点开可在线查看
📂 查看全部 761 个脚本附件 →
⚠️ 脚本内含明文凭据(与本页正文一致),请勿在公网环境直接运行。
基础设施 · 案例

K8s GPU 单私有化集群完整案例

中等规模:3 Master + 6 Worker;Operator → vLLM → Harbor/GitLab/Argo → 207 LiteLLM 切流;不装机。

基础设施 · K8s GPU 单私有化集群完整案例

定位:中等企业样板的端到端纸面跟读——单套私有化 GPU 集群从节点规划 → GPU Operator → vLLM → Harbor/GitLab/Argo CD → 207 LiteLLM 切流。

边界:本环境(207 / 116)资源不够,不在此教程真装 K8s / Operator / Harbor / GitLab / Argo CD;YAML 与命令仅供实验集群跟读。

对照现状:应用仍在 192.168.110.207(Dify + LiteLLM Compose/systemd);GPU 现状是 116.62.10.183 Docker vLLM;本案例把 GPU 侧演进到 K8s 池,LiteLLM 只改 upstream。

姊妹篇(理论):K8s GPU · Operator · Harbor/GitLab/Argo CD · Argo CD 原理与部署教程

实战对照:作业17 GPU/K8s 与模型路由 · 路由发布 Runbook · LiteLLM 高级功能

清单目录:patches_cursor/基础设施_K8s_GPU_单私有化集群完整案例/

HTML:docs/html_cursor/基础设施_K8s_GPU_单私有化集群完整案例/基础设施_K8s_GPU_单私有化集群完整案例_cursor.html


目录

  1. 案例目标与边界
  2. 拓扑与网络规划
  3. 集群就绪验收
  4. GPU Operator 安装与验收
  5. 推理工作负载(vLLM)
  6. Harbor · GitLab · Argo CD
  7. 对上现网:207 LiteLLM 切流
  8. 配额、限流与值班清单
  9. 故障树
  10. 验收总表与文件清单
  11. 完整配置附录

1. 案例目标与边界

1.1 你要带走什么

读完并能在实验集群跟读后,应能说清并演练:

#能力
1画出「单私有化 GPU 集群」节点角色与污点/标签
2用 Operator 把 nvidia.com/gpu 变成可调度资源并验收
3用 GitOps 发两个推理 Deployment(主模型 + 小模型)
4在 不动 Dify 的前提下,改 207 LiteLLM 把流量切到集群,并能回滚到 116

1.2 案例约定拓扑(中等企业样板)

角色数量规格约定(纸面)说明
Control Plane3无 GPU,8C/32GHA kubeadm / 等价托管控制面
GPU Worker6每节点 2× L40S(示意)专跑推理;污点 NoSchedule
可调度 GPU 合计12nvidia.com/gpu配额先锁 gpu-infer≤8 张,留缓冲
镜像仓1Harbor harbor.example.local可与集群同机房或旁路
代码仓1GitLab gitlab.example.local存 manifests
GitOps1Argo CD(可装在本集群或管理集群)本案例装在本集群 argocd NS
应用/网关现状207 Dify + LiteLLM不迁入本集群
flowchart LR
  subgraph APP["现网应用面 · 207"]
    DIFY[Dify :80]
    LITELLM[LiteLLM :4000]
    DIFY --> LITELLM
  end

  subgraph NOW["现状 GPU · 116"]
    DOCKER[Docker vLLM :8000]
  end

  subgraph CASE["本案例 · 单私有化 GPU 集群"]
    ARGO[Argo CD]
    OP[GPU Operator]
    VLLM1[vllm-qwen36-27b ×2]
    VLLM2[vllm-qwen-small ×1]
    ING[Ingress]
    ARGO --> VLLM1
    ARGO --> VLLM2
    OP -.->|nvidia.com/gpu| VLLM1
    OP -.-> VLLM2
    VLLM1 --> ING
    VLLM2 --> ING
  end

  LITELLM -->|切流后主上游| ING
  LITELLM -.->|回滚/备上游| DOCKER
  GL[GitLab] --> ARGO
  HB[Harbor] --> VLLM1

1.3 明确不做


2. 拓扑与网络规划

2.1 命名与网段(占位)

项案例值
集群名gpu-k8s-prod-01
API Serverhttps://k8s-api.gpu-k8s.example.local:6443
推理 Ingress*.gpu-k8s.example.local
模型存储NFS / 并行文件系统 StorageClass:nfs-models
Pod CIDR / Service CIDR按机房规范;需与 207 路由可达

关键点:207 上的 LiteLLM 必须能解析并访问 vllm-qwen.gpu-k8s.example.local(内网 DNS 或 /etc/hosts 演练),否则切流必失败。

2.2 命名空间

完整文件:patches_cursor/基础设施_K8s_GPU_单私有化集群完整案例/01-namespaces.yaml

Namespace用途
gpu-operatorOperator 及 DaemonSet
gpu-infer全部推理 Deployment / Service / Ingress
argocdArgo CD(若装在本集群)

2.3 节点标签与污点

在每台 GPU Worker 上约定:

bash
# 纸面命令 —— 在实验集群执行,勿对 116 乱打 taint
kubectl label node gpu-w01 nvidia.com/gpu.present=true --overwrite
kubectl label node gpu-w01 nvidia.com/gpu.product=NVIDIA-L40S --overwrite
kubectl taint nodes gpu-w01 nvidia.com/gpu=true:NoSchedule
机制作用
nvidia.com/gpu.present=trueDeployment nodeSelector 只落 GPU 节点
nvidia.com/gpu=true:NoSchedule无 toleration 的普通 Pod 上不来
GFD(Operator)自动补卡型等标签,亲和性更好写

配额与备注 ConfigMap:02-quota-and-node-notes.yaml。


3. 集群就绪验收

控制面与 CNI 就绪后再装 Operator。最低检查:

bash
kubectl get nodes -o wide
# 期望:3× control-plane Ready;6× worker Ready

kubectl get pods -A | grep -E 'calico|cilium|flannel|kube-system'
# CNI / dns 无 CrashLoop

kubectl get cs   # 老版本;新版本看 component status 等价检查

验收口诀:节点 Ready → CoreDNS 正常 → 任意非 GPU Pod 能调度成功 → 再进入第 4 节。


4. GPU Operator 安装与验收

理论背景见姊妹篇「§3 NVIDIA GPU Operator」。本案例用 Helm values 片段:

patches_cursor/基础设施_K8s_GPU_单私有化集群完整案例/07-gpu-operator-values.yaml

bash
# 纸面 —— 版本号以 NVIDIA 文档稳定版为准
helm repo add nvidia https://helm.ngc.nvidia.com/nvidia
helm repo update
helm upgrade --install gpu-operator nvidia/gpu-operator \
  -n gpu-operator --create-namespace \
  -f patches_cursor/基础设施_K8s_GPU_单私有化集群完整案例/07-gpu-operator-values.yaml

4.1 组件就绪

bash
kubectl get pods -n gpu-operator
# 期望各节点:driver(若启用)/ toolkit / device-plugin / gfd / dcgm-exporter Running

kubectl describe node gpu-w01 | findstr /C:"nvidia.com/gpu"
# Linux: kubectl describe node gpu-w01 | grep -A8 Capacity

期望 Capacity / Allocatable 出现类似:

text
nvidia.com/gpu: 2

(每 Worker 2 卡 → 全集群 Allocatable 合计 12。)

4.2 冒烟:占 1 卡的 Job

yaml
apiVersion: batch/v1
kind: Job
metadata:
  name: gpu-smoke
  namespace: gpu-infer
spec:
  template:
    spec:
      restartPolicy: Never
      nodeSelector:
        nvidia.com/gpu.present: "true"
      tolerations:
        - key: nvidia.com/gpu
          operator: Equal
          value: "true"
          effect: NoSchedule
      containers:
        - name: cuda-smoke
          image: harbor.example.local/ai/cuda-sample:vectorAdd
          resources:
            limits:
              nvidia.com/gpu: "1"
bash
kubectl apply -f 01-namespaces.yaml
kubectl apply -f - <<'EOF'
# …上列 Job…
EOF
kubectl logs job/gpu-smoke -n gpu-infer
kubectl delete job gpu-smoke -n gpu-infer

Pass:Job Completed,日志显示 CUDA device OK;Fail:Pending + Insufficient nvidia.com/gpu → 回查 Device Plugin。


5. 推理工作负载(vLLM)

5.1 模型与副本策略

Deployment逻辑模型名副本卡/副本用途
vllm-qwen36-27bqwen3.6-27b21对齐现网主模型;滚动更新可保 1 副本在线
vllm-qwen-smallqwen-small11演示多模型路由 / 低成本分流

卡占用:2+1=3,在配额 8 以内,剩余给评测或扩容。

5.2 完整清单

文件内容
03-vllm-qwen-deployment.yaml主模型 Deployment + PVC
04-vllm-service-ingress.yaml小模型 Deployment、双 Service、Ingress

要点(与理论篇一致):

5.3 集群内验收

bash
kubectl -n gpu-infer get deploy,po,svc,ingress
kubectl -n gpu-infer rollout status deploy/vllm-qwen36-27b

# 集群内探活(示例)
kubectl -n gpu-infer run curl --rm -it --image=curlimages/curl -- \
  curl -sS http://vllm-qwen36-27b:8000/health

从 207 侧(切流前)应先能:

bash
curl -sS http://vllm-qwen.gpu-k8s.example.local/health
curl -sS http://vllm-qwen.gpu-k8s.example.local/v1/models

6. Harbor · GitLab · Argo CD

Argo CD 概念、安装、Application 详解见 Argo CD 原理与部署教程。

6.1 流水线(与理论篇案例 C 同构)

text
开发改 manifests / CI 出镜像
        │
        ▼
  Harbor  ←  push ai/vllm-openai:v0.8.5
        │
  GitLab  ←  overlays/prod 更新 image tag
        │
  Argo CD ←  sync Application gpu-infer-workloads
        │
  gpu-infer NS 滚动更新 vLLM

Application 样例见文末 附录 E · 05-argo-application.yaml(与 patches_cursor/…/05-… 同文)。

bash
kubectl apply -f patches_cursor/基础设施_K8s_GPU_单私有化集群完整案例/05-argo-application.yaml
argocd app get gpu-infer-workloads
# 或
kubectl -n argocd get application gpu-infer-workloads

6.2 Git 仓建议布局

text
gpu-infer-manifests/
  base/           # Deployment / Service 公共
  overlays/prod/  # 副本数、tag、Ingress host
  overlays/lab/

口诀不变:镜像进 Harbor · 声明进 GitLab · 真相以 Git 为准 · Argo 负责落地。

6.3 与本环境缩样的对应

完整 GitOps(本案例)本环境缩样(作业17)
Argo sync Deployment116 上改 Docker / compose
Harbor tag手工拉镜像
Git 改路由 YAML改 patches_cursor/LiteLLM部署/config.yaml + restart

LiteLLM 路由仍在 207,不进 Argo(本案例边界);集群内推理清单进 Argo。


7. 对上现网:207 LiteLLM 切流

7.1 目标状态

text
Dify → LiteLLM(207:4000) model=qwen3.6-27b
         │ 主
         └─► http://vllm-qwen.gpu-k8s.example.local/v1
         │ 备(fallback)
         └─► http://116.62.10.183:8000/v1   # 现网 Docker,作回滚锚点

完整配置样例见文末 附录 F · 06-litellm-cutover-config.yaml(与 patches_cursor/…/06-… 同文)。

7.2 切流步骤(仍走作业17 Runbook 纪律)

  1. 预检:集群 /health、/v1/models 从 207 可达;主 Deployment Ready≥1。
  2. 备份:拷贝现网 /opt/litellm/config.yaml 与 Git 中 patches_cursor/LiteLLM部署/config.yaml。
  3. 改路由:以 06-litellm-cutover-config.yaml 为蓝本合并进生产 config(主 api_base 改 Ingress;保留 qwen3.6-27b-docker116 + fallbacks)。
  4. 发布:同步到 207 → systemctl restart litellm(或你们现网等价方式)。
  5. 验收:
bash
# 在 207 或开发机
curl -sS http://192.168.110.207:4000/v1/chat/completions \
  -H "Authorization: Bearer sk-litellm-bocheng-207" \
  -H "Content-Type: application/json" \
  -d "{\"model\":\"qwen3.6-27b\",\"messages\":[{\"role\":\"user\",\"content\":\"ping\"}],\"max_tokens\":16}"
  1. 审计一行:谁、何时、主 upstream 从 116:8000 改为 vllm-qwen.gpu-k8s…,回滚命令是什么。

7.3 灰度建议

阶段做法
灰 1新增逻辑名 qwen3.6-27b-k8s,仅内部 curl / 测试 Agent 使用
灰 2生产 qwen3.6-27b 切主到 K8s,fallback 仍指向 116
灰 3观察 1~3 天:延迟、5xx、GPU 利用率;再考虑缩 116 副本

7.4 回滚(先路由、后工作负载)

bash
# 1)路由回滚:api_base 改回 http://116.62.10.183:8000/v1,去掉或倒置 fallback
# 2)restart litellm,curl 验收
# 3)若 K8s 侧坏了:Argo 回滚 Application 或 git revert overlays/prod

顺序与 作业17 模型路由配置发布 Runbook 一致:先回滚路由,避免流量打坏 upstream。


8. 配额、限流与值班清单

8.1 集群内

项案例约定
ResourceQuotagpu-infer 最多 8 卡(见 02-quota-and-node-notes.yaml)
副本上限主模型建议 ≤4(留卡给小模型/批任务)
监控DCGM Exporter → 已有 Prometheus/Grafana 体系(见集成环境部署专题)

8.2 网关侧(207)

项说明
timeout / max_retries见切流 config;避免拖死 Worker
fallbacks私有挂了回 116
SLA继续用现网 Exporter 探 LiteLLM;可另加探 Ingress /health

8.3 日检(一页)


9. 故障树

现象优先查处置方向
Pod Pending · Insufficient nvidia.com/gpuDevice Plugin、配额、是否超售等卡 / 降副本 / 查 Operator
Pod Pending · 污点toleration 是否写上补 toleration 或去掉误 taint
CUDA driver version is insufficient节点驱动 vs 镜像 CUDA升驱动或换镜像 tag
镜像 ImagePullBackOffHarbor 连通、secret、tag拉通仓库;固定 digest
Argo OutOfSync / 反复自愈失败Git 与活集群被人肉 kubectl 改飘禁止生产手改;以 Git 为准
LiteLLM 5xx / 超时207→Ingress 网络、上游 health、超时设置先 curl Ingress;再 fallback 回 116
切流后答得慢副本不足、排队、显存扩副本或临时回 116,再容量规划
只有配置页/部分 Agent 异常多半不是 K8s;查 Dify 插件与专题十七与 GPU 池解耦排查

NVIDIA 事件速查习惯与作业17 Part B 相同:kubectl describe po / kubectl get events -n gpu-infer --sort-by=.lastTimestamp。


10. 验收总表与文件清单

10.1 端到端验收(实验集群 + 207 配置演练)

步骤Pass 标准
节点3 CP + 6 GPU Worker Ready;GPU 节点有污点与标签
Operatornvidia.com/gpu 可调度;冒烟 Job 成功
工作负载主×2 + 小×1 Running;Service/Ingress 通
GitOpsApplication Synced;改 tag 能滚动
切流LiteLLM 主上游指向 Ingress;fallback 指向 116
回滚改回 116 后 chat 恢复;有审计记录

10.2 仓库文件

路径说明
docs/md_cursor/基础设施_K8s_GPU_单私有化集群完整案例/本文
patches_cursor/…/01-namespaces.yamlNS(附录 A)
…/02-quota-and-node-notes.yaml配额与节点约定(附录 B)
…/03-vllm-qwen-deployment.yaml主模型(附录 C)
…/04-vllm-service-ingress.yaml小模型 + Service + Ingress(附录 D)
…/05-argo-application.yamlArgo Application(附录 E)
…/06-litellm-cutover-config.yaml207 切流样例(全文见附录 F)
…/07-gpu-operator-values.yamlOperator Helm values 片段(附录 G)

10.3 和现状的一句话对照

text
现在:  Dify/LiteLLM@207  →  Docker vLLM@116
目标:  Dify/LiteLLM@207  →  Ingress→vLLM@单私有化 GPU K8s(116 作 fallback)
理论:  见姊妹篇;多集群/公网分配仍读理论篇,不在本案例展开

11. 完整配置附录

下列正文与 patches_cursor/基础设施_K8s_GPU_单私有化集群完整案例/ 下同名文件全文一致,便于离线阅读与复制;kubectl apply / 合并配置时仍可用仓库路径。

附录 A · 01-namespaces.yaml

路径:patches_cursor/基础设施_K8s_GPU_单私有化集群完整案例/01-namespaces.yaml

yaml
# 案例集群命名空间(纸面跟读,勿在 207/116 执行)
apiVersion: v1
kind: Namespace
metadata:
  name: gpu-operator
---
apiVersion: v1
kind: Namespace
metadata:
  name: gpu-infer
  labels:
    purpose: inference
---
apiVersion: v1
kind: Namespace
metadata:
  name: argocd

附录 B · 02-quota-and-node-notes.yaml

路径:patches_cursor/基础设施_K8s_GPU_单私有化集群完整案例/02-quota-and-node-notes.yaml

yaml
# gpu-infer 命名空间配额:最多 8 张卡(案例约定)
apiVersion: v1
kind: ResourceQuota
metadata:
  name: gpu-infer-quota
  namespace: gpu-infer
spec:
  hard:
    requests.nvidia.com/gpu: "8"
    limits.nvidia.com/gpu: "8"
    requests.cpu: "64"
    requests.memory: 256Gi
    pods: "40"
---
# GPU 节点污点:只跑推理(控制面 / 普通业务需容忍或避开)
# 实际执行:kubectl taint nodes gpu-w01 nvidia.com/gpu=true:NoSchedule
# 下列为文档对照用示意;污点通常用 kubectl / 节点 bootstrap,不靠本文件 apply
apiVersion: v1
kind: ConfigMap
metadata:
  name: gpu-node-ops-notes
  namespace: gpu-infer
data:
  taint: "nvidia.com/gpu=true:NoSchedule"
  label_present: "nvidia.com/gpu.present=true"
  label_product: "nvidia.com/gpu.product=NVIDIA-L40S"

附录 C · 03-vllm-qwen-deployment.yaml

路径:patches_cursor/基础设施_K8s_GPU_单私有化集群完整案例/03-vllm-qwen-deployment.yaml

yaml
# 主模型:qwen3.6-27b(对齐现网逻辑名);1 卡;挂载模型 PVC
apiVersion: apps/v1
kind: Deployment
metadata:
  name: vllm-qwen36-27b
  namespace: gpu-infer
  labels:
    app: vllm-qwen36-27b
    model: qwen3.6-27b
spec:
  replicas: 2
  selector:
    matchLabels:
      app: vllm-qwen36-27b
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
  template:
    metadata:
      labels:
        app: vllm-qwen36-27b
        model: qwen3.6-27b
    spec:
      nodeSelector:
        nvidia.com/gpu.present: "true"
      tolerations:
        - key: nvidia.com/gpu
          operator: Equal
          value: "true"
          effect: NoSchedule
      containers:
        - name: vllm
          image: harbor.example.local/ai/vllm-openai:v0.8.5
          args:
            - --model
            - /models/qwen3.6-27b
            - --served-model-name
            - qwen3.6-27b
            - --host
            - 0.0.0.0
            - --port
            - "8000"
            - --tensor-parallel-size
            - "1"
          ports:
            - name: http
              containerPort: 8000
          env:
            - name: HUGGING_FACE_HUB_TOKEN
              valueFrom:
                secretKeyRef:
                  name: hf-token
                  key: token
                  optional: true
          resources:
            requests:
              cpu: "8"
              memory: 48Gi
              nvidia.com/gpu: "1"
            limits:
              cpu: "16"
              memory: 64Gi
              nvidia.com/gpu: "1"
          readinessProbe:
            httpGet:
              path: /health
              port: http
            initialDelaySeconds: 60
            periodSeconds: 10
          livenessProbe:
            httpGet:
              path: /health
              port: http
            initialDelaySeconds: 120
            periodSeconds: 20
          volumeMounts:
            - name: model
              mountPath: /models/qwen3.6-27b
              readOnly: true
      volumes:
        - name: model
          persistentVolumeClaim:
            claimName: pvc-qwen36-27b
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-qwen36-27b
  namespace: gpu-infer
spec:
  accessModes: ["ReadOnlyMany"]
  resources:
    requests:
      storage: 80Gi
  storageClassName: nfs-models

附录 D · 04-vllm-service-ingress.yaml

路径:patches_cursor/基础设施_K8s_GPU_单私有化集群完整案例/04-vllm-service-ingress.yaml

yaml
# 备模 / 小模型占位:演示多 Deployment + 路由分流
apiVersion: apps/v1
kind: Deployment
metadata:
  name: vllm-qwen-small
  namespace: gpu-infer
  labels:
    app: vllm-qwen-small
    model: qwen-small
spec:
  replicas: 1
  selector:
    matchLabels:
      app: vllm-qwen-small
  template:
    metadata:
      labels:
        app: vllm-qwen-small
        model: qwen-small
    spec:
      nodeSelector:
        nvidia.com/gpu.present: "true"
      tolerations:
        - key: nvidia.com/gpu
          operator: Equal
          value: "true"
          effect: NoSchedule
      containers:
        - name: vllm
          image: harbor.example.local/ai/vllm-openai:v0.8.5
          args:
            - --model
            - /models/qwen-small
            - --served-model-name
            - qwen-small
            - --host
            - 0.0.0.0
            - --port
            - "8000"
          ports:
            - name: http
              containerPort: 8000
          resources:
            requests:
              cpu: "4"
              memory: 24Gi
              nvidia.com/gpu: "1"
            limits:
              nvidia.com/gpu: "1"
              memory: 32Gi
          readinessProbe:
            httpGet:
              path: /health
              port: http
            initialDelaySeconds: 45
            periodSeconds: 10
          volumeMounts:
            - name: model
              mountPath: /models/qwen-small
              readOnly: true
      volumes:
        - name: model
          persistentVolumeClaim:
            claimName: pvc-qwen-small
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-qwen-small
  namespace: gpu-infer
spec:
  accessModes: ["ReadOnlyMany"]
  resources:
    requests:
      storage: 40Gi
  storageClassName: nfs-models
---
apiVersion: v1
kind: Service
metadata:
  name: vllm-qwen36-27b
  namespace: gpu-infer
spec:
  selector:
    app: vllm-qwen36-27b
  ports:
    - name: http
      port: 8000
      targetPort: http
---
apiVersion: v1
kind: Service
metadata:
  name: vllm-qwen-small
  namespace: gpu-infer
spec:
  selector:
    app: vllm-qwen-small
  ports:
    - name: http
      port: 8000
      targetPort: http
---
# 对 207 LiteLLM 暴露:内网 Ingress(示例域名)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: vllm-ingress
  namespace: gpu-infer
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: "32m"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "300"
spec:
  ingressClassName: nginx
  rules:
    - host: vllm-qwen.gpu-k8s.example.local
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: vllm-qwen36-27b
                port:
                  number: 8000
    - host: vllm-small.gpu-k8s.example.local
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: vllm-qwen-small
                port:
                  number: 8000

附录 E · 05-argo-application.yaml

路径:patches_cursor/基础设施_K8s_GPU_单私有化集群完整案例/05-argo-application.yaml

yaml
# Argo CD Application:以 Git 为准同步到「单」私有化 GPU 集群
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: gpu-infer-workloads
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://gitlab.example.local/ai-platform/gpu-infer-manifests.git
    targetRevision: main
    path: overlays/prod
  destination:
    server: https://kubernetes.default.svc
    namespace: gpu-infer
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true
  # 生产可改为手动 sync;案例演示 automated + selfHeal

附录 F · 06-litellm-cutover-config.yaml

路径:patches_cursor/基础设施_K8s_GPU_单私有化集群完整案例/06-litellm-cutover-config.yaml

yaml
# 207 LiteLLM 切流样例:主上游 → K8s Ingress;备上游 → 现网 116 Docker vLLM
# 对照:patches_cursor/LiteLLM部署/config.yaml、作业17 主备路由
# 变更仍走:备份 → diff → 拷到 /opt/litellm → systemctl restart litellm → curl 验收

model_list:
  - model_name: qwen3.6-27b
    litellm_params:
      model: openai/qwen3.6-27b
      api_base: http://vllm-qwen.gpu-k8s.example.local/v1
      api_key: "sk-cluster-gpu"
      timeout: 300
      max_retries: 2
      extra_body:
        chat_template_kwargs:
          enable_thinking: false

  # 回滚锚点:现网 116 Docker vLLM
  - model_name: qwen3.6-27b-docker116
    litellm_params:
      model: openai/qwen3.6-27b
      api_base: http://116.62.10.183:8000/v1
      api_key: "123456"
      timeout: 300
      max_retries: 0

  - model_name: qwen-small
    litellm_params:
      model: openai/qwen-small
      api_base: http://vllm-small.gpu-k8s.example.local/v1
      api_key: "sk-cluster-gpu"
      timeout: 120
      max_retries: 1

litellm_settings:
  drop_params: true
  set_verbose: false
  request_timeout: 300
  num_retries: 2
  fallbacks:
    - qwen3.6-27b: [qwen3.6-27b-docker116]

router_settings:
  routing_strategy: simple-shuffle

general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY

附录 G · 07-gpu-operator-values.yaml

路径:patches_cursor/基础设施_K8s_GPU_单私有化集群完整案例/07-gpu-operator-values.yaml

yaml
# GPU Operator Helm values 片段(纸面跟读;版本号以官网稳定版为准)
# helm upgrade --install gpu-operator nvidia/gpu-operator \
#   -n gpu-operator --create-namespace -f 07-gpu-operator-values.yaml

driver:
  enabled: true
toolkit:
  enabled: true
devicePlugin:
  enabled: true
dcgmExporter:
  enabled: true
gfd:
  enabled: true
migManager:
  enabled: false
# 若节点已由 OS 镜像固化驱动,可改 driver.enabled=false,只装 toolkit + plugin
operator:
  defaultRuntime: containerd

修订记录

日期说明
2026-09-01首版:中等规模单集群完整案例(应用留 207、GPU 进 K8s、GitOps + LiteLLM 切流)
2026-09-01文末增加 01~07 完整配置附录(与 patches 同文)