How to override a helm value

3/11/2018

I am actually working on a development environment using Gradle, Docker, Minikube and Helm.

I am using a bunch of bash scripts to get things done.

What I achieved so far is:

  1. Gradle builds the jar using a plugin for versioning.
  2. Gradle builds a docker image with the same version calculated on the jar job.

Now I need to be able to propagate the version calculated by Gradle to Helm so it can pick the right docker image.

The approach I already have in mind is to define an environment variable so it can be used by Helm.

The problem is that I would need to redefine it afterward.

Is any better way of doing that?

-- Marcos J.C Kichel
bash
docker
gradle
kubernetes
kubernetes-helm

1 Answer

3/14/2018

Most Helm charts contain at least the following in their values.yaml file, which sets a default docker image tag, and also allows the user installing/upgrading the chart to specify a different image without having to modify the chart itself.

# values.yaml
image:
  repository: <docker-repo-url-here>
  tag: <docker-image-tag-here>

And in the deployment yaml, fetch the values from the values.yaml

# deployment.yaml
kind: Deployment
spec:
  template:
    spec:
      containers:
      - name: container-name
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag}}"

From there, you can do a simple helm upgrade <release-name> <chart-path> --set image.tag=<new-image-tag> when you want to use a new image.

-- Grant David Bachman
Source: StackOverflow