Skip to main content
Version: v3

odo init

The odo init command is the first command to be executed when you want to bootstrap a new component, using odo. If sources already exist, the command odo dev should be considered instead.

This command must be executed from a directory with no devfile.yaml file.

The command can be executed in two flavors, either interactive or non-interactive.

Running the command

Interactive mode

In interactive mode, the behavior of odo init depends on whether the current directory already contains source code or not.

Empty directory

If the directory is empty, you will be guided to:

  • choose a devfile from the list of devfiles present in the registry or registries referenced (using the odo registry command),
  • configure the devfile
  • choose a starter project referenced by the selected devfile,
  • choose a name for the component present in the devfile; this name must follow the Kubernetes naming convention and not be all-numeric.
odo init
Example
$ odo init
__
/ \__ Initializing a new component
\__/ \ Files: No source code detected, a starter project will be created in the current directory
/ \__/ odo version: v3.10.0
\__/

Interactive mode enabled, please answer the following questions:
? Select language: Java
? Select project type: Maven Java
✓ Downloading devfile "java-maven" from registry "DefaultDevfileRegistry" [4s]

↪ Container Configuration "tools":
OPEN PORTS:
- 8080
- 5858
ENVIRONMENT VARIABLES:
- DEBUG_PORT = 5858

? Select container for which you want to change configuration? NONE - configuration is correct
? Which starter project do you want to use? springbootproject
? Enter component name: my-java-maven-app
✓ Downloading starter project "springbootproject" [1s]

You can automate this command by executing:
odo init --name my-java-maven-app --devfile java-maven --devfile-registry DefaultDevfileRegistry --starter springbootproject

Your new component 'my-java-maven-app' is ready in the current directory.
To start editing your component, use 'odo dev' and open this folder in your favorite IDE.
Changes will be directly reflected on the cluster.

Directory with sources

If the current directory is not empty, odo init will make its best to autodetect the type of application and propose you a Devfile that should suit your project. It will try to detect the following, based on the files in the current directory:

  • Language
  • Project Type
  • Ports used in your application
  • A Devfile that should help you start with odo

If the information detected does not seem correct to you, you are able to select a different Devfile.

In all cases, you will be guided to:

  • configure the devfile
  • choose a name for the component present in the devfile; this name must follow the Kubernetes naming convention and not be all-numeric.
odo init
Example
$ odo init
__
/ \__ Initializing a new component
\__/ \ Files: Source code detected, a Devfile will be determined based upon source code autodetection
/ \__/ odo version: v3.10.0
\__/

Interactive mode enabled, please answer the following questions:
Based on the files in the current directory odo detected
Language: JavaScript
Project type: Node.js
Application ports: 8080
The devfile "nodejs:2.1.1" from the registry "DefaultDevfileRegistry" will be downloaded.
? Is this correct? Yes
✓ Downloading devfile "nodejs:2.1.1" from registry "DefaultDevfileRegistry" [3s]

↪ Container Configuration "runtime":
OPEN PORTS:
- 8080
- 5858
ENVIRONMENT VARIABLES:
- DEBUG_PORT = 5858

? Select container for which you want to change configuration? NONE - configuration is correct
? Enter component name: node-echo

You can automate this command by executing:
odo init --name node-echo --devfile nodejs --devfile-registry DefaultDevfileRegistry --devfile-version 2.1.1

Your new component 'node-echo' is ready in the current directory.
To start editing your component, use 'odo dev' and open this folder in your favorite IDE.
Changes will be directly reflected on the cluster.

Non-interactive mode

In non-interactive mode, you will have to specify from the command-line the information needed to get a devfile.

If you want to download a devfile from a registry, you must specify the devfile name with the --devfile flag. The devfile with the specified name will be searched in the registries referenced (using odo preference view), and the first one matching will be downloaded. If you want to download the devfile from a specific registry in the list or referenced registries, you can use the --devfile-registry flag to specify the name of this registry. By default odo uses official devfile registry registry.devfile.io. You can use registry's web interface to view its content. If you want to download a version devfile, you must specify the version with --devfile-version flag.

If you prefer to download a devfile from an URL or from the local filesystem, you can use the --devfile-path instead.

The --starter flag indicates the name of the starter project (as referenced in the selected devfile), that you want to use to start your development. To see the available starter projects for devfile stacks in the official devfile registry use its web interface to view its content.

The required --name flag indicates how the component initialized by this command should be named. The name must follow the Kubernetes naming convention and not be all-numeric.

Fetch Devfile from any registry of the list

In this example, the devfile will be downloaded from the StagingRegistry registry, which is the first one in the list containing the nodejs-react devfile.

odo init --name <component-name> --devfile <devfile> [--starter STARTER]
Example
$ odo preference view
[...]

Devfile registries:
NAME URL SECURE
StagingRegistry https://registry.stage.devfile.io No
DefaultDevfileRegistry https://registry.devfile.io No
$ odo registry --devfile nodejs-react
NAME REGISTRY DESCRIPTION VERSIONS
nodejs-react StagingRegistry React is a free and open-source front-en... 2.0.2, 2.1.0
nodejs-react DefaultDevfileRegistry React is a free and open-source front-en... 2.0.2, 2.1.0
$ odo init --devfile nodejs-react --name my-nr-app
__
/ \__ Initializing a new component
\__/ \
/ \__/ odo version: v3.10.0
\__/

✓ Downloading devfile "nodejs-react" [3s]

Your new component 'my-nr-app' is ready in the current directory.
To start editing your component, use 'odo dev' and open this folder in your favorite IDE.
Changes will be directly reflected on the cluster.

Fetch Devfile from a specific registry of the list

In this example, the devfile will be downloaded from the DefaultDevfileRegistry registry, as explicitly indicated by the --devfile-registry flag.

Example
$ odo preference view
[...]

Devfile registries:
NAME URL SECURE
StagingRegistry https://registry.stage.devfile.io No
DefaultDevfileRegistry https://registry.devfile.io No
$ odo init --name my-spring-app --devfile java-springboot --devfile-registry DefaultDevfileRegistry --starter springbootproject
__
/ \__ Initializing a new component
\__/ \
/ \__/ odo version: v3.10.0
\__/

✓ Downloading devfile "java-springboot" from registry "DefaultDevfileRegistry" [4s]
✓ Downloading starter project "springbootproject" [874ms]

Your new component 'my-spring-app' is ready in the current directory.
To start editing your component, use 'odo dev' and open this folder in your favorite IDE.
Changes will be directly reflected on the cluster.

Fetch Devfile from a URL

odo init --devfile-path <URL> --name <component-name> [--starter STARTER]
Example
$ odo init --devfile-path https://registry.devfile.io/devfiles/nodejs-angular --name my-nodejs-app --starter nodejs-angular-starter
__
/ \__ Initializing a new component
\__/ \
/ \__/ odo version: v3.10.0
\__/

✓ Downloading devfile from "https://registry.devfile.io/devfiles/nodejs-angular" [1s]
✓ Downloading starter project "nodejs-angular-starter" [958ms]

Your new component 'my-nodejs-app' is ready in the current directory.
To start editing your component, use 'odo dev' and open this folder in your favorite IDE.
Changes will be directly reflected on the cluster.

Fetch Devfile of a specific version

odo init --devfile <devfile-name> --devfile-version <devfile-version> --name <component-name> [--starter STARTER]
Examples
$ odo init --devfile go --name my-go-app --devfile-version 2.0.0
__
/ \__ Initializing a new component
\__/ \
/ \__/ odo version: v3.10.0
\__/

✓ Downloading devfile "go:2.0.0" [3s]

Your new component 'my-go-app' is ready in the current directory.
To start editing your component, use 'odo dev' and open this folder in your favorite IDE.
Changes will be directly reflected on the cluster.
To deploy your component to a cluster use "odo deploy".
note

Use "latest" as the version name to fetch the latest version of a given Devfile.

Example
$ odo init --devfile go --name my-go-app --devfile-version latest
__
/ \__ Initializing a new component
\__/ \
/ \__/ odo version: v3.10.0
\__/

✓ Downloading devfile "go:latest" [4s]

Your new component 'my-go-app' is ready in the current directory.
To start editing your component, use 'odo dev' and open this folder in your favorite IDE.
Changes will be directly reflected on the cluster.
To deploy your component to a cluster use "odo deploy".