I have a little bit strange question, but maybe you can advise right way for this implementation.
I read about Helm Dependencies - when you can set the list of necessary charts and install them during your "main" chart install.
Is it possible to have this list of dependencies (with versions) without "main/root" chart?
For example - I want to install to my k8s cluster rabbit, redis, postgres and few my custom charts.
I don't want to run few times "helm chart install..." - I want to have one file with the list of helms/versions and install them in one command.
Also I want to easy upgrade helm charts using my the same one file - I want to change version, run again one command and update only necessary helm charts (with different versions).
Is it possible, or, maybe I should use something another for this?
CodePudding user response:
There's no actual requirement that a Helm chart contain any templates of its own. It's possible to have a Helm chart that only contains dependencies; then running helm install
on that "parent" chart would install all of the dependencies.
It would be valid to run helm create
to build a new chart, then delete the values.yaml
file and template
directory from the generator, and fill in the requirements in Chart.yaml
.
In your setup you're just installing infrastructure services. Occasionally you will see a dependency-only chart like this used to install several application components as well; this is sometimes called an umbrella chart. There are potential problems around umbrella charts where Helm likes to combine together dependencies: if different application components depend on different major versions of some chart there can be a conflict, and if you have multiple components that each depend on, say, Redis, an umbrella-chart installation will typically install just one shared Redis rather than an isolated Redis per component.
There are a number of ways to group multiple helm install
commands into a single execution. Just writing a simple shell script will often work, depending on your needs. General-purpose automation tools (Ansible, Salt Stack, Chef) may have ways to run Helm, or if not, then to run arbitrary commands. There are also a couple of Helm-specific tools here: Helmsman is simpler and Helmfile more complex, but both let you "install" a collection of related charts without necessarily building an umbrella chart.
CodePudding user response:
What you describe at the beginning of your question is called "Umbrella Charts". These are Charts that are used to bundle other Charts and manage these as one unit.
If this is not what you want to do (that's how I understand your question), then you are required to use other tools. One such tool is Helmfile, which allows you to define a list of Helm Charts, their versions and Helm Values. You can then install/upgrade/uninstall all referenced Helm Charts in one go.
Another option is to use kluctl (disclaimer: I'm the main developer of it). It basically allows you to do the same as offered by Helmfile, but in a different way/style. Kluctl focuses on Kustomize deployments while allowing you to easily pull-in third-party Helm Charts.
Having the mentioned Helm Charts in a Kluctl deployment would require you to have a kluctl deployment project that looks like this:
my_project
├── third-party
│ ├── rabbit
│ │ ├── kustomization.yaml
│ │ ├── helm-chart.yaml
│ │ └── helm-values.yaml
│ ├── redis
│ │ ├── kustomization.yaml
│ │ ├── helm-chart.yaml
│ │ └── helm-values.yaml
│ └── deployment.yaml
├── deployment.yaml
└── .kluctl.yaml
my_project/deployment.yaml
vars:
- values:
# this is arbitrary yaml
my:
ns: my-namespace
# this is also possible, loading vars from a file...
# many other sources are supported as well
# - file: my-config.yaml
deployments:
- include: third-party
commonLabels:
my.example.com/deployment: my-example-deployment
my.example.com/target: {{ target.name }}
my_project/third-party/deployment.yaml
deployments:
- path: rabbit
- path: redis
my_project/third-party/rabbit/kustomization.yaml
resources:
# this file is auto-generated by the helm-integration
- deploy.yaml
my_project/third-party/rabbit/helm-chart.yaml
helmChart:
repo: https://charts.bitnami.com/bitnami
chartName: rabbitmq
chartVersion: 10.3.2
releaseName: my-rabbit
# my.ns comes from the 'vars' defined in the root deployment.yaml
namespace: "{{ my.ns }}"
output: deploy.yaml
my_project/third-party/rabbit/helm-values.yaml
auth:
username: my-user
password: you-would-of-course-never-do-this
my_project/third-party/redis/helm-chart.yaml and helm-values.yaml
Basically the same as for rabbitmq, but with redis specific settings.
my_project/.kluctl.yaml
targets:
- name: dev
context: my-dev-cluster-context
Using kluctl
Based on the above example, you would then run kluctl helm-pull
from the root project directory, which will then pre-pull all involved Helm Charts and write the contents besides the helm-chart.yaml files. These pre-pulled Charts are meant to be added to you version control (this might change in the future).
After that, you can run commands like kluctl diff -t dev
, kluctl deploy -t dev
and kluctl prune -t dev
to work with the deployment.
kluctl helm-upgrade
will help you while upgrading the pre-pulled Helm Charts.
Fully working example
A fully working example can be found here. The shown yamls from above are only meant to give an idea about the Helm related stuff.