我正在使用kustomize并尝试将一些头盔参数修补到grafana配置中,我具有以下配置文件grafana.yaml:
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: prod-k8s-grafana
labels:
environment: prod
project: k8s
role: grafana
spec:
project: prod-k8s
source:
repoURL: 'https://github.com/helm/charts.git'
path: 'stable/grafana'
targetRevision: 'ba1d08a129255167457480e29339ab5bfe75d918'
helm:
parameters:
- name: service.type
value: LoadBalancer
syncPolicy:
automated:
prune: true
destination:
namespace: prod-k8s-grafana
然后,我有了我的kustomization文件,该文件用于添加修补值-专门添加到头盔参数部分。当我添加如下所示的补丁程序时,它会修补值,但会删除grafana.yaml文件中定义的原始名称值:
patches:
- target:
kind: Application
patch: |-
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: xxx
spec:
destination:
server: https://DSKJHDAKJSH4HDSKHDKSJ0E56C7420CCF041E9.sk1.eu-west-2.eks.amazonaws.com
- target:
kind: Application
name: prod-k8s-grafana
patch: |-
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: prod-k8s-grafana
spec:
source:
helm:
parameters:
- name: 'datasources."datasources\.yaml".datasources[0].url'
value: 'http://prod-k8s-prometheus-cluster02-server.prod-k8s-prometheus.svc.cluster.local'
- name: persistence.storageClassName
value: gp2
- name: 'datasources."datasources\.yaml".apiVersion'
value: '1'
- name: 'datasources."datasources\.yaml".datasources[0].name'
value: Prometheus
这样,当我检查运行kustomize build
命令时,它将删除输出:
- name: service.type
value: LoadBalancer
因此,修补这些名称和值似乎会覆盖grafana.yaml中的参数。
如何确保补丁在补丁名称后附加一个值,而不是覆盖?
答案 0 :(得分:0)
我最近遇到了同样的问题,不知道这是否是完美的解决方案,但是如果您使用patchesJson6902
并在0位置添加env变量,则不会删除另一个变量:
- op: add
path: /spec/template/spec/containers/0/env/0
value:
name: ONE
value: '1'
- op: add
path: /spec/template/spec/containers/0/env/0
value:
name: TWO
value: '2'
- op: add
path: /spec/template/spec/containers/0/env/0
value:
name: THREE
value: '3'