我尝试使用kubectl patch向 kubernetes 部署的 args 列表添加另外两个值。我已经查看了官方记录的(https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/)变体,但没有设法在一个时间。
假设这个简单的部署:
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
spec:
replicas: 1
selector:
matchLabels:
name: test
template:
metadata:
labels:
name: test
name: test
spec:
containers:
- image: alpine
name: test
command:
- echo
args:
- my
- text
Run Code Online (Sandbox Code Playgroud)
我现在想向该args部分附加其他值。这一次只适用于一个值:
kubectl patch deployments.apps test --type=json -p='[{"op": "add", "path": "/spec/t
emplate/spec/containers/0/args/-", "value": "additional" }]'
Run Code Online (Sandbox Code Playgroud)
这有效,并给我留下了以下内容:
...
args:
- my
- text
- additional
Run Code Online (Sandbox Code Playgroud)
但是使用一组值运行补丁会给我一个错误:
# running:
k patch deployments.apps test …Run Code Online (Sandbox Code Playgroud)