devspace icon indicating copy to clipboard operation
devspace copied to clipboard

Deploying without building ignores the CLI image tag

Open sebaspf opened this issue 2 years ago • 3 comments

Is your feature request related to a problem?

When microservices are declared as dependencies in a monorepo, deploying the project without building the images ignores the image tag given through the command line. We use this to deploy the exact same image to multiple clusters and separate the build from the deploy jobs.

In the following example project run devspace deploy -t ASDFASDFASDF --render and you will see that the deployment for dep1 has no image tag (latest will be assumed) but ASDFASDFASDF would be the desired one.

Main devsace.yaml

version: v2beta1

pipelines:
  deploy:
    run: |-
      run_dependencies --all

dependencies:
  dep1:
    path: ./dep1

Dependency devsapce.yaml in the folder ./dep1

version: v2beta1

pipelines:
  deploy:
    run: |-
      ensure_pull_secrets --all
      create_deployments --all

images:
  api:
    image: dep1-image

deployments:
  dep1:
    helm:
      values:
        containers:
          - image: dep1-image

Which solution do you suggest?

Somehow passing the tag given from the command line to de deploy command. Also adding a --tag flag to create_deployments (as build_images has) will help to build a workaround.

Which alternative solutions exist?

We must rebuild the images in the deploy step or edit the .devspace/cache.yaml for every dependency to write the desired tag. Non of the solutions is in my opinion acceptable.

A third approach is to force a tag over a profile like follows:

profiles:
  - name: custom-tag
    replace:
      images:
        dep1:
          image: dep1-image
          tags:
            - ${IMAGE_TAG}

sebaspf avatar Mar 01 '23 13:03 sebaspf

Hi @sebaspf

could you try adding the build image step separately? like


pipelines:
  deploy:
    run: |-
      ensure_pull_secrets --all
      build_images --all -t ${IMAGE_TAG} 
      create_deployments --all

89luca89 avatar Mar 03 '23 13:03 89luca89

Hi @89luca89,

I could, but this will build all images again. That is exactly what I want to prevent as the images where already build and pushed in an earlier step of the pipeline. A -t in create_deployments that forces the deployments to use the given tag tag would be much more efficient than rebuilding the images.

sebaspf avatar Mar 03 '23 18:03 sebaspf

It seems the tag doesn't get used anywhere in a pipeline. For example a custom pipeline:

echo ${runtime.images.app}

does not work unless the image is built. It makes waiting on a specific image to be available (to run db migrations, for example) to be quite difficult.

withinboredom avatar Mar 10 '23 21:03 withinboredom