You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用JSON Patch命令为Kubernetes Deployment添加命令参数

给Kubernetes Deployment添加--insecure命令参数的kubectl patch实现

你可以使用以下JSON类型的kubectl patch命令,直接在Deployment的容器命令数组末尾追加--insecure参数:

kubectl patch deploy xxxx --type='json' -p='[{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "--insecure"}]'

命令细节说明:

  • op: "add":明确操作类型为添加元素
  • path: "/spec/template/spec/containers/0/command/-":
    • /spec/template/spec/containers/0:定位到Deployment Pod模板中的第一个容器(如果有多个容器,调整数字索引即可,比如1对应第二个容器)
    • /command/-:特殊语法,表示在command数组的末尾插入新元素
  • value: "--insecure":指定要添加的具体命令参数

验证修改结果

执行完patch命令后,用以下命令确认修改是否生效:

kubectl get deploy xxxx -o yaml | grep -A 5 "command:"

输出会显示包含--insecure的命令数组,与你期望的清单结构一致。

内容的提问来源于stack exchange,提问作者Nitin G

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 18:05:26