How to handle helm chart dependencies as part of CI/CD pipelines? Keep reading to find out. We’ll explore helm charts SDLC in the context of charts dependencies and base CI/CD on it.
If you later find this article useful take a look at the disclaimer for information on how to thank me.
Introduction
As you may already know, helm charts might depend on other helm charts. Use dependencies field of Chart.yaml for listing chart’s dependencies. Yet, many questions may arise about how to treat dependencies while building robust CI/CD helm chart pipelines. We’ve already seen how to test helm charts. Let’s focus now on helm charts SDLC with respect to their dependencies.
helm chart dependencies – little theory
It’s important to understand that while a chart may list multiple helm charts as its dependencies, it’s installed as a single release along with its dependencies. View relevant docs here and here. In addition, there are various helm dependency commands.
helm charts SDLC in the context of dependencies
Find below the suggested SDLC process for development of charts with respect to their dependencies. CI/CD processes would rely and mimic it in order to ensure stable dependency versions.
- put reference to chart dependencies into
dependenciesfield ofChart.yaml. Use specific versions rather than version ranges. If you don’t, below commands must be followed religiously. - run
helm repo addfor each dependency repository. - run
helm dependency build. This command will reconstruct the dependencies according toChart.lockfile if it exists. If it doesn’t, this command will behave ashelm dependency update. It, in turn, createsChart.lockfile for the first time and downloads the dependencies tochartsfolder. - do version control
Chart.lockfile and putchartsfolder to.gitignore.Chart.lockfile will be used by CI/CD processes. - the chart can either be installed from the chart repository folder or packaged using
helm packagecommand and installed from the resulting archive. Note, that the archive containschartsfolder which contains the dependency charts.
CI/CD build and release pipeline will be very much based on the above SDLC:
- run
helm repo addfor each dependency repository. - run
helm dependency build. - run
helm package - push the chart to Artifact registry (e.g. Artifactory)
helm charts dependencies important guidelines
- always run
helm dependency updateafter changes todependenciesfield inChart.yaml. It will update the lock file. Of course, commit and push this change together with changes toChart.yamlin order to avoid CI/CD pipelines failures. - version control
Chart.lockfile and putchartsfolder to.gitignore. This way, the dependencies will be downloaded tochartsfolder during the pipelines, their versions matching information in the lock file. Finally, the pipelines will package the chart folder includingchartsfolder. This point is critical. It ensures that the released chart has the same dependencies (specified in the lock file) that the chart’s developer used during local testing.
You can practice the above flow on a sample WordPress helm chart.
Summary
That’s it about helm charts dependencies and its CI/CD. As always, feel free to share. If you found this article useful, take a look at the disclaimer for information on how to thank me.
- Become a Certified Kubernetes Administrator (CKA)!
- Become a Certified Kubernetes Application Developer (CKAD)!
- BUNDLE KUBERNETES FUNDAMENTALS & CKA CERTIFICATION (COURSE & CERTIFICATION) FOR THE BEST DEAL! $499 ONLY!
Recommended Kubernetes courses on Pluralsight:
- Packaging Applications with Helm for Kubernetes
- Automating Kubernetes Deployments Using a GitOps Workflow
Sign up using this link to get exclusive discounts like 50% off your first month or 15% off an annual subscription)
Recommended Kubernetes books on Amazon:
