You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/proposals/console/devfile-import.md
+56-44Lines changed: 56 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,80 +2,94 @@
2
2
3
3
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.
4
4
5
-
## As-Is Today
5
+
## Dev Preview POC
6
6
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).
8
8
9
9
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).
10
10
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:
12
14
- Git Repo Url
13
15
- Git Repo Ref
14
-
- Build Context Path
16
+
- Devfile Context Dir
17
+
- Docker Build Context Dir
18
+
- Dockerfile Location
15
19
- Container Port
16
20
- Image Name
17
21
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.
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.
26
27
27
28
For phase 1, only the Dockerfile Build Guidance is to be implemented. SourceToImage(S2I) will be implemented in the future sprints.
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.
34
33
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:
36
37
37
38
```yaml
38
39
schemaVersion: 2.0.0
39
40
metadata:
40
41
name: nodejs
41
42
version: 1.0.0
42
43
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
44
46
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
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.
73
85
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.
75
87
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.
77
89
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:
79
93
1. `pkg/server/devfile-handler.go`
80
94
- image stream name
81
95
- build config output image stream tag
@@ -85,8 +99,6 @@ If we want to decouple `ImageStream` and `ImageStreamTag` from the application n
85
99
86
100
This allows us to use the image name from devfile.yaml rather than always using the application name.
87
101
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
-
90
102
These devfile information would be parsed and returned by the library and thus ensuring a consistent UX.
0 commit comments