如何使用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
相关产品推荐
相关产品推荐

