我有一個 Kubernetes 部署并正在運行:(為簡潔起見,省略了一些欄位)
apiVersion: apps/v1
kind: Deployment
metadata:
name: argocd-server
namespace: argocd
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: argocd-server
template:
metadata:
creationTimestamp: null
labels:
app.kubernetes.io/name: argocd-server
spec:
containers:
- name: argocd-server
image: quay.io/argoproj/argocd:v2.2.5
command:
- argocd-server
我想為現有部署創建一個補丁,以向command容器添加某些引數:
- '--insecure'
- '--basehref'
- /argocd
我在這里閱讀了有關kubectl patch命令的檔案,但我不確定如何實際選擇要修補的容器(按名稱或索引)。覆寫完整串列(在補丁檔案中給出該行)
會很好,但我想防止在補丁檔案中給出完整的規范。command:- argocd-servercontainers:
uj5u.com熱心網友回復:
您可以按索引選擇容器,例如:
kubectl patch deployment argocd-server -n argocd --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/command", "value": ["argocd-server", "--insecure"]}]'
uj5u.com熱心網友回復:
感謝@Blokje5 的啟發,我能夠構建這兩個選項:
JSON 方法
排隊
kubectl patch deployment argocd-server -n argocd --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/command", "value": ["argocd-server", "--insecure", "--basehref", "/argocd"]}]'
帶補丁檔案
patch.json
[
{
"op": "replace",
"path": "/spec/template/spec/containers/0/command",
"value": [
"argocd-server",
"--insecure",
"--basehref",
"/argocd"
]
}
]
kubectl -n argocd patch deployment argocd-server --type='json' --patch-file patch.json
YAML 方法
yaml 檔案
patch.yaml
---
op: replace
spec:
template:
spec:
containers:
- name: argocd-server
command:
- argocd-server
- --insecure
- --basehref
- /argocd
kubectl -n argocd patch deployment argocd-server --patch-file patch.yaml
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/431109.html
上一篇:如何更改docker默認存盤大小
下一篇:Python缺少self引數
