Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify on how to use image name in image component and how tools can consume it #985

Closed
elsony opened this issue Nov 14, 2022 · 3 comments · Fixed by devfile/library#172
Labels
area/api Enhancement or issue related to the api/devfile specification area/documentation Improvements or additions to documentation

Comments

@elsony
Copy link
Contributor

elsony commented Nov 14, 2022

Which area this feature is related to?

/area documentation

Which area is this documentation change is related to?

/area api

Issue details

What mistake did you find / what is missing in the documentation?
The existing imageName field in the image component only has a brief field description. Based on the discussion on the community call on 11/14 (see the recording https://drive.google.com/file/d/1XLTdizST_LeoKpF7xw4Q9k__6LoXKCmo/view?usp=sharing for details), we need to clarify how the imageName field is set and handled by the tools.

Summary of the change:

  1. The user can specify the imageName with either a full URL or a relative location of the image within an image registry to store the built image.
  2. If a relative location is being used, the tools will have their own way to find out the image registry location (e.g. detection or user input). After the image component is built, it will automatically replace the correct image location in memory so that it can be used by an image container or the kubernetes component for deploying the image.
  3. If a full URL is used, the tools will not replace it with the automatically generated URL and will use the full URL to store the built image.
@openshift-ci openshift-ci bot added area/documentation Improvements or additions to documentation area/api Enhancement or issue related to the api/devfile specification labels Nov 14, 2022
@kadel
Copy link
Member

kadel commented Dec 15, 2022

  • If a relative location is being used, the tools will have their own way to find out the image registry location (e.g. detection or user input). After the image component is built, it will automatically replace the correct image location in memory so that it can be used by an image container or the kubernetes component for deploying the image.

Shouldn't tools also allow overriding the image name?
Let's say that I have two applications, both using java-springboot stack. This stack defines image component with imageName: java-springboot-image:latest.
Let's say that we have a setting on the tooling side that allows the user to set the registry that should be used. My two different applications will be pushing to the same image. This is definitely not what we want.

@l0rd
Copy link
Contributor

l0rd commented Jan 26, 2023

Considering the imageName as a full registry image has collision and permissions problems. We should avoid that.

We should rather consider it an image selector as Tilt does:

my-image is an image selector. Tilt will scan all your workload manifests for images, and match any object that contains the image name my-image (regardless of tag).

So the proposal is to

  1. Add a new image component property called imageNameSelector which description is:
An kubernetes and container component image selector. Tools will scan all container and 
kubernetes components for images, and match any object that matches it 
(regardless of the registry and tag).
  1. To deprecate the current imageName and replace it in every documentation sample but continue supporting it for backward compatibility as an alias of imageNameSelector.

  2. Implement the new behavior in the Devfile library and DWO


example

components:
  - name: devtools-image
    image:
      imageNameSelector: devtools                    # <=== image selector
      autoBuild: true
      dockerfile:
        uri: Dockerfile
  - name: devtools-container1
    container:
      image: devtools                                # <=== matches selector ✅
      memoryLimit: 512Mi
      command: ['sleep', 'infinity']
  - name: devtools-container2
    container:
      image: quay.io/devfile/devtools:ubi8-latest    # <=== matches selector ✅
      memoryLimit: 512Mi
      command: ['sleep', 'infinity']
  - name: devtools-container3
    container:
      image: quay.io/devfile/devtools2:ubi8-latest    # <=== doesn't match selector ❌
      memoryLimit: 512Mi
      command: ['sleep', 'infinity']

Tools implementing the devfile spec will:

  • Build the Dockerfile, tag and push the resulting image to a user-defined registry (e.g. <local-registry>/<user-org>/<devfile-name>-<image-name>:<build-#>).
  • Replace container component images that match the imageNameSelector with the image that has just been built
  • Replace kubernetes component containers with images that match the imageNameSelector with the image that has just been built.
  • Leave the non matching container and kubernetes components as they are

rm3l added a commit to rm3l/devfile-library that referenced this issue Apr 19, 2023
This goal of this field is to provide a replacement
(as a format string) that will be used as selector
for all matching (relative) image names.

See [1] for more details.

[1] devfile/api#985
rm3l added a commit to rm3l/devfile-library that referenced this issue Apr 24, 2023
The goal of this field is to allow tools to provide
information (currently registry and tag) allowing to replace matching image names.

See [1] for more details.

[1] devfile/api#985
rm3l added a commit to rm3l/devfile-library that referenced this issue Apr 24, 2023
… Kubernetes components

This relies on the Docker Distribution library
to parse image references in order to detect if
they are absolute or relative.

See [1] for more details about the proposal.

[1] devfile/api#985 (comment)
rm3l added a commit to rm3l/devfile-library that referenced this issue Apr 24, 2023
… Kubernetes components

This relies on the Docker Distribution library
to parse image references in order to detect if
they are absolute or relative.

See [1] for more details about the proposal.

[1] devfile/api#985 (comment)
rm3l added a commit to rm3l/devfile-library that referenced this issue Apr 24, 2023
… Kubernetes components

This relies on the Docker Distribution library
to parse image references in order to detect if
they are absolute or relative.

See [1] for more details about the proposal.

[1] devfile/api#985 (comment)
rm3l added a commit to rm3l/devfile-library that referenced this issue Apr 24, 2023
The goal of this field is to allow tools to provide
information (currently registry and tag) allowing to replace matching image names.

See [1] for more details.

[1] devfile/api#985

Signed-off-by: Armel Soro <[email protected]>
rm3l added a commit to rm3l/devfile-library that referenced this issue Apr 24, 2023
… Kubernetes components

This relies on the Docker Distribution library
to parse image references in order to detect if
they are absolute or relative.

See [1] for more details about the proposal.

[1] devfile/api#985 (comment)

Signed-off-by: Armel Soro <[email protected]>
rm3l added a commit to rm3l/devfile-library that referenced this issue Apr 24, 2023
… Kubernetes components

This relies on the Docker Distribution library
to parse image references in order to detect if
they are absolute or relative.

See [1] for more details about the proposal.

[1] devfile/api#985 (comment)

Signed-off-by: Armel Soro <[email protected]>
rm3l added a commit to rm3l/devfile-library that referenced this issue Apr 25, 2023
… Kubernetes components

This relies on the Docker Distribution library
to parse image references in order to detect if
they are absolute or relative.

See [1] for more details about the proposal.

[1] devfile/api#985 (comment)

Signed-off-by: Armel Soro <[email protected]>
rm3l added a commit to rm3l/devfile-library that referenced this issue Apr 25, 2023
… Kubernetes components

This relies on the Docker Distribution library
to parse image references in order to detect if
they are absolute or relative.

See [1] for more details about the proposal.

[1] devfile/api#985 (comment)

Signed-off-by: Armel Soro <[email protected]>
@rm3l
Copy link
Member

rm3l commented Apr 26, 2023

I've created a PR in the Devfile library to handle imageName as a selector: devfile/library#172.
@l0rd @elsony @kadel Please take a look and let me know your thoughts.

There is also a draft PR in odo related to that. It leverages the changes in devfile/library#172 and can be used already to test this via odo: redhat-developer/odo#6768

rm3l added a commit to rm3l/devfile-library that referenced this issue May 10, 2023
The goal of this field is to allow tools to provide
information (currently registry and tag) allowing to replace matching image names.

See [1] for more details.

[1] devfile/api#985

Signed-off-by: Armel Soro <[email protected]>
rm3l added a commit to rm3l/devfile-library that referenced this issue May 10, 2023
… Kubernetes components

This relies on the Docker Distribution library
to parse image references in order to detect if
they are absolute or relative.

See [1] for more details about the proposal.

[1] devfile/api#985 (comment)

Signed-off-by: Armel Soro <[email protected]>
rm3l added a commit to rm3l/devfile-library that referenced this issue May 10, 2023
The goal of this field is to allow tools to provide
information (currently registry and tag) allowing to replace matching image names.

See [1] for more details.

[1] devfile/api#985

Signed-off-by: Armel Soro <[email protected]>
rm3l added a commit to rm3l/devfile-library that referenced this issue May 10, 2023
… Kubernetes components

This relies on the Docker Distribution library
to parse image references in order to detect if
they are absolute or relative.

See [1] for more details about the proposal.

[1] devfile/api#985 (comment)

Signed-off-by: Armel Soro <[email protected]>
@michael-valdron michael-valdron moved this to Done ✅ in Devfile Project May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Enhancement or issue related to the api/devfile specification area/documentation Improvements or additions to documentation
Projects
Status: Done ✅
Development

Successfully merging a pull request may close this issue.

4 participants