4
votes

I'm using helm charts to deploy around 15 microservices. There is a parent helm chart with requirements.yaml where the all the required microservices are listed as dependencies.

Sample requirements.yaml file:

dependencies:
  - name: service1
    repository: "@stable"
    version: <version>
  - name: service2
    repository: "@stable"
    version: <version>
  - name: service3
    repository: "@stable"
    version: <version>
  - name: service4
    repository: "@stable"
    version: <version>
    condition: false

When I run helm dependency update all the charts that are listed as dependency are downloaded. There are scenarios where few services are under development and are not required to be deployed in production.

We have different artifactory for prod and non-prod environment and the disabled services are not in prod artifactory. Hence it gives an error saying helm chart missing. I understand that the condition flag doesn't install the dependency but how can I stop it from downloading the dependency ?

1
I don't think the solution you want is possible. All you could do is write a script that helm fetch 's the charts .tgz files into /charts and omit the one(s) you don't wantDean coakley

1 Answers

0
votes

It might come a bit late, but I sorted out a similar problem recently and I thought it might help others to share. You can use the condition key when declaring dependencies in your Chart.yaml:

dependencies:
- condition: gitea.cache.builtIn.enabled
  name: memcached
  repository: https://charts.bitnami.com/bitnami
  version: 4.2.20

With the bit in values.yaml being as follows:

[...]
gitea:
  cache:
    builtIn:
      enabled: true
[...]

This example is extracted from the fantastic gitea helm chart repo and should be self explanatory. However, you can take a look at Helm documentation

Be aware that if there are nested charts more than 2 levels deep, helm2 might misbehave so I recommend you to take a look at Helm3 for that.

Finally please note that in my case (as I'm following a small detour when deploying Helm charts, the check for the condition happens when rendering the helm chart not when running helm dependency update