Skip to content

Commit 5190b65

Browse files
committed
Update proposal
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
1 parent 56712b0 commit 5190b65

File tree

1 file changed

+56
-44
lines changed

1 file changed

+56
-44
lines changed

docs/proposals/console/devfile-import.md

Lines changed: 56 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,80 +2,94 @@
22

33
This document outlines how the console is going to use a devfile 2.0.0 spec for it's import feature targeted for the upcoming release.
44

5-
## As-Is Today
5+
## Dev Preview POC
66

7-
Currently the Devfile import feature is mocked with a POC [openshift/console PR](https://github.com/openshift/console/pull/6321). The POC PR, requires the build guidance devfile spec to be implemented. However, the build guidance spec is still an open discussion in the [devfile/api PR](https://github.com/devfile/api/pull/127).
7+
The Devfile import feature was mocked with a POC [openshift/console PR](https://github.com/openshift/console/pull/6321). The POC PR, required the build guidance devfile spec to be implemented. However, the build guidance spec is still an open discussion in the [devfile/api PR](https://github.com/devfile/api/pull/127).
88

99
With an initial target date for the Dec 04, 2020; the devfile import developer preview should look similar to this [demo video](https://drive.google.com/file/d/1uLzDibVZlkMqbjtKkho04e8k2-Ns5A2W/view).
1010

11-
The information required to build a component from build guidance are:
11+
## Required Data
12+
13+
The information required to build a component from devfile are:
1214
- Git Repo Url
1315
- Git Repo Ref
14-
- Build Context Path
16+
- Devfile Context Dir
17+
- Docker Build Context Dir
18+
- Dockerfile Location
1519
- Container Port
1620
- Image Name
1721

18-
The console devfile import page has the Git Repo Url, Git Repo Ref & the Build Context Path
22+
The console devfile import page has the Git Repo Url, Git Repo Ref & the Devfile Context Dir.
1923

2024
<img src="https://user-images.githubusercontent.com/31771087/99319303-4ae89180-2837-11eb-8933-eaaf41160bcd.png">
2125

22-
The Dockerfile is assumed to be present in the context directory. The Container Port is assumed to be 8080 and the Image Name is assumed to be the same as the application name.
23-
24-
### Note:
25-
The context path is present in both the Console import form and the open devfile spec(Refer to the OpenShift Console Devfile Import screenshot above and the open Build Guidance PR screenshot below). Do we require two context dir information? Is the context dir in the Console form for devfile.yaml and the context dir in the build guidance spec for Dockerfile relative to devfile.yaml? Or do we always assume both the devfile.yaml and Dockerfile are always at the same dir level.
26+
There are two context directories info required. The `Devfile Context Dir` present in the Console form is used to find the devfile.yaml in a repository. The `Docker Build Context Dir` present in the devfile.yaml is used to establish a context dir for Docker builds relative to the devfile.yaml.
2627

2728
For phase 1, only the Dockerfile Build Guidance is to be implemented. SourceToImage(S2I) will be implemented in the future sprints.
2829

2930
<img src="https://user-images.githubusercontent.com/31771087/99319306-4c19be80-2837-11eb-9639-a5c130deb4ba.png">
3031

31-
## Proposed Changes
32-
3332
With the target deadline approaching soon, we may need to provide an alternative path for the OpenShift Console to consume the devfile. With the Build Guidance spec [devfile/api PR](https://github.com/devfile/api/pull/127) still an open discussion, this document proposes a solution within the boundaries of the devfile 2.0.0 spec to achieve this.
3433

35-
Here is a proposed 2.0.0 spec devfile that can support build guidance for OpenShift Console:
34+
## Proposed Changes
35+
36+
Here is a proposed 2.0.0 spec devfile that can support devfile build guidance for OpenShift Console:
3637

3738
```yaml
3839
schemaVersion: 2.0.0
3940
metadata:
4041
name: nodejs
4142
version: 1.0.0
4243
attributes:
43-
alpha.build-dockerfile: ./mydir/Dockerfile # is a relative path to the context dir containing src files in the repo
44+
alpha.build-context: mydir # key:value pair that establishes the context dir for Docker builds relative to devfile.yaml
45+
alpha.build-dockerfile: Dockerfile # key:value pair that specifies the location of the Dockerfile relative to alpha.build-context
4446
components:
45-
- name: myapplication
46-
attributes:
47-
tool: console-import # key:value pair used to filter container type component that only the Console Devfile Import is interested in
48-
container:
49-
image: buildContextImageOutput:latest # this is the image which will be used by the Console's buildConfig output
50-
endpoints:
51-
- name: http-3000 # define endpoints in devfile.yaml, rather than hardcoding a default
52-
targetPort: 3000
53-
env:
54-
- name: FOO # set container env through the devfile.yaml for the container
55-
value: "bar"
56-
- name: otherapplication1
57-
container:
58-
image: someimage1
59-
endpoints:
60-
- name: http-3001
61-
- name: otherapplication2
62-
container:
63-
image: someimage2
64-
endpoints:
65-
- name: http-3002
66-
targetPort: 3002
67-
env:
68-
- name: ABC
69-
value: "xyz"
47+
- name: runtime
48+
attributes:
49+
tool: console-import # key:value pair used to filter container type component that only the Console Devfile Import is interested in
50+
container:
51+
image: imageplaceholder # image which will be used by the buildConfig output but not supported for Dev Preview, defaults to Console's application name
52+
memoryLimit: 1024Mi
53+
endpoints:
54+
- name: http-3000
55+
targetPort: 3000 # define endpoints in devfile.yaml, that will be used for the devfile service
56+
- name: runtime2 # other components ignored by the Console Devfile Import
57+
container:
58+
image: registry.access.redhat.com/ubi8/nodejs-12:1-45
59+
memoryLimit: 1024Mi
60+
mountSources: true
61+
sourceMapping: /project
62+
endpoints:
63+
- name: http-3000
64+
targetPort: 3000
65+
commands:
66+
- id: install
67+
exec:
68+
component: runtime2
69+
commandLine: npm install
70+
workingDir: /project
71+
group:
72+
kind: build
73+
isDefault: true
74+
- id: run
75+
exec:
76+
component: runtime2
77+
commandLine: npm start
78+
workingDir: /project
79+
group:
80+
kind: run
81+
isDefault: true
7082
```
7183
72-
Without the build guidance devfile spec, the proposed change here is to mention the dockerfile location in the metadata attribute. The attributes is a free form key-value pair and in the above example, a `alpha.build-dockerfile` key holds the dockerfile location; which would have otherwise been specified by the Dockerfile Build Guidance spec.
84+
Without the build guidance devfile spec, the proposed change here is to mention the docker build context and the dockerfile location in the metadata attribute. The attributes is a free form key-value pair and in the above example, `alpha.build-context` & `alpha.build-dockerfile` are used for the values; which would have otherwise been specified by the Dockerfile Build Guidance spec.
7385

74-
Asides the devfile change, the POC PR would need to be updated to use the above devfile's image and endpoint.
86+
To allow the Console to filter only devfile component containers, we use a `tool: console-import` key value pair attribute in the container component. Any other components in the devfile are ignored by the Console.
7587

76-
Console's devfile import POC is using a `BuildConfig` to build the Dockerfile from the dockerfile path location, currently found from the context dir. The POC PR `BuildConfig` outputs it to an `ImageStreamTag`. However, the POC PR assumes the `ImageStream` and `ImageStreamTag` are all the same name as the application name. This is tightly coupled and dependant on the information entered in the Console Devfile Import form and thus does not allow us to mention a custom image name in the devfile.
88+
Asides the devfile change, the Dev Preview would need to be updated to use the above devfile's image in the future.
7789

78-
If we want to decouple `ImageStream` and `ImageStreamTag` from the application name, so that a custom image name can be specified in the devfile's component container; then we would need to update the following files:
90+
Console's devfile import Dev Preview is using a `BuildConfig` to build the Dockerfile from the dockerfile path location and build context directory. The `BuildConfig` outputs it to an `ImageStreamTag`. However, for the Dev Preview it assumes the `ImageStream` and `ImageStreamTag` are all the same name as the application name. This is tightly coupled and dependant on the information entered in the Console Devfile Import form and thus does not allow us to mention a custom image name in the devfile.
91+
92+
If we want to decouple `ImageStream` and `ImageStreamTag` from the application name, so that a custom image name can be specified in the devfile's component container; then we would need to update the following information:
7993
1. `pkg/server/devfile-handler.go`
8094
- image stream name
8195
- build config output image stream tag
@@ -85,8 +99,6 @@ If we want to decouple `ImageStream` and `ImageStreamTag` from the application n
8599

86100
This allows us to use the image name from devfile.yaml rather than always using the application name.
87101

88-
The proposed devfile also mentions an endpoint instead of hardcoding a default 8080. This can be updated in the POC PR's function `createOrUpdateResources()` in `frontend/packages/dev-console/src/components/import/import-submit-utils.ts`
89-
90102
These devfile information would be parsed and returned by the library and thus ensuring a consistent UX.
91103

92104
### Note:

0 commit comments

Comments
 (0)