Deploy with Helm
Use Helm in a Codefresh pipeline
Helm is the package manager for Kubernetes. Codefresh has comprehensive support for Helm:
- You get a free built-in Helm repository with each Codefresh account.
- You can track your charts in the Helm chart dashboard.
- You can view your deployments in your Helm Release dashboard.
- You can view Helm releases in the Environment dashsboard.
- You can promote Helm releases in your Helm promotion dashboard.
- You can add any external Helm repository on any other cloud provider.
Codefresh also provides a pipeline step for deploying with Helm.
For more insights on Helm charts see also our Helm best practices guide.
The example Helm project
You can see the example project at https://github.com/codefresh-contrib/helm-sample-app. The repository contains a simple Go application, a Dockerfile and an example chart.
You need to have added at least one Kubernetes cluster in your Codefresh account.
Notice that if you still use Helm 2 you should also have installed the server side of Helm 2 (Tiller) using
helm init. This command is best run from the cloud console of your cluster. The respective pipelines of this guide are in the helm-2 branch.
CI/CD pipeline with Helm deployment
It is possible to deploy directly a Helm chart as it exists on the filesystem. This is not the recommended way to use Helm, because you are bypassing the Helm chart repository, but it is certainly the simplest Helm pipeline possible.
Here is the whole pipeline:
This pipeline does the following:
- Clones the source code with a Git clone step
- Builds a docker image using a Build step
- Deploys the Helm chart to a cluster named
my-demo-k8s-clusterusing the Helm step from the Step Marketplace.
Note that in this example
charts/helm-example refers to the filesystem location in the code that was just checked out.
The deployment will be visible in the Helm releases dashboard.
If you want to run this example yourself, make sure to edit the chart and put your own values there for the Docker image.
CI/CD pipeline with Helm deployment that also stores the chart
It is recommended to use a Helm repository to store your chart before deploying it. This way you know what is deployed in your clusters and you can also reuse charts in other installations.
First of all you need to import in your pipeline from the shared configuration the settings for the internal Helm repository (or any other external repository that you have setup in Codefresh). This will make available the internal Helm repository to your pipeline so that it can push/pull Helm charts from it.
Once that is done you can change your pipeline to also store the chart first and then deploy it.
Here is the whole pipeline:
After you finish running your pipeline, not only the deployment will take place, but you will also see your chart in your Helm Chart dashboard:
It is also possible to run your own Helm commands in a Codefresh pipeline.