GoogleContainerTools / skaffold

Easy and Repeatable Kubernetes Development
https://skaffold.dev/
Apache License 2.0
15.03k stars 1.62k forks source link

Skaffold build with --file-output and --tag outputs a file without the new tag. #9382

Closed Cloud956 closed 7 months ago

Cloud956 commented 7 months ago

Expected behavior

The created file ( for example builds.json) should have the new tag specified with the --tag. Like this:

{"builds":[{"imageName":"streaming-hospital","tag":"streaming-hospital:test"},{"imageName":"streaming-hospital-test","tag":"streaming-hospital-test:test"}]}

When specifying the tag as "test"

Actual behavior

It outputs the automatically-generated random tag.

{"builds":[{"imageName":"streaming-hospital","tag":"streaming-hospital:b5ef5cfa04cda780d3dd21c9504aad16b329976a8a97bc6ed95dd8021036f972"},{"imageName":"streaming-hospital-test","tag":"streaming-hospital-test:79df6e18abe614acaf5a1952d97581453f1a93d7c2c374c2c2dab7161c914c2b"}]}

Information

apiVersion: skaffold/v4beta10
kind: Config
metadata:
  name: streaming-hospital
build:
  artifacts:
    - image: streaming-hospital
      context: ./hospital
      sync:
        manual:
          - src: hospital/**/*
            dest: .
      docker:
        dockerfile: Dockerfile
        buildArgs:
          BUILD_VERSION: '{{.BUILD_VERSION}}'
    - image: streaming-hospital-test
      context: ./hospital-test
      docker:
        dockerfile: Dockerfile
        buildArgs:
           AUTH0_USERNAME: '{{.AUTH0_USERNAME}}'
           AUTH0_PASSWORD: '{{.AUTH0_PASSWORD}}'
  tagPolicy:
    sha256: {}
  local:
    push: false

Steps to reproduce the behavior

  1. Build a skaffold.yaml with some build artifacts.
  2. run skaffold build --file-output builds.json --tag='test'
ericzzzzzzz commented 7 months ago

hi @Cloud956 the tag in build output file is not the one you specified with --tag, it is a immutable image reference used for k8s deployment. This is expected. Please see https://skaffold.dev/docs/taggers/#how-tagging-works for details.