Reputation: 3438
I'm using kustomize and attempting to patch some helm parameters into the grafana configuration I have the below configuration file 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
Then I have my kustomization file which I'm using to add patched values- specifically to the helm parameters section. When I add a patch like below, it patches the values, but it remove the original name value defined in the grafana.yaml file:
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
So that when I check run kustomize build
command, the the output it removes:
- name: service.type
value: LoadBalancer
It therefore appears that patching these name and values overwrites the parameters from grafana.yaml.
How can I ensure the patch appends the patched name a vales, rather than overwriting?
Upvotes: 1
Views: 4487
Reputation: 359
I got the same issue recently, don't know if this is the perfect solution but if you use patchesJson6902
and add env variables at the position 0 it won't delete the other one :
- 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'
Upvotes: 3