Skip to content

Modified docs to adhere to schema_1st PR #43

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

Merged
merged 3 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ metadata:
----
schemaVersion: 2.0.0
metadata:
generateName: devfile-sample-
name: devfile-sample
----

[NOTE]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A devfile allows to specify commands to be available for execution in a workspac

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

. For each command, define a mandatory type of one of the following types: `exec` or `vscode-tasks`.
. For each command, define a mandatory type of one of the following types: `exec`, `apply`, `composite`, or `vscode-tasks`.
+
.Sample command
[source,yaml]
Expand All @@ -39,7 +39,7 @@ A devfile allows to specify commands to be available for execution in a workspac
----
schemaVersion: 2.0.0
metadata:
name: MyDevfile
name: mydevfile
projects:
- name: my-go-project
clonePath: go/src/github.com/acme/my-go-project
Expand All @@ -64,49 +64,12 @@ commands:
component: go-cli
commandLine: "go get -d && go run main.go"
workingDir: "${PROJECTS_ROOT}/src/github.com/acme/my-go-project"
runAsUser: root
----
+
[NOTE]

* 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.

* A command can have only one action, though you can use `composite` commands to execute several commands either sequentially or in parallel.

. Define attributes for the `vscode-task` or `vscode-launch` command to run using the Editor.
+
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.
+
[source,yaml]
----
schemaVersion: 2.0.0
metadata:
name: MyDevfile
projects:
- name: my-go-project
clonePath: go/src/github.com/acme/my-go-project
git:
remotes:
origin: "https://github.com/acme/my-go-project.git"
commands:
- id: task
vscode-task:
name: tasks
referenceContent: >
{
"version": "2.0.0",
"tasks": [
{
"label": "create test file",
"type": "shell",
"command": "touch ${workspaceFolder}/test.file"
}
]
}
----

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.

. Command group
+
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.
Expand All @@ -115,7 +78,7 @@ A given command can be assigned to one or more groups that represents the nature
----
schemaVersion: 2.0.0
metadata:
name: MyDevfile
name: mydevfile
projects:
- name: my-maven-project
clonePath: maven/src/github.com/acme/my-maven-project
Expand Down Expand Up @@ -152,7 +115,7 @@ A composite command can be defined to chain multiple commands together. The indi
----
schemaVersion: 2.0.0
metadata:
name: MyDevfile
name: mydevfile
projects:
- name: my-maven-project
clonePath: maven/src/github.com/acme/my-maven-project
Expand All @@ -179,35 +142,14 @@ commands:
group:
kind: build
isDefault: true
- id: installAndPackage
- id: installandpackage
composite:
commands:
- install
- package
parallel: false
----

. Command preview URL
+
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.
+
[source,yaml]
----
commands:
- id: tasks
exec:
previewUrl:
port: 8080 <1>
path: /myweb <2>
component: go-cli
commandLine: "go run webserver.go"
workingDir: ${PROJECTS_ROOT}/webserver
----
<1> TCP port where the application listens. Mandatory parameter.
<2> The path part of the URL to the UI. Optional parameter. The default is root (`/`).

The example above opens `++http://__<server-domain>__/myweb++`, where `_<server-domain>_` is the URL to the dynamically created Kubernetes Ingress or OpenShift Route.

[role="_additional-resources"]
.Additional resources

Expand Down
52 changes: 22 additions & 30 deletions docs/modules/user-guide/partials/proc_adding-event-bindings.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
= Adding event bindings

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

.Prerequisites

Expand All @@ -17,41 +17,33 @@ Adding event bindings.
----
# v2.0
---
components:
- container:
name: "copier"
image: ''
- container:
name: "maven"
image: ''
- plugin:
id: theia
Commands:
containerBuild:
reference:
composite:

- exec:
name: "copyNeededFiles"
component: "copier"
commandLine: "cp somefile"
- exec:
name: "buildAll"
component: "maven"
commandLine: "mvn ..."
- vsCodeTask:
name: "openFile"
component: "theia"
commands:
- id: init-project
apply:
component: tools
- id: copy-artifacts
exec:
component: tools
commandLine: "cp files"
workingDir: $PROJECTS_ROOT
- id: init-cache
exec:
component: tools
commandLine: "init cache"
workingDir: /.m2
- id: pre-compile-cmd
composite:
commands:
- copy-artifacts
- init-cache
events:
preStart:
- "copyNeededFiles"
- init-project
postStart:
- "buildAll"
- "openFile"
- pre-compile-cmd
----
====

[role="_additional-resources"]
.Additional resources
* See https://github.com/che-incubator/devworkspace-api/issues/32[corresponding issue].

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[id="proc_adding-kubernetes-component-to-a-devfile_{context}"]
= Adding `kubernetes` component to a devfile
= Adding a `kubernetes` or `openshift` component to a devfile

[role="_abstract"]
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.
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.

.Prerequisites

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

.Procedure

. Define a component using the type `kubernetes`.
. Define a component using the type `kubernetes` or `openshift`.

. The content can be provided through the `reference` attribute, which points to the file with the component content.
. Provide the content through the `uri` or `inlined` property.
+
.Adding `kubernetes` component using the `reference` attribute
.Adding `openshift` component using the `uri` property
====
[source,yaml]
----
components:
- name: mysql
kubernetes:
reference: petclinic.yaml
selector:
app.kubernetes.io/name: mysql
app.kubernetes.io/component: database
app.kubernetes.io/part-of: petclinic
openshift:
uri: petclinic.yaml
----
====

. 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:
+
.Adding `kubernetes` component using the `referenceContent` attribute
====
[source,yaml]
----
components:
- name: mysql
kubernetes:
reference: petclinic.yaml
referenceContent: |
kind: List
items:
-
apiVersion: v1
kind: Pod
metadata:
name: ws
spec:
containers:
... etc
----
====

. 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).
+
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:
+
.Overriding container entrypoints
.Adding a `kubernetes` component using the `inlined` property
====
[source,yaml]
----
components:
- name: appDeployment
kubernetes:
reference: app-deployment.yaml
entrypoints:
- parentName: mysqlServer
command: ['sleep']
args: ['infinity']
- parentSelector:
app: prometheus
args: ['-f', '/opt/app/prometheus-config.yaml']
- name: myk8deploy
kubernetes:
inlined: |
apiVersion: batch/v1
kind: Job
metadata:
name: pi
spec:
template:
spec:
containers:
- name: job
image: myimage
command: ["some", "command"]
restartPolicy: Never
----
====
+
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.
+
Other types of constraints (and their combinations) are possible:
+
`containerName`:: the name of the container
`parentName`:: the name of the parent object that (indirectly) contains the containers to override
`parentSelector`:: the set of labels the parent object needs to have
+
A combination of these constraints can be used to precisely locate the containers inside the referenced Kubernetes list.
. Specify the endpoint through the endpoint property with `kubernetes` or `openshift` components.

. Overriding container environment variables
+
To provision or override entrypoints in a Kubernetes or OpensShift component, configure it in the following way:
+
.Overriding container environment variables
====
[source,yaml]
----
components:
- name: appDeployment
kubernetes:
reference: app-deployment.yaml
env:
- name: ENV_VAR
value: value
----
====
+
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.

. Specifying mount-source option
+
To specify a project sources directory mount into container(s), use the `mountSources` parameter:
+
.Specifying mount-source option
====
[source,yaml]
----
components:
- name: appDeployment
kubernetes:
reference: app-deployment.yaml
mountSources: true
----
====
. Associate `kubernetes` or `openshift` components with `Apply` commands. If you do not associate `Apply` commands, they are assumed to be applied at start up.
+
If enabled, project sources mounts will be applied to every container of the given component.
This parameter is also applicable for `plugin` type components.
Loading