devspace-sh / devspace

DevSpace - The Fastest Developer Tool for Kubernetes ⚡ Automate your deployment workflow with DevSpace and develop software directly inside Kubernetes.
https://devspace.sh
Apache License 2.0
4.29k stars 359 forks source link

Deploying without building ignores the CLI image tag #2579

Open sebaspf opened 1 year ago

sebaspf commented 1 year ago

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}
89luca89 commented 1 year ago

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
sebaspf commented 1 year ago

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.

withinboredom commented 1 year ago

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.