0

I'm wondering about the way to override a default value for a dependency chart.

Let's go straight to the point, having this kustomization file for Prometheus:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
helmCharts:
- name: prometheus
  releaseName: prometheus
  repo: https://prometheus-community.github.io/helm-charts
  version: 23.0.0
  namespace: monitoring

I want to define for example the storageClass value for the alermanager chart which is a dependency of Prometheus chart. This is the folder structure created when try to build the chart.

.
├── charts
│   ├── prometheus
│   │   ├── Chart.lock
│   │   ├── Chart.yaml
│   │   ├── README.md
│   │   ├── charts
│   │   │   ├── alertmanager
│   │   │   │   ├── Chart.yaml
│   │   │   │   ├── README.md
│   │   │   │   ├── ci
│   │   │   │   │   └── config-reload-values.yaml
│   │   │   │   ├── templates
│   │   │   │   │   ├── NOTES.txt
│   │   │   │   │   ├── _helpers.tpl
│   │   │   │   │   ├── configmap.yaml
│   │   │   │   │   ├── ingress.yaml
│   │   │   │   │   ├── pdb.yaml
│   │   │   │   │   ├── serviceaccount.yaml
│   │   │   │   │   ├── services.yaml
│   │   │   │   │   ├── statefulset.yaml
│   │   │   │   │   └── tests
│   │   │   │   │       └── test-connection.yaml
│   │   │   │   ├── values.schema.json
│   │   │   │   └── values.yaml                               <-- Override a value here
│   │   ├── templates
│   │   │   ├── NOTES.txt
│   │   │   ├── _helpers.tpl
│   │   │   ├── clusterrole.yaml
│   │   │   ├── clusterrolebinding.yaml
│   │   │   ├── cm.yaml
│   │   │   ├── deploy.yaml
│   │   │   ├── extra-manifests.yaml
│   │   │   ├── headless-svc.yaml
│   │   │   ├── ingress.yaml
│   │   │   ├── network-policy.yaml
│   │   │   ├── pdb.yaml
│   │   │   ├── psp.yaml
│   │   │   ├── pvc.yaml
│   │   │   ├── rolebinding.yaml
│   │   │   ├── service.yaml
│   │   │   ├── serviceaccount.yaml
│   │   │   ├── sts.yaml
│   │   │   └── vpa.yaml
│   │   ├── values.schema.json
│   │   └── values.yaml
│   └── prometheus-23.0.0.tgz
└── kustomization.yaml

Question:

How can I override a value in a dependency chart using Kustomize?

Jose Rodriguez
  • 9,753
  • 13
  • 36
  • 52
  • With Kustomize, you patch specific Kubernetes resources. What resource generated by the chart do you want to patch? The only resource I see for which a storageClass would make sense is a PersistentVolumeClaim that is part of the prometheus chart, not alertmanager. – larsks Jul 07 '23 at 23:29
  • I can patch for example the volumeClaimTemplate for the alertmanager StatefulSet for example, but the generation of another resources in some dependecy charts depends from the property value in the values.yaml file for that chart. – Jose Rodriguez Jul 09 '23 at 08:32

1 Answers1

0

You can define Helm values in Kustomize either inline or via files. These values will override the default ones of the Helm chart as you'd do with Helm outside Kustomize.

helmCharts:
- name: prometheus
  releaseName: prometheus
  repo: https://prometheus-community.github.io/helm-charts
  version: 23.0.0
  namespace: monitoring

  # Inline
  valuesInline:
    somekey: somevalue

  # Values files:
  valuesFile: values.yaml
  additionalValuesFiles:
  - values-file-1.yml
  - values-file-2.yml

Documentation

Gaël J
  • 11,274
  • 4
  • 17
  • 32