Linting Your Helm Charts

December 20, 2018
ops devops kubernetes helm

In any engineering environment, linting is an important tool to help maintain style, and prevent simple mistakes. The same is true of your Helm charts. Chart linting is an easy tool that you can add to your pipeline to ensure your deployments are valid and versioned correctly.

Getting linting set up for your custom Helm charts is actually extremely straight-forward thanks to the Helm chart-testing project, which can be found here: https://github.com/helm/chart-testing. Furthermore, we can re-use much of the configuration from the community Helm charts repository.

This is especially convenient if you are currently using CircleCI for your testing pipeline. If you are, you can quite literally copy the entire job out of the Helm CircleCI config file (which I’ve included below for convenience).

  lint-charts:
    docker:
      - image: gcr.io/kubernetes-charts-ci/test-image:v3.0.1
    steps:
      - checkout
      - run:
          name: lint
          command: |
            git remote add k8s <repository>
            git fetch k8s master
            ct lint --config .circleci/chart-testing.yaml

While this example expects a chart-testing configuration file in the repository, it is not necessary. Parameters can be provided as CLI flags or environment variables if you prefer not to include extra configuration files in your repos.

At this point, you will have valid checks for most common Helm errors, including:

  • invalid YAML
  • non-deployable charts
  • forgetting to bump the chart version after changes (the most common in my experience)

Quick detection of these issues is vital in enabling a continuous delivery pipeline that includes Helm chart modifications.


Hopefully this works out for you, or was at least helpful. If you have any questions, don’t hesitate to shoot me an email, or follow me on twitter @nrmitchi.