Skaffold: Correct Tag Policy for Helm Deployments

Created on 23 Sep 2019  路  3Comments  路  Source: GoogleContainerTools/skaffold

Hi, I've been using the envTemplate tag policy with the {{.DIGEST}} tag in the dev profile of my skaffold.yaml file.

skaffold run -p dev would run successfully when I was using Skaffold version v0.37.0, but now that I've upgraded to Skaffold version v0.38.0 I can see from the logs that tagging images with {{.DIGEST}}, {{.DIGEST_ALGO}} and {{.DIGEST_HEX}} have been officially deprecated(?).

I have been searching around the documentation to find out what is the proper replacement for {{.DIGEST}} and I haven't found anything.

Could someone point me in the right direction in regards to what the best practices are for using tag policies with helm deployments?

Actual behavior

Generating tags...
 - org/serviceA -> FATA[0000] failed to build: generating tag for org/serviceA: {{.DIGEST}}, {{.DIGEST_ALGO}} and {{.DIGEST_HEX}} are deprecated, image digest will now automatically be appended to image tags 

Information

  • Skaffold version: v0.38.0
  • Operating system: CentOS Linux release 7.6.1810 (Core)
  • Contents of skaffold.yaml:
apiVersion: skaffold/v1beta2 
kind: Config
build:
  artifacts:
  - image: org/serviceA
    context: .
    docker: {}
  tagPolicy:
    envTemplate:
      template: '{{.DOCKER_REGISTRY}}/{{.IMAGE_NAME}}:{{.VERSION}}'
  local: {}
deploy:
  kubectl: {}
profiles:
- name: dev
  build:
    tagPolicy:
      envTemplate:
        template: '{{.DOCKER_REGISTRY}}/{{.IMAGE_NAME}}:{{.DIGEST}}'
    local: {}
  deploy:
    helm:
      releases:
      - name: serviceA
        chartPath: charts/serviceA
        setValueTemplates:
          image.repository: '{{.DOCKER_REGISTRY}}/{{.IMAGE_NAME}}'
          image.tag: '{{.DIGEST}}'

Steps to reproduce the behavior

  1. skaffold run -p dev
aretag kinbug prioritp1

Most helpful comment

@tejal29 Thank you for your help.

I applied your suggested actions and it fixed my problem.

  1. Running the skaffold fix --overwrite command updated the apiversion from v1beta2 to v1beta14.
  2. Removing the {{.DIGEST}} from the tagpolicy now causes the skaffold run -p dev command to successfully execute.

I want to add that although my problem was fixed, I had another problem which was figuring out how to use the new docker image produced by skaffold run -p dev.

$ skaffold run -p dev

...

Build complete in 7.982785624s
Starting test...
Test complete in 12.029碌s
Tags used in deployment:
 - org/serviceA -> docker_registry/org/serviceA@sha256:46ddfeca4f857f940a1ac9557bec7c154badf5ec6bc996c0b7309cc0d8af8bd4
Starting deploy...

I wanted to overwrite the values of the image.repository and image.tag keys in my values.yaml file to the repository + tag shown in the example above. If I couldn't do so then my Pods wouldn't be able to fetch and use the new image.

I did some playing around and noticed I could still use {{.DIGEST}} in the setValueTemplates block and the value of {{.DIGEST}} was docker_registry/org/serviceA@sha256:46ddfeca4f857f940a1ac9557bec7c154badf5ec6bc996c0b7309cc0d8af8bd4. The new docker image produced by skaffold run -p dev (shown in logs above), which is exactly what I was looking for.


This is my final working skaffold.yaml file

# skaffold.yaml

apiVersion: skaffold/v1beta14
kind: Config
build:
  artifacts:
  - image: org/serviceA
    context: .
    docker: {}
  tagPolicy:
    envTemplate:
      template: '{{.DOCKER_REGISTRY}}/{{.IMAGE_NAME}}:{{.VERSION}}'
  local: {}
deploy:
  kubectl: {}
profiles:
- name: dev
  build:
    tagPolicy:
      envTemplate:
        template: '{{.DOCKER_REGISTRY}}/{{.IMAGE_NAME}}'
    local: {}
  deploy:
    helm:
      releases:
      - name: serviceA
        chartPath: charts/serviceA                  
        setValueTemplates:
          image.repository: '{{.DIGEST}}'

I'm happy to close this issue now. Unless you want to keep it open?

All 3 comments

@KDvu Sorry for the confusion. I have brought this to our team's attention and we will definitely do a better job around documenting such deprecation in the release notes.

First off, looks like your config is very old.

  1. Please run skaffold fix to upgrade to latest version.
    to overwrite the skaffold config use overwrite flag mentioned here https://skaffold.dev/docs/references/cli/#skaffold-fix
  2. Please drop the DIGEST from the dev profile and else.

Let me know this fixes your problem.

@tejal29 Thank you for your help.

I applied your suggested actions and it fixed my problem.

  1. Running the skaffold fix --overwrite command updated the apiversion from v1beta2 to v1beta14.
  2. Removing the {{.DIGEST}} from the tagpolicy now causes the skaffold run -p dev command to successfully execute.

I want to add that although my problem was fixed, I had another problem which was figuring out how to use the new docker image produced by skaffold run -p dev.

$ skaffold run -p dev

...

Build complete in 7.982785624s
Starting test...
Test complete in 12.029碌s
Tags used in deployment:
 - org/serviceA -> docker_registry/org/serviceA@sha256:46ddfeca4f857f940a1ac9557bec7c154badf5ec6bc996c0b7309cc0d8af8bd4
Starting deploy...

I wanted to overwrite the values of the image.repository and image.tag keys in my values.yaml file to the repository + tag shown in the example above. If I couldn't do so then my Pods wouldn't be able to fetch and use the new image.

I did some playing around and noticed I could still use {{.DIGEST}} in the setValueTemplates block and the value of {{.DIGEST}} was docker_registry/org/serviceA@sha256:46ddfeca4f857f940a1ac9557bec7c154badf5ec6bc996c0b7309cc0d8af8bd4. The new docker image produced by skaffold run -p dev (shown in logs above), which is exactly what I was looking for.


This is my final working skaffold.yaml file

# skaffold.yaml

apiVersion: skaffold/v1beta14
kind: Config
build:
  artifacts:
  - image: org/serviceA
    context: .
    docker: {}
  tagPolicy:
    envTemplate:
      template: '{{.DOCKER_REGISTRY}}/{{.IMAGE_NAME}}:{{.VERSION}}'
  local: {}
deploy:
  kubectl: {}
profiles:
- name: dev
  build:
    tagPolicy:
      envTemplate:
        template: '{{.DOCKER_REGISTRY}}/{{.IMAGE_NAME}}'
    local: {}
  deploy:
    helm:
      releases:
      - name: serviceA
        chartPath: charts/serviceA                  
        setValueTemplates:
          image.repository: '{{.DIGEST}}'

I'm happy to close this issue now. Unless you want to keep it open?

Thanks for the explanation!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gbird3 picture gbird3  路  3Comments

woodcockjosh picture woodcockjosh  路  4Comments

yurchenkosv picture yurchenkosv  路  3Comments

emichaf picture emichaf  路  4Comments

Morriz picture Morriz  路  3Comments