Managing Helm releases

Manage Helm deployments from the Codefresh UI

Codefresh has built-in integration for Helm that provides a unique view into your production Kubernetes cluster.
In Helm Releases, you can see the current status of your cluster, including the currently deployed releases, their previous revisions including change tracking, and even roll back to a previous release.

Codefresh also offers an environment view for Helm releases as well as a promotion dashboard.

View Helm releases and release information

View all the Helm releases in your cluster, and drill down into a specific release to see its services, deployed versions, manifests and more.

NOTE
Make sure you have connected your Kubernetes cluster to Codefresh.

  1. In the Codefresh UI, from DevOps Insights in the sidebar, select Helm Releases.

Helm Releases

Helm Releases
  1. To see details for a specific release, click the release name.

Kubernetes Services

Kubernetes Services

The History tab shows all previous releases.

Helm History

Helm History

You can further expand a release revision to see exactly what files were changed in this release.

Helm diff

Helm diff

There are other tabs that show you the chart used, the values as well as the final manifests that were actually deployed.

Final rendered manifests

Final rendered manifests

Add labels to Kubernetes services

For better visibility into services, add the recommended labels to your Kubernetes service.

  apiVersion: v1
kind: Service
metadata:
  name: {{ template "fullname" . }}
  labels:
    app.kubernetes.io/name: "{{ template "name" . }}"  
    helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    app.kubernetes.io/managed-by: "{{ .Release.Service  }}"
    app.kubernetes.io/instance: "{{ .Release.Name }}"   

To use the instance label for something different, you can also use a release label instead:

release: {{ .Release.Name }}

Add an upgrade message

Codefresh allows you to display a meaningful description for each release in the release history. This message can help show the main reason behind each release, or any other message that is convenient for you.

Helm release message

Helm release message

You can set this message for your Helm release in three ways:

  1. When you manually install a Helm release from the Helm charts screen, there is a field for this message.
  2. Set the property commit_message inside the notes.txt file of your chart.
  3. By providing an environment variable called COMMIT_MESSAGE within your Helm pipeline step.

Roll back a Helm release

You can rollback to a previous revision of a release in the History tab.

  1. Click the Helm release for which to perform a rollback, and then click the History tab.
  2. To rollback to a specific release, click Rollback in the row.

Rolling back to a previous release

Rolling back to a previous release

NOTE
It takes time to complete rollback for a release, and the change in the cluster is not instantly updated in the Codefresh UI. If you also use a custom rollback pipeline, the delay between the cluster update and the UI refresh is even longer.

Helm UI actions

From the main release screen, you have some additional actions.

Select the row with the desired chart, and:

  • Issue a Helm test by clicking on the ‘Run Test’ button.
  • Delete a release by clicking on the ‘Delete’ button.
    For deletion options, see the Helm delete documentation. For example, purge removes the revision from the release history.

Helm deployment badge

Similar to a build badge, you can also get a deployment badge for a Helm release.

  1. In the Codefresh UI, from the DevOps Insights section in the sidebar, select Helm Releases.
  2. In the row with the Helm release for which to add a deployment badge, click the Settings (gear) icon.

Helm Deployment badge

Helm Deployment badge
  1. To get deployment information, click Badge.
    Codefresh provides the Markdown/HTML/Link segment that you can embed in README or other documents to show deployment information.

Overriding default Helm actions for releases

By default, when you take an action in the UI, Codefresh executes the native Helm command corresponding to that action:

  • helm test for testing a chart
  • helm rollback for rollbacks
  • helm delete or helm uninstall --keep-history for delete
  • helm delete --purge or helm uninstall for purging a release

You can override these actions for a specific Helm release by defining custom pipelines for each action. This way you can add your extra logic on top of these actions. For example your own Helm uninstall pipeline might also have a notification step that posts a message to a Slack channel after a release is removed.

NOTE
Only Codefresh admin users can override the default pipelines defined for a Helm release.

  1. In the Codefresh UI, from the DevOps Insights section in the sidebar, select Helm Releases.
  2. In the row with the Helm release for which to override default actions, click the Settings (gear) icon.

Changing default Helm actions

Changing default Helm actions
  1. Select the pipeline to use for the respective actions.

Environment variables for custom Helm commands

If you do override any of these actions, the following environment variables are available in the respective pipeline, so that you can use your own custom Helm command.

Helm Test pipeline

  • CF_HELM_RELEASE: Name of release
  • CF_HELM_KUBE_CONTEXT: kubectl context name of target cluster (cluster name from dashboard)
  • CF_HELM_NAMESPACE: Namespace where release is stored
  • CF_HELM_TIMEOUT: Time in seconds to wait for any individual Kubernetes operation
  • CF_HELM_CLEANUP: Delete test pods upon completion

Helm Rollback pipeline

  • CF_HELM_VERSION: Helm version, ex.: 3.0.1, 2.7.0
  • CF_HELM_RELEASE: Name of release on cluster
  • CF_HELM_REVISION: Revision to use for rollback
  • CF_HELM_KUBE_CONTEXT: kubectl context name of target cluster (cluster name from dashboard)
  • CF_HELM_NAMESPACE: Namespace where release is stored

Helm Delete pipeline

  • CF_HELM_PURGE: Boolean, delete release from store
  • CF_HELM_RELEASE: Name of release
  • CF_HELM_TIMEOUT: Time in seconds to wait for any individual Kubernetes operation
  • CF_HELM_HOOKS: Prevent hooks from running during install
  • CF_HELM_KUBE_CONTEXT: kubectl context name of target cluster (cluster name from dashboard)
  • CF_HELM_VERSION: Helm version, ex.: 3.0.1, 2.7.0
  • CF_HELM_NAMESPACE: Namespace where release is stored

Using Helm in a Codefresh pipeline
Helm charts and repositories
Using a managed Helm repository
Promoting Helm Environments