Skip to content

Commit

Permalink
Update devfile schema based on devfile/api@c088cf3
Browse files Browse the repository at this point in the history
Signed-off-by: Theofanis Petkos <thepetk@gmail.com>
  • Loading branch information
thepetk committed Jun 3, 2024
1 parent 5633e6a commit 75f83ad
Show file tree
Hide file tree
Showing 30 changed files with 4,631 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libs/docs/src/config/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

import { DocVersions } from '../types';

export const docVersions = ['2.0.0', '2.1.0', '2.2.0', '2.2.1', '2.2.2'] as const;
export const docVersions = ['2.0.0', '2.1.0', '2.2.0', '2.2.1', '2.2.2', '2.3.0'] as const;

export const defaultVersion: DocVersions = '2.2.2';
3 changes: 2 additions & 1 deletion libs/docs/src/config/versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
2.1.0
2.2.0
2.2.1
2.2.2
2.2.2
2.3.0
2,211 changes: 2,211 additions & 0 deletions libs/docs/src/devfile-schemas/2.3.0.json

Large diffs are not rendered by default.

92 changes: 92 additions & 0 deletions libs/docs/src/docs/2.3.0/adding-a-command-group.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
title: Adding a command group
description: Adding a command group
---

Create command groups to help automate your devfile.

## Procedure

1. Assign a given command to one or more groups that represent the
nature of the command.

2. Use the following supported group kinds: `build`, `run`, `test`,
`debug` or `deploy`

3. At most, there can only be one default command for each group kind.
Set the default command by specifying `isDefault` to `true`.

```yaml {% filename="devfile.yaml" %}
schemaVersion: 2.2.0
metadata:
name: mydevfile
projects:
- name: my-maven-project
clonePath: maven/src/github.com/acme/my-maven-project
git:
remotes:
origin: 'https://github.com/acme/my-maven-project.git'
components:
- name: maven
container:
image: eclipse/maven-jdk8:latest
mountSources: true
command: ['tail']
commands:
- id: package
exec:
component: maven
commandLine: 'mvn package'
group:
kind: build
- id: install
exec:
component: maven
commandLine: 'mvn install'
group:
kind: build
isDefault: true
```
4. Use the `deploy` kind to reference a deploy command for an outerloop
scenario.

```yaml {% filename="devfile.yaml" %}
schemaVersion: 2.2.0
metadata:
name: python
version: 1.0.0
provider: Red Hat
supportUrl: https://github.com/devfile-samples/devfile-support#support-information
attributes:
alpha.dockerimage-port: 8081
parent:
id: python
registryUrl: 'https://registry.devfile.io'
components:
- name: outerloop-build
image:
imageName: python-image:latest
dockerfile:
uri: docker/Dockerfile
buildContext: .
rootRequired: false
- name: outerloop-deploy
kubernetes:
uri: outerloop-deploy.yaml
commands:
- id: build-image
apply:
component: outerloop-build
- id: deployk8s
apply:
component: outerloop-deploy
- id: deploy
composite:
commands:
- build-image
- deployk8s
group:
kind: deploy
isDefault: true
```
52 changes: 52 additions & 0 deletions libs/docs/src/docs/2.3.0/adding-a-composite-command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: Adding a composite command
description: Adding a composite command
---

Connect multiple commands together by defining a composite command.

## Procedure

1. Reference the individual commands that are called from a composite
command by using the `id` of the command.

2. Specify whether to run the commands within a composite command in
sequence or parallel by defining the `parallel` property

```yaml {% filename="devfile.yaml" %}
schemaVersion: 2.2.0
metadata:
name: mydevfile
projects:
- name: my-maven-project
clonePath: maven/src/github.com/acme/my-maven-project
git:
remotes:
origin: 'https://github.com/acme/my-maven-project.git'
components:
- name: maven
container:
image: eclipse/maven-jdk8:latest
mountSources: true
command: ['tail']
commands:
- id: package
exec:
component: maven
commandLine: 'mvn package'
group:
kind: build
- id: install
exec:
component: maven
commandLine: 'mvn install'
group:
kind: build
isDefault: true
- id: installandpackage
composite:
commands:
- install
- package
parallel: false
```
128 changes: 128 additions & 0 deletions libs/docs/src/docs/2.3.0/adding-a-container-component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
title: Adding a container component
description: Adding a container component
---

To incorporate custom tools into the workspace, define an image-based
configuration of a container in a workspace using the `container` component type.

## Prerequisites

- [Adding schema version](./versions)

- [Adding a name](./metadata)

- [Adding components](./adding-components)

## Procedure

1. Define a component using the type `container`.

```yaml {% title="A container component" filename="devfile.yaml" %}
components:
- name: maven
container:
image: eclipse/maven-jdk8:latest
volumeMounts:
- name: mavenrepo
path: /root/.m2
env:
- name: ENV_VAR
value: value
endpoints:
- name: maven-server
targetPort: 3101
protocol: https
secure: 'true'
exposure: public
memoryRequest: 256M
memoryLimit: 1536M
cpuRequest: 0.1
cpuLimit: 0.5
command: ['tail']
args: ['-f', '/dev/null']
```
```yaml {% title="A minimal container component" filename="devfile.yaml" %}
schemaVersion: 2.2.0
metadata:
name: mydevfile
components:
- name: go
container:
image: golang
memoryLimit: 512Mi
command: ['sleep', 'infinity']
```
Specify the type of component using the `container` property. Use
the `image` property to specify the image for the component. When
defining the `image`, use container naming conventions. For example,
the `image` property in the preceding example refers to the
container image, `docker.io/library/golang:latest`.

Use the `container` component to augment the image with additional
resources and information. This component allows you to integrate
the tooling provided by the image with the application that consumes
the devfile.

2. Mounting project sources

For the `container` component to have access to the project sources,
you must set the `mountSources` attribute to `true`.

```yaml {% filename="devfile.yaml" %}
schemaVersion: 2.2.0
metadata:
name: mydevfile
components:
- name: go
container:
image: golang
memoryLimit: 512Mi
mountSources: true
command: ['sleep', 'infinity']
```

The sources are mounted on a location stored in the `PROJECTS_ROOT`
environment variable that is made available in the running container
of the image. This location defaults to `/projects`. If
`sourceMapping` is defined in the container, it overrides the
`PROJECT_ROOT` value and mounts the source to the path defined by
`sourceMapping`.

3. Specify a volume

For the `container` component to have a shared volume, you must
define a volume component in the devfile and reference the volume
using `volumeMount` in container component. For more information on
volume component, see [adding a volume component](./adding-a-volume-component).

```yaml {% filename="devfile.yaml" %}
components:
- name: mycontainer
container:
image: java11-maven:next
memoryLimit: 768Mi
mountSources: true
volumeMounts:
- name: m2
path: /home/user/.m2
- name: m2
volume:
size: 1Gi
```

4. Container Entrypoint

Use the `command` attribute of the `container` type to modify the
`entrypoint` command of the container created from the image. The
availability of the `sleep` command and the support for the
`infinity` argument depend on the base image used in the particular
images.

## Additional Resources

- [API Reference](./devfile-schema)

- [Devfile resources](./resources)
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: Adding a kubernetes or openshift component
description: Adding a kubernetes or openshift component
---

You can add either a `kubernetes` or `openshift` component to a devfile.

## Prerequisites

- [Adding schema version](./versions)

- [Adding a name](./metadata)

- [Adding components](./adding-components)

## Procedure

1. Define a component using the `kubernetes` or `openshift` property.

2. Provide the content through the `uri` or `inlined` property.

```yaml {% title="Adding an openshift component using the uri property" filename="devfile.yaml" %}
components:
- name: mysql
openshift:
uri: petclinic.yaml
```
```yaml {% title="Adding a kubernetes component using the inlined property" filename="devfile.yaml" %}
components:
- 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
```
3. Specify the endpoint through the endpoint property with `kubernetes`
or `openshift` components.

4. By default `kubernetes` or `openshift` components are not going to
be deployed. Specify `deployByDefault: true` if you want to apply the
component at start up.

5. Associate `kubernetes` or `openshift` components with `apply`
commands wth `deploy` command group kind. If the `kubernetes` or
`openshift` component uses an image built by an `image` component
defined in the devfile, you can create a composite `deploy` command
to build the image and deploy the `kubernetes` or `openshift` component.
For more information on `deploy` commands, see [adding a command group](./adding-a-command-group).
Loading

0 comments on commit 75f83ad

Please sign in to comment.