Skaffold: Helm section ignores templating

Created on 21 Nov 2018  路  3Comments  路  Source: GoogleContainerTools/skaffold

Expected behavior

Skaffold will inject tag in helm values, so with new skaffold run, k8s will pull new image.
It can be achieved by adding templating into helm section like this:

      setValues:
        image.repository: <imageRepo>
        image.tag: {{ .IMAGE_NAME}}:0.0.2-{{ .DIGEST_HEX }}

Actual behavior

Helm using same tag as tagPolicy define.
If I using image with tag latest, k8s will not pull new image, because of image with tag latest already present on machine (k8s node) and I cannot assign tag, which skaffold assigns

      setValues:
        image.repository: <imageRepo>
        image.tag: latest

Information

  • Skaffold version: v0.17.0
  • Operating system: Debian stretch
  • Contents of skaffold.yaml:
apiVersion: skaffold/v1alpha5
kind: Config
build:
  artifacts:
  - image: <imageName>
  tagPolicy:
    envTemplate:
      template: "{{ .IMAGE_NAME}}:3.0.0.1-SNAPSHOT-{{ .DIGEST_HEX }}"
deploy:
  helm:
    releases:
    - name: skaffold-dev-server
      chartPath: "helm/dev-server"
      namespace: dev
      setValues:
        image.repository: <imageRepo>
        image.tag: latest
      valuesFiles:
        - "helm/server/values.yaml"
profiles:
   - name: gcb
     build:
       googleCloudBuild:
         projectId: <projID>

Steps to reproduce the behavior

  1. ...
  2. ...
deplohelm kinbug

Most helpful comment

@f0rmiga thanks for digging into that. @yurchenkosv I'm gonna close this issue for now, if you try the recommended change and you're still experiencing issues please reopen.

@maximbaz the values stanza points skaffold to the helm values file, which usually contains multiple values which helm will set on install. the setValues provides skaffold a list of value pairs which it will pass to helm via the --set flag when doing an install. both accomplish the same thing.

All 3 comments

Am I right to assume that even if I use sha256: {} as tagPolicy, I should still be able to use {{ .DIGEST }} and others in the helm section, like so?

apiVersion: skaffold/v1alpha5
kind: Config
build:
  artifacts:
  - image: <imageName>
  tagPolicy:
    sha256: {}
deploy:
  helm:
    releases:
    - name: skaffold-dev-server
      chartPath: "helm/dev-server"
      setValues:
        image.tag: "{{ .DIGEST }}"
      valuesFiles:
        - "helm/server/values.yaml"

Also, I can't seem to grasp what's the difference between:

values:
  image.tag: "{{ .DIGEST }}"

and

setValues:
  image.tag: "{{ .DIGEST }}"

Does anyone know?

@yurchenkosv @maximbaz

The documentation related to this is here https://skaffold.dev/docs/how-tos/deployers/#deploying-with-helm.

Use setValueTemplates instead of setValues.

@nkubala I don't think this issue is a bug.

@f0rmiga thanks for digging into that. @yurchenkosv I'm gonna close this issue for now, if you try the recommended change and you're still experiencing issues please reopen.

@maximbaz the values stanza points skaffold to the helm values file, which usually contains multiple values which helm will set on install. the setValues provides skaffold a list of value pairs which it will pass to helm via the --set flag when doing an install. both accomplish the same thing.

Was this page helpful?
0 / 5 - 0 ratings