For a regular helm-chart I can use helm package --app-version="foo-bar" to be able to overwrite app-version while packing the helm chart.
Is there a way to achieve the same with sub-charts.
Consider the following helm-chart structure
uber-chart
\sub-chart-1
\sub-chart-2
\sub-chart-3
Is it possible to pass different app-versions to different sub-charts while packaging uber-chart?
Related
I have an umbrella chart containing multiple subcharts. I want to ensure that the subcharts are installed in a given order since some of them have dependencies on the others. Specifying them as hook resources can only control the order within the sub chart. Is there a way to control the order in such a way that the subcharts get installed in the specified order?
Helm itself does not provide any tolling to control the installation order of the dependency charts. However, you can use any helm controller or CI/CD tool like Flux to manage such dependency order.
Here, is an example of managing order of charts using Flux CD: https://fluxcd.io/docs/components/helm/helmreleases/#helmrelease-dependencies
I have multiple charts that all use the same templates. Is it possible to instruct helm to use some other templates directory, or have some shared templates that I can import/reference in some way? I would like to avoid the copy paste and have reusable templates, but at the same time keep the project/service per chart because in the future there will be some discrepancies.
How do you achieve DRY and re-usability in helm?
To me, that sounds like you want to use so called "Library Charts" ( link to helm docs).
To create one, you define a helm chart that does not actually create any Resources but only defines reusable templates and set the type property in the chart.yml to library:
apiVersion: v2
name: library-chart
description: A Helm chart for Kubernetes
type: library
version: 0.0.1
Then, you can include that helm chart as a dependency in your other charts and start using the templates defined there.
I have several microservices that have practically the same settings in YAML, some values change (e.g. image, version, a specific environment variable ...), and they are in different repositories, with a different pipeline each. How do I use the same template between them without getting repeated code?
This is how we do it in the place I currently work.
We have our own generic Helm chart that is version controlled and hosted in our Artifactory, every parameter in that chart that may need changing is exposed in values.yaml.
The Artifactory gets added to helm as repository, then you only need separate a values.yaml for each microservice you want deployed as the chart gets sourced centrally.
helm install -f values.yaml microservice01 artifcatory/global-helm-chart
On top of that we use helmfile, but this is not necessary in order to achieve your goal.
The key points are:
make the chart generic
host it centrally
add the repository to helm.
You can also update the values.yaml from pipeline and then package the chart and deploy it..In that way you can still have the same yaml file but the values will differ from which pipeline they are deployed.
Alternatively and easy way will be to maintain different values.yaml for different environment in the helm chart itself and pass them during helm install/upgrade from pipeline.
We do it for about 90 microservices. We have common Chart and we run values file through kindof sed script which changes what we need. Then whole package gets deployed
I need to install a helm chart with a key/value that is not present in one of the templates and I prefer not to edit the already existing templates.
In particular, I need to change resources.limits.cpu and resources.limits.memory in k8s-job-template.yaml but resources is not even mentioned in that file.
Is there a solution for this?
The only customizations it's possible to make for a Helm chart are those the chart author has written in; you can't make arbitrary additional changes to the YAML files.
(Kustomize allows merges of arbitrary YAML content and is built into recent kubectl, but it doesn't have some of the lifecycle or advanced templating features of Helm.)
For future reference, I found a solution to this.
Simply download the chart using the following command:
helm fetch <chart> --untar --destination /local/path/to/chart
Go to the folder /local/path/to/chart/<chartname> and make the desired changes.
After this, simply install the helm chart based on the locally edited chart:
helm install /local/path/to/chart/<chartname>
Is there a way to create own boilerplate helm chart and then generate from it helm charts for my micro services (which will differ only in chart names)?
Yes, you'd need to create a package of your base boilerplate chart and then reference it in the requirements.yaml for other charts which depend on it.
Ref: https://helm.sh/docs/developing_charts/#chart-dependencies
Use helm create command to create boiler template, then changes are up to yourself.
$ helm create mychart
Ref: https://helm.sh/docs/helm/#helm-create