Skaffold: FR: Add .IMAGE_TAG template variable

Created on 21 Jan 2020  路  7Comments  路  Source: GoogleContainerTools/skaffold

Expected behavior

There should be a way to retrieve the image-tag somehow in order to correctly insert it into the skaffold.yaml

According to https://skaffold.dev/docs/environment/templating/ {{.IMAGE_NAME}} is usable but not {{.IMAGE_TAG}}

Actual behavior

Kubernetes reports the Error Back-off pulling image "example.azurecr.io/example/cloud/social/rating"
Clearly here's missing the image-tag.

Information

  • Skaffold version: v1.2.0
  • Contents of skaffold.yaml:
apiVersion: skaffold/v2alpha1
kind: Config
metadata:
  name: example-social-cloud-rating-service
build:
  artifacts:
  - image: example.azurecr.io/example/cloud/social/rating
    jib: {}
  local: {}
deploy:
  helm:
    flags:
      upgrade: ["-i"]
    releases:
    - name: example-social-cloud-rating-service
      chartPath: helm
      namespace: example-socialcloud-dev
      setValueTemplates:
        "web.image": example.azurecr.io/example/cloud/social/rating
        "web.imageTag": "{{ .IMAGE_TAG }}"
        "web.name": example-social-cloud-rating-service
        "web.host": rating.social.cloud.example.com

With the deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
    name: {{ .Values.web.name }}
    namespace: {{ .Release.Namespace }}
    labels:
        app: {{ .Values.web.name }}
spec:
    replicas: 1
    selector:
        matchLabels:
            app: {{ .Values.web.name }}
    template:
        metadata:
            labels:
                app: {{ .Values.web.name }}
        spec:
            containers:
                -
                    image: "{{ .Values.web.image }}"
                    imagePullPolicy: Always
                    name: {{ .Values.web.name }}
                    ports:
                        -
                            containerPort: 8080
                    livenessProbe:
                        httpGet:
                            path: /healthz/ready
                            port: 8080
                    readinessProbe:
                        httpGet:
                            path: /healthz/ready
                            port: 8080

aretemplating fixit kinfeature-request prioritp1

Most helpful comment

I have found a workaround that helps, but still not flexible enough if you need image tag by itself.

I found this in debug output
level=debug msg="EnvVarMap: map[DIGEST:988737991187.dkr.ecr.us-east-2.amazonaws.com/sandbox-999999-titanium:latest@sha256:8f68c8204660819340f81c94001ce651bfe87e83ab1598eb5e91bd861a39831f DIGEST_ALGO:988737991187.dkr.ecr.us-east-2.amazonaws.com/sandbox-999999-titanium DIGEST_HEX:latest@sha256:8f68c8204660819340f81c94001ce651bfe87e83ab1598eb5e91bd861a39831f IMAGE_NAME:988737991187.dkr.ecr.us-east-2.amazonaws.com/sandbox-999999-titanium]

I was able to get image+tag with this in my skaffold config:

     setValueTemplates:
        global.deployment.image.repository: "{{.DIGEST}}"

All 7 comments

I opened #3343 for this reason as well.

+1 it looks like there is no way to get the image tag from the tagPolicy to use later in helm.

  tagPolicy:
    dateTime:
      format: "2006-01-02_15-04-05.999_MST"
      timezone: "Local"

There is no way to get the image and tag and pass it to helm

  helm:
    releases:
    - name: my-app
      chartPath: ./helm
      skipBuildDependencies: true
      setValueTemplates:
        image.repository: '{{.IMAGE_NAME}}'
        image.tag: '{{.IMAGE_TAG}}'

For above skaffold dev -v debug 2>&1 shows:

time="2020-03-02T12:50:56Z" level=debug msg="Running command: [helm --kube-context kubernetes-admin@prod install --name my-app ./helm --set image.repository=my-app --set image.tag=<no value>]"

Also, for Helm we would need {{IMAGE_REPOSITORY}} so we could do below. See https://github.com/GoogleContainerTools/skaffold/issues/3763

      setValueTemplates:
        image.repository: '{{IMAGE_REPOSITORY}}/{{.IMAGE_NAME}}'
        image.tag: '{{.IMAGE_TAG}}'

+1 for this as well !

I have found a workaround that helps, but still not flexible enough if you need image tag by itself.

I found this in debug output
level=debug msg="EnvVarMap: map[DIGEST:988737991187.dkr.ecr.us-east-2.amazonaws.com/sandbox-999999-titanium:latest@sha256:8f68c8204660819340f81c94001ce651bfe87e83ab1598eb5e91bd861a39831f DIGEST_ALGO:988737991187.dkr.ecr.us-east-2.amazonaws.com/sandbox-999999-titanium DIGEST_HEX:latest@sha256:8f68c8204660819340f81c94001ce651bfe87e83ab1598eb5e91bd861a39831f IMAGE_NAME:988737991187.dkr.ecr.us-east-2.amazonaws.com/sandbox-999999-titanium]

I was able to get image+tag with this in my skaffold config:

     setValueTemplates:
        global.deployment.image.repository: "{{.DIGEST}}"

I think this seems reasonable. PR's welcome!

I'm going to close this as a dupe of #3343 so we can keep the conversation to one issue, I think that one covers what's being asked here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

heroic picture heroic  路  4Comments

abatilo picture abatilo  路  4Comments

yurchenkosv picture yurchenkosv  路  3Comments

stanislav-zaprudskiy picture stanislav-zaprudskiy  路  4Comments

achedeuzot picture achedeuzot  路  3Comments