title | language_tabs | toc_footers | search | |||
---|---|---|---|---|---|---|
Odo Devfile Reference |
|
|
true |
A full odo Devfile example using Spring Boot
schemaVersion: 2.0.0
metadata:
name: springBoot
version: 1.0.0
projects:
- name: springbootproject
git:
location: "https://github.com/odo-devfiles/springboot-ex.git"
components:
- container:
name: tools
image: maysunfaisal/springbootbuild
memoryLimit: 768Mi
command: ['tail']
args: [ '-f', '/dev/null']
mountSources: true
volumeMounts:
- name: springbootpvc
path: /data
- container:
name: runtime
image: maysunfaisal/springbootruntime
memoryLimit: 768Mi
command: ['tail']
args: [ '-f', '/dev/null']
endpoints:
- name: '8080/tcp'
configuration:
public: true
targetPort: 8080
mountSources: false
volumeMounts:
- name: springbootpvc
path: /data
commands:
- exec:
id: devBuild
commandLine: "/artifacts/bin/build-container-full.sh"
component: tools
workingDir: /projects/springbootproject
group:
kind: build
isDefault: true
- exec:
id: devRun
commandLine: "/artifacts/bin/start-server.sh"
component: runtime
workingDir: /
group:
kind: run
isDefault: true
Download the application
$ odo create nodejs --downloadSource
Create a URL and push the service
$ odo url create
$ odo push
odo
odo is a fast, iterative, and straightforward CLI tool for developers who write, build, and deploy applications on OpenShift.
Existing tools such as oc are more operations-focused and require a deep-understanding of Kubernetes and OpenShift concepts. odo abstracts away complex Kubernetes and OpenShift concepts for the developer.
Devfile
What is a devfile?
A devfile is a portable file that describes your development environment. It allows for a portable developmental environment without the need of reconfiguration.
With a devfile you can describe:
- The source code being used
- Development components such as IDE tools (VSCode) and application runtimes (Yarn / NPM)
- A list of pre-defined commands that can be run
- Projects to initially clone
Odo takes this devfile and transforms it into a workspace of multiple containers running on OpenShift, Kubernetes or Docker.
Devfiles are YAML files with a defined schema.
PLEASE NOTE: Devfile v2 is still in its early stages and there are some parts of the schema that have not yet been implemented.
Please refer to the below table for a list of features which are not yet implemented:
Key | Key Description | Status | Description |
---|---|---|---|
projects[].github.startPoint | githubObject | IN PROGRESS | Refer to issue: #3002 |
projects[].github.startPoint | githubObject | IN PROGRESS | Refer to issue: #3002 |
projects[].git.startPoint | gitObject | IN PROGRESS | Refer to issue: #3002 |
projects[].zip | zipObject | IN PROGRESS | Entire object not yet implemented. Refer to issue: #3442 |
parent | parentObject | IN PROGRESS | Refer to issue: #2919 |
events | eventObject | IN PROGRESS | Refer to issue: #2919 |
component[].kubernetes | kubernetesObject | IN PROGRESS | Refer to: |
component[].openshift | openshiftObject | IN PROGRESS | Refer to: |
component[].volume | volumeObject | IN PROGRESS | Refer to: |
component[].plugin | pluginObject | IN PROGRESS | Refer to: #3407 |
component[].container.endpoints.attributes | attributeObject | UNKNOWN | In schema but not yet implemented. |
component[].container.endpoints.configuration.cookiesAuthEnabled | configurationObject | UNKNOWN | In schema but not yet implemented. |
component[].container.endpoints.configuration.type | configurationObject | UNKNOWN | In schema but not yet implemented. |
commands[].apply | applyObject | UNKNOWN | In schema but not yet implemented. |
commands[].composite | compositeObject | UNKNOWN | In schema but not yet implemented. |
commands[].vscodeLaunch | vscodeLaunchObject | UNKNOWN | In schema but not yet implemented. |
commands[].vscodeTask | vscodeTaskObject | UNKNOWN | In schema but not yet implemented. |
commands[].exec.attributes | execObject | UNKNOWN | In schema but not yet implemented. |
Installing odo can be found at our installation page.
If you haven't used odo yet, we reccomend going through our Deploying a devfile using odo guide.
All defineable Devfile properties
schemaVersion: <string>
metadata: <metadataObject>
projects:
- <projectObject>
components:
- <componentObject>
commands:
- <commandObject>
Key | Type | Required | Description |
---|---|---|---|
schemaVersion | string | yes | Schema version of Devfile |
metadata | metadataObject | no | metadataObject |
projects | array of projectObject | no | projectObject |
components | array of componentObject | no | componentObject |
commands | array of commandObject | no | commandObject |
schemaVersion: 2.0.0
Key | Type | Required | Description |
---|---|---|---|
schemaVersion | string | yes | Either 1.0.0 or 2.0.0 of the schema |
metadata:
name: nodejs
version: 1.0.0
Key | Type | Required | Description |
---|---|---|---|
name | string | yes | Name of your devfile |
version | string | yes | Version of your devfile |
Pulling from a git location
projects:
- name: nodejs-web-app
git:
location: https://github.com/odo-devfiles/nodejs-ex.git
branch: master
sparseCheckoutDir: /app/ # optional checkout dir
startPoint: 1.0.0 # tag or commit to start at
Pulling from a GitHub location
projects:
- name: nodejs-web-app
github:
location: https://github.com/odo-devfiles/nodejs-ex.git
branch: master
sparseCheckoutDir: /app/ # optional checkout dir
startPoint: 1.0.0 # tag or commit to start at
Pulling from a zip
projects:
- name: nodejs-web-app
zip:
location: https://github.com/odo-devfiles/nodejs-ex/archive/0.0.1.zip
sparseCheckoutDir: /app/ # optional checkout dir
Key | Type | Description |
---|---|---|
projectObject | projectObject | List of projects to be used |
Example using an OpenLiberty container
components:
- container:
name: appsodyrun
image: 'ajymau/java-openliberty-dev:latest'
memoryLimit: 1512Mi
mountSources: true
endpoints:
- name: 9080/tcp
configuration:
discoverable: false
public: true
protocol: tcp
scheme: http
targetPort: 9080
env:
- name: MODE2
value: TEST2
- name: myprop2
value: myval2
Key | Type | Description |
---|---|---|
componentObject | componentObject | List of components to be used |
Example using the exec command
commands:
- exec:
id: devBuild
commandLine: "/artifacts/bin/build-container-full.sh"
component: tools
workingDir: /projects/springbootproject
group:
kind: build
isDefault: true
- exec:
id: devRun
commandLine: "/artifacts/bin/start-server.sh"
component: runtime
workingDir: /
group:
kind: run
isDefault: true
Key | Type | Description |
---|---|---|
exec | execObject | CLI Command executed in an existing component container |
Pulling from a git location
projects:
- name: nodejs-web-app
git:
location: https://github.com/odo-devfiles/nodejs-ex.git
branch: master
sparseCheckoutDir: /app/ # optional checkout dir
startPoint: 1.0.0 # tag or commit to start at
Pulling from a GitHub location
projects:
- name: nodejs-web-app
github:
location: https://github.com/odo-devfiles/nodejs-ex.git
branch: master
sparseCheckoutDir: /app/ # optional checkout dir
startPoint: 1.0.0 # tag or commit to start at
Pulling from a zip
projects:
- name: nodejs-web-app
zip:
location: https://github.com/odo-devfiles/nodejs-ex/archive/0.0.1.zip
sparseCheckoutDir: /app/ # optional checkout dir
Each project may contain three different objects, git
, github
or zip
.
Key | Type | Description |
---|---|---|
name | string | Name of your devfile |
clonePath | string | Path relative the root of your projects to which the project should be cloned into |
git | gitObject | Pull from a Git location |
github | githubObject | Pull from GitHub |
zip | zipObject | Get from a zip location |
Using the gitObject
projects:
- name: nodejs-web-app
git:
location: https://github.com/odo-devfiles/nodejs-ex.git
branch: master
sparseCheckoutDir: /app/ # optional checkout dir
startPoint: 1.0.0 # tag or commit to start at
Key | Type | Description |
---|---|---|
location | string | Location of the git repository |
branch | string | What branch to use |
spareCheckoutDir | string | What directory to use when pulling |
startPoint | string | Tag or commit to start from |
Using the githubObject
projects:
- name: nodejs-web-app
github:
location: https://github.com/odo-devfiles/nodejs-ex.git
branch: master
sparseCheckoutDir: /app/ # optional checkout dir
startPoint: 1.0.0 # tag or commit to start at
Key | Type | Description |
---|---|---|
location | string | Location of the git repository |
branch | string | What branch to use |
spareCheckoutDir | string | What directory to use when pulling |
startPoint | string | Tag or commit to start from |
Using the zipObject
projects:
- name: nodejs-web-app
zip:
location: https://github.com/odo-devfiles/nodejs-ex/archive/0.0.1.zip
sparseCheckoutDir: /app/ # optional checkout dir
Key | Type | Description |
---|---|---|
location | string | Location of the zip |
spareCheckoutDir | string | What directory to use when pulling |
Example using a container using the minimum amount of keys
components:
- container:
name: appsodyrun
image: 'ajymau/java-openliberty-dev:latest'
Each component must use the container
object.
Key | Type | Description |
---|---|---|
containerObject | containerObject | List of containers to be used |
Example using an OpenLiberty container
components:
- container:
name: appsodyrun
image: 'ajymau/java-openliberty-dev:latest'
memoryLimit: 1512Mi
mountSources: true
endpoints:
- name: 9080/tcp
configuration:
discoverable: false
public: true
protocol: tcp
scheme: http
targetPort: 9080
env:
- name: MODE2
value: TEST2
- name: myprop2
value: myval2
Key | Type | Required | Description |
---|---|---|---|
name | string | yes | Name of your container |
image | string | yes | Image version |
memoryLimit | string | no | Memory limit to be used with your container |
mountSources | boolean | no | Mount the source or not |
sourceMapping | string | no | Path in the container where project sources should be transferred / mounted when mountSource is set to true |
endpoints[] | endpointObject | no | List of endpoints to use |
volumeMounts[] | volumeMountsObject | no | List of volumes to mount |
env[] | envObject | no | List of environment variables to use |
Example using an endpoint
components:
- container:
name: appsodyrun
image: 'ajymau/java-openliberty-dev:latest'
endpoints:
- name: 9080/tcp
configuration:
discoverable: false
public: true
protocol: tcp
scheme: http
targetPort: 9080
Key | Type | Required | Description |
---|---|---|---|
name | string | yes | Name of your endpoint |
targetPort | integer | yes | Port number that you are targeting |
configuration | configurationObject | no | Configuration attributes regarding the port number and protocol(s) being used |
attributes | attributesObject | no | UNKNOWN, TODO: FILL IN HERE! |
Example using a configuration object with an endpoint
components:
- container:
name: appsodyrun
image: 'ajymau/java-openliberty-dev:latest'
endpoints:
- name: 9080/tcp
configuration:
discoverable: false
public: true
protocol: tcp
scheme: http
targetPort: 9080
Key | Type | Required | Description |
---|---|---|---|
discoverable | boolean | no | Whether or not you want your endpoint discoverable |
public | boolean | no | Whether or not you want your endpoint public |
protocol | string | no | tcp or udp |
scheme | string | no | http or https |
secure | boolean | no | Whether or not the endpoint is defined as secure |
Example using a volume with a container
components:
- container:
name: tools
image: maysunfaisal/springbootbuild
memoryLimit: 768Mi
command: ['tail']
args: [ '-f', '/dev/null']
mountSources: true
volumeMounts:
- name: springbootpvc
path: /data
Key | Type | Required | Description |
---|---|---|---|
name | string | yes | Name of the volume |
path | string | no | Path in the component container where the volume should be mounted. Defaults to /<name> if blank |
Example using an exec command within a command object
commands:
- exec:
id: devBuild
component: tools
commandLine: "/artifacts/bin/build-container-full.sh"
workingDir: /projects/springbootproject
group:
kind: build
isDefault: true
Each command must use the exec
object.
Key | Type | Description |
---|---|---|
execObject | execObject | The CLI command to be ran |
Example using exec command within a command object
commands:
- exec:
id: devBuild
commandLine: "/artifacts/bin/build-container-full.sh"
component: tools
workingDir: /projects/springbootproject
group:
kind: build
isDefault: true
env:
- name: FOO
value: BAR
Key | Type | Required | Description |
---|---|---|---|
id | string | yes | ID of the command |
commandLine | string | yes | Command to be ran |
component | string | no | What component that the actions relate to |
label | string | no | Optional label to be used to describe the command |
workingDir | string | no | Working directory where the command should be executed |
group | groupObject | no | Group that the command is part of |
env | envObject | no | List of environment variables used |
Example using the group object within exec
commands:
- exec:
id: devBuild
commandLine: "/artifacts/bin/build-container-full.sh"
group:
kind: build
isDefault: true
Key | Type | Required | Description |
---|---|---|---|
kind | string | yes | Kind of group the command is part of. Options: build , run , test , debug |
isDefault | boolean | no | Identifies that it is the default command to be ran |
List of objects which are found in multiple parts of Devfile. For example, the envObject is found within containerObject and execObject.
Example using environment variables with a container
components:
- container:
name: appsodyrun
image: 'ajymau/java-openliberty-dev:latest'
targetPort: 9080
env:
- name: MODE2
value: TEST2
- name: myprop2
value: myval2
Example using environment variables within the exec command
commands:
- exec:
id: devBuild
commandLine: "/artifacts/bin/build-container-full.sh"
env:
- name: FOO
value: BAR
Key | Type | Required | Description |
---|---|---|---|
name | string | yes | Name of the environment variable |
value | string | yes | Value of the environment variable |