You can use Helm Conditions to easily specify which dependencies should be installed.
I've created an example to illustrate how it works.
I have two dependencies declared in the Chart.yaml
and I've defined in the values.yaml
file that only redis
should be installed:
$ cat test-chart/Chart.yaml
...
dependencies:
- name: redis
version: "15.x.x"
repository: "https://charts.bitnami.com/bitnami"
condition: redis.enabled
- name: memcached
version: "5.x.x"
repository: "https://charts.bitnami.com/bitnami"
condition: memcached.enabled
$ cat test-chart/values.yaml
...
redis:
enabled: true
memcached:
enabled: false
Let's install this chart to make sure only redis
is installed:
$ helm install chart-1 test-chart
NAME: chart-1
LAST DEPLOYED: Wed Nov 10 11:18:44 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
chart-1-redis-master-0 1/1 Running 0 107s
chart-1-redis-replicas-0 1/1 Running 0 107s
chart-1-redis-replicas-1 1/1 Running 0 66s
chart-1-redis-replicas-2 1/1 Running 0 32s
As you can see from the above output, memcached
wasn't installed as expected.
Now suppose we want to install memcached
instead of redis
. All we need to do is change memcached.enabled
and redis.enabled
in the values.yaml
file and upgrade the release:
$ cat test-chart/values.yaml
...
redis:
enabled: false
memcached:
enabled: true
$ helm upgrade chart-1 test-chart
Release "chart-1" has been upgraded. Happy Helming!
NAME: chart-1
LAST DEPLOYED: Wed Nov 10 11:21:49 2021
NAMESPACE: default
STATUS: deployed
REVISION: 2
TEST SUITE: None
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
chart-1-memcached-86847c8c4f-nt5wv 1/1 Running 0 21s
Everything seems fine, redis
was uninstalled and memcached
was installed.