我想用一个命令修补 Kubernetes 部署中的所有kubectl patch
容器模板,而不必知道它们的名称。那可能吗?
我知道我可以通过awk
,和实现替换sed
,但我更喜欢在表达式中使用类似 a 的东西......jq
kubectl replace
[*]
特定容器规范的补丁命令
kubectl patch deployment mydeployment -p '{"spec":{"template":{"spec":{"containers":[{"name":"myname","imagePullPolicy":"Always"}]}}}}'
示例部署
apiVersion: extensions/v1beta1
kind: Deployment
spec:
replicas: 1
template:
spec:
containers:
- image: example.com/my/fancyimage:latest
imagePullPolicy: Never
name: myname
dnsPolicy: ClusterFirst
restartPolicy: Always