Skip to content

Commit 3bbf559

Browse files
jc-bergerRobert Krátký
andauthored
Modified docs to adhere to schema_1st PR (#43)
* modified docs to adhere to schema more content changes to align with schema more source.yaml changes to align with schema more changes to yamls tweaks to yamls. more changes to come major change to adding kubernetes doc. changed yaml for event bindings doc more content and yaml changes minor tweaks and adjusted tab spacing in yaml addressed doc review comments more language review fixed capitalization error * Update docs/modules/user-guide/partials/proc_defining-endpoints.adoc Co-authored-by: Robert Krátký <[email protected]> * Update docs/modules/user-guide/partials/proc_adding-plugin-component-to-a-devfile.adoc Co-authored-by: Robert Krátký <[email protected]> Co-authored-by: Robert Krátký <[email protected]>
1 parent 131de2b commit 3bbf559

9 files changed

+103
-388
lines changed

docs/modules/user-guide/partials/proc_adding-a-name-to-a-devfile.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ metadata:
2929
----
3030
schemaVersion: 2.0.0
3131
metadata:
32-
generateName: devfile-sample-
32+
name: devfile-sample
3333
----
3434

3535
[NOTE]

docs/modules/user-guide/partials/proc_adding-commands-to-a-devfile.adoc

Lines changed: 5 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ A devfile allows to specify commands to be available for execution in a workspac
1717

1818
. For each command, define an unique value for the mandatory `id` attribute.
1919

20-
. For each command, define a mandatory type of one of the following types: `exec` or `vscode-tasks`.
20+
. For each command, define a mandatory type of one of the following types: `exec`, `apply`, `composite`, or `vscode-tasks`.
2121
+
2222
.Sample command
2323
[source,yaml]
@@ -39,7 +39,7 @@ A devfile allows to specify commands to be available for execution in a workspac
3939
----
4040
schemaVersion: 2.0.0
4141
metadata:
42-
name: MyDevfile
42+
name: mydevfile
4343
projects:
4444
- name: my-go-project
4545
clonePath: go/src/github.com/acme/my-go-project
@@ -64,49 +64,12 @@ commands:
6464
component: go-cli
6565
commandLine: "go get -d && go run main.go"
6666
workingDir: "${PROJECTS_ROOT}/src/github.com/acme/my-go-project"
67-
runAsUser: root
6867
----
6968
+
7069
[NOTE]
7170

72-
* Any component on which commands are executed must define a `name` attribute. This name is used to reference the component in the command definition. Example: `name: go-cli` in the component definition and `component: go-cli` in the command definition.
73-
7471
* A command can have only one action, though you can use `composite` commands to execute several commands either sequentially or in parallel.
7572

76-
. Define attributes for the `vscode-task` or `vscode-launch` command to run using the Editor.
77-
+
78-
If the editor in the workspace supports it, the devfile can specify additional configuration in the editor-specific format. This is dependent on the integration code present in the workspace editor itself and so is not a generic mechanism.
79-
+
80-
[source,yaml]
81-
----
82-
schemaVersion: 2.0.0
83-
metadata:
84-
name: MyDevfile
85-
projects:
86-
- name: my-go-project
87-
clonePath: go/src/github.com/acme/my-go-project
88-
git:
89-
remotes:
90-
origin: "https://github.com/acme/my-go-project.git"
91-
commands:
92-
- id: task
93-
vscode-task:
94-
name: tasks
95-
referenceContent: >
96-
{
97-
"version": "2.0.0",
98-
"tasks": [
99-
{
100-
"label": "create test file",
101-
"type": "shell",
102-
"command": "touch ${workspaceFolder}/test.file"
103-
}
104-
]
105-
}
106-
----
107-
108-
This example shows association of a `tasks.json` file with a devfile. Notice the `vscode-task` type that instructs the editor to interpret this command as a tasks definition and `referenceContent` attribute that contains the contents of the file itself. You can also save this file separately from the devfile and use `reference` attribute to specify a relative or absolute URL to it.
109-
11073
. Command group
11174
+
11275
A given command can be assigned to one or more groups that represents the nature of the command. The support groups are: `build`, `run`, `test` and `debug`. For each of the groups, one default command can be defined in each group by specifying the `isDefault` value.
@@ -115,7 +78,7 @@ A given command can be assigned to one or more groups that represents the nature
11578
----
11679
schemaVersion: 2.0.0
11780
metadata:
118-
name: MyDevfile
81+
name: mydevfile
11982
projects:
12083
- name: my-maven-project
12184
clonePath: maven/src/github.com/acme/my-maven-project
@@ -152,7 +115,7 @@ A composite command can be defined to chain multiple commands together. The indi
152115
----
153116
schemaVersion: 2.0.0
154117
metadata:
155-
name: MyDevfile
118+
name: mydevfile
156119
projects:
157120
- name: my-maven-project
158121
clonePath: maven/src/github.com/acme/my-maven-project
@@ -179,35 +142,14 @@ commands:
179142
group:
180143
kind: build
181144
isDefault: true
182-
- id: installAndPackage
145+
- id: installandpackage
183146
composite:
184147
commands:
185148
- install
186149
- package
187150
parallel: false
188151
----
189152

190-
. Command preview URL
191-
+
192-
It is possible to specify a preview URL for commands that expose web UI. This URL is offered for opening when the command is executed.
193-
+
194-
[source,yaml]
195-
----
196-
commands:
197-
- id: tasks
198-
exec:
199-
previewUrl:
200-
port: 8080 <1>
201-
path: /myweb <2>
202-
component: go-cli
203-
commandLine: "go run webserver.go"
204-
workingDir: ${PROJECTS_ROOT}/webserver
205-
----
206-
<1> TCP port where the application listens. Mandatory parameter.
207-
<2> The path part of the URL to the UI. Optional parameter. The default is root (`/`).
208-
209-
The example above opens `++http://__<server-domain>__/myweb++`, where `_<server-domain>_` is the URL to the dynamically created Kubernetes Ingress or OpenShift Route.
210-
211153
[role="_additional-resources"]
212154
.Additional resources
213155

docs/modules/user-guide/partials/proc_adding-event-bindings.adoc

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
= Adding event bindings
33

44
[role="_abstract"]
5-
Adding event bindings.
5+
Commands can be bound to events to form four different types of events: `preStart`, `postStart`, `preStop`, and `postStop`.
66

77
.Prerequisites
88

@@ -17,41 +17,33 @@ Adding event bindings.
1717
----
1818
# v2.0
1919
---
20-
components:
21-
- container:
22-
name: "copier"
23-
image: ''
24-
- container:
25-
name: "maven"
26-
image: ''
27-
- plugin:
28-
id: theia
29-
Commands:
30-
containerBuild:
31-
reference:
32-
composite:
33-
34-
- exec:
35-
name: "copyNeededFiles"
36-
component: "copier"
37-
commandLine: "cp somefile"
38-
- exec:
39-
name: "buildAll"
40-
component: "maven"
41-
commandLine: "mvn ..."
42-
- vsCodeTask:
43-
name: "openFile"
44-
component: "theia"
20+
commands:
21+
- id: init-project
22+
apply:
23+
component: tools
24+
- id: copy-artifacts
25+
exec:
26+
component: tools
27+
commandLine: "cp files"
28+
workingDir: $PROJECTS_ROOT
29+
- id: init-cache
30+
exec:
31+
component: tools
32+
commandLine: "init cache"
33+
workingDir: /.m2
34+
- id: pre-compile-cmd
35+
composite:
36+
commands:
37+
- copy-artifacts
38+
- init-cache
4539
events:
4640
preStart:
47-
- "copyNeededFiles"
41+
- init-project
4842
postStart:
49-
- "buildAll"
50-
- "openFile"
43+
- pre-compile-cmd
5144
----
5245
====
5346

5447
[role="_additional-resources"]
5548
.Additional resources
5649
* See https://github.com/che-incubator/devworkspace-api/issues/32[corresponding issue].
57-
Lines changed: 25 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[id="proc_adding-kubernetes-component-to-a-devfile_{context}"]
2-
= Adding `kubernetes` component to a devfile
2+
= Adding a `kubernetes` or `openshift` component to a devfile
33

44
[role="_abstract"]
5-
This section describes how to add a `kubernetes` component to a devfile. A complex component type that allows to apply configuration from a list of Kubernetes or OpenShift components.
5+
This section describes how to add either a `kubernetes` or `openshfit` component to a devfile. You can apply configurations to your devfile with `kubernetes` or `openshift` components.
66

77
.Prerequisites
88

@@ -12,116 +12,45 @@ This section describes how to add a `kubernetes` component to a devfile. A compl
1212

1313
.Procedure
1414

15-
. Define a component using the type `kubernetes`.
15+
. Define a component using the type `kubernetes` or `openshift`.
1616

17-
. The content can be provided through the `reference` attribute, which points to the file with the component content.
17+
. Provide the content through the `uri` or `inlined` property.
1818
+
19-
.Adding `kubernetes` component using the `reference` attribute
19+
.Adding `openshift` component using the `uri` property
2020
====
2121
[source,yaml]
2222
----
2323
components:
2424
- name: mysql
25-
kubernetes:
26-
reference: petclinic.yaml
27-
selector:
28-
app.kubernetes.io/name: mysql
29-
app.kubernetes.io/component: database
30-
app.kubernetes.io/part-of: petclinic
25+
openshift:
26+
uri: petclinic.yaml
3127
----
3228
====
33-
34-
. Alternatively, to post a devfile with such components to REST API, the contents of the Kubernetes or OpenShift list can be embedded into the devfile using the `referenceContent` field:
35-
+
36-
.Adding `kubernetes` component using the `referenceContent` attribute
37-
====
38-
[source,yaml]
39-
----
40-
components:
41-
- name: mysql
42-
kubernetes:
43-
reference: petclinic.yaml
44-
referenceContent: |
45-
kind: List
46-
items:
47-
-
48-
apiVersion: v1
49-
kind: Pod
50-
metadata:
51-
name: ws
52-
spec:
53-
containers:
54-
... etc
55-
----
56-
====
57-
58-
. Overriding container entrypoints. As with the xref:component-type-container{context}[`container` component], it is possible to override the entrypoint of the containers contained in the Kubernetes or OpenShift list using the `command` and `args` properties (as link:https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes[understood] by Kubernetes).
5929
+
60-
There can be more containers in the list (contained in Pods or Pod templates of deployments). It is therefore necessary to select which containers to apply the entrypoint changes to as follows:
61-
+
62-
.Overriding container entrypoints
30+
.Adding a `kubernetes` component using the `inlined` property
6331
====
6432
[source,yaml]
6533
----
6634
components:
67-
- name: appDeployment
68-
kubernetes:
69-
reference: app-deployment.yaml
70-
entrypoints:
71-
- parentName: mysqlServer
72-
command: ['sleep']
73-
args: ['infinity']
74-
- parentSelector:
75-
app: prometheus
76-
args: ['-f', '/opt/app/prometheus-config.yaml']
35+
- name: myk8deploy
36+
kubernetes:
37+
inlined: |
38+
apiVersion: batch/v1
39+
kind: Job
40+
metadata:
41+
name: pi
42+
spec:
43+
template:
44+
spec:
45+
containers:
46+
- name: job
47+
image: myimage
48+
command: ["some", "command"]
49+
restartPolicy: Never
7750
----
7851
====
7952
+
80-
The `entrypoints` list contains constraints for picking the containers along with the `command` and `args` parameters to apply to them. In the example above, the constraint is `parentName: mysqlServer`, which will cause the command to be applied to all containers defined in any parent object called `mysqlServer`. The parent object is assumed to be a top level object in the list defined in the referenced file, which is `app-deployment.yaml` in the example above.
81-
+
82-
Other types of constraints (and their combinations) are possible:
83-
+
84-
`containerName`:: the name of the container
85-
`parentName`:: the name of the parent object that (indirectly) contains the containers to override
86-
`parentSelector`:: the set of labels the parent object needs to have
87-
+
88-
A combination of these constraints can be used to precisely locate the containers inside the referenced Kubernetes list.
53+
. Specify the endpoint through the endpoint property with `kubernetes` or `openshift` components.
8954

90-
. Overriding container environment variables
91-
+
92-
To provision or override entrypoints in a Kubernetes or OpensShift component, configure it in the following way:
93-
+
94-
.Overriding container environment variables
95-
====
96-
[source,yaml]
97-
----
98-
components:
99-
- name: appDeployment
100-
kubernetes:
101-
reference: app-deployment.yaml
102-
env:
103-
- name: ENV_VAR
104-
value: value
105-
----
106-
====
107-
+
108-
This is useful for temporary content or without access to editing the referenced content. The specified environment variables are provisioned into each init container and containers inside all Pods and Deployments.
109-
110-
. Specifying mount-source option
111-
+
112-
To specify a project sources directory mount into container(s), use the `mountSources` parameter:
113-
+
114-
.Specifying mount-source option
115-
====
116-
[source,yaml]
117-
----
118-
components:
119-
- name: appDeployment
120-
kubernetes:
121-
reference: app-deployment.yaml
122-
mountSources: true
123-
----
124-
====
55+
. Associate `kubernetes` or `openshift` components with `Apply` commands. If you do not associate `Apply` commands, they are assumed to be applied at start up.
12556
+
126-
If enabled, project sources mounts will be applied to every container of the given component.
127-
This parameter is also applicable for `plugin` type components.

0 commit comments

Comments
 (0)