odo CLI reference

Basic odo CLI commands

app

Perform application operations related to your OKD project.

Example using app

  1. # Delete the application
  2. odo app delete myapp
  3. # Describe 'webapp' application,
  4. odo app describe webapp
  5. # List all applications in the current project
  6. odo app list
  7. # List all applications in the specified project
  8. odo app list --project myproject

catalog

Perform catalog-related operations.

Example using catalog

  1. # Get the supported components
  2. odo catalog list components
  3. # Get the supported services from service catalog
  4. odo catalog list services
  5. # Search for a component
  6. odo catalog search component python
  7. # Search for a service
  8. odo catalog search service mysql
  9. # Describe a service
  10. odo catalog describe service mysql-persistent

component

Manage components of an application.

Example using component

  1. # Create a new component
  2. odo component create
  3. # Create a local configuration and create all objects on the cluster
  4. odo component create --now

config

Modify odo specific settings within the config file.

Example using config

  1. # For viewing the current local configuration
  2. odo config view
  3. # Set a configuration value in the local configuration
  4. odo config set Type java
  5. odo config set Name test
  6. odo config set MinMemory 50M
  7. odo config set MaxMemory 500M
  8. odo config set Memory 250M
  9. odo config set Ignore false
  10. odo config set MinCPU 0.5
  11. odo config set MaxCPU 2
  12. odo config set CPU 1
  13. # Set an environment variable in the local configuration
  14. odo config set --env KAFKA_HOST=kafka --env KAFKA_PORT=6639
  15. # Create a local configuration and apply the changes to the cluster immediately
  16. odo config set --now
  17. # Unset a configuration value in the local config
  18. odo config unset Type
  19. odo config unset Name
  20. odo config unset MinMemory
  21. odo config unset MaxMemory
  22. odo config unset Memory
  23. odo config unset Ignore
  24. odo config unset MinCPU
  25. odo config unset MaxCPU
  26. odo config unset CPU
  27. # Unset an env variable in the local config
  28. odo config unset --env KAFKA_HOST --env KAFKA_PORT

Application

Application is the name of application the component needs to be part of

CPU

The minimum and maximum CPU a component can consume

Ignore

Consider the .odoignore file for push and watch

Table 1. Available Local Parameters:

Application

The name of application that the component needs to be part of

CPU

The minimum and maximum CPU a component can consume

Ignore

Whether to consider the .odoignore file for push and watch

MaxCPU

The maximum CPU a component can consume

MaxMemory

The maximum memory a component can consume

Memory

The minimum and maximum memory a component can consume

MinCPU

The minimum CPU a component can consume

MinMemory

The minimum memory a component is provided

Name

The name of the component

Ports

Ports to be opened in the component

Project

The name of the project that the component is part of

Ref

Git ref to use for creating component from git source

SourceLocation

The path indicates the location of binary file or git source

SourceType

Type of component source - git/binary/local

Storage

Storage of the component

Type

The type of component

Url

The URL to access the component

create

Create a configuration describing a component to be deployed on OKD. If a component name is not provided, it is autogenerated.

By default, builder images are used from the current namespace. To explicitly supply a namespace, use: odo create namespace/name:version. If a version is not specified, the version defaults to latest.

Use odo catalog list to see a full list of component types that can be deployed.

Example using create

  1. # Create new Node.js component with the source in current directory.
  2. odo create nodejs
  3. # Create new Node.js component and push it to the cluster immediately.
  4. odo create nodejs --now
  5. # A specific image version may also be specified
  6. odo create nodejs:latest
  7. # Create new Node.js component named 'frontend' with the source in './frontend' directory
  8. odo create nodejs frontend --context ./frontend
  9. # Create a new Node.js component of version 6 from the 'openshift' namespace
  10. odo create openshift/nodejs:6 --context /nodejs-ex
  11. # Create new Wildfly component with binary named sample.war in './downloads' directory
  12. odo create wildfly wildfly --binary ./downloads/sample.war
  13. # Create new Node.js component with source from remote git repository
  14. odo create nodejs --git https://github.com/openshift/nodejs-ex.git
  15. # Create new Node.js git component while specifying a branch, tag or commit ref
  16. odo create nodejs --git https://github.com/openshift/nodejs-ex.git --ref master
  17. # Create new Node.js git component while specifying a tag
  18. odo create nodejs --git https://github.com/openshift/nodejs-ex.git --ref v1.0.1
  19. # Create new Node.js component with the source in current directory and ports 8080-tcp,8100-tcp and 9100-udp exposed
  20. odo create nodejs --port 8080,8100/tcp,9100/udp
  21. # Create new Node.js component with the source in current directory and env variables key=value and key1=value1 exposed
  22. odo create nodejs --env key=value,key1=value1
  23. # Create a new Python component with the source in a Git repository
  24. odo create python --git https://github.com/openshift/django-ex.git
  25. # Passing memory limits
  26. odo create nodejs --memory 150Mi
  27. odo create nodejs --min-memory 150Mi --max-memory 300 Mi
  28. # Passing cpu limits
  29. odo create nodejs --cpu 2
  30. odo create nodejs --min-cpu 200m --max-cpu 2

debug

Debug a component.

Example using debug

  1. # Displaying information about the state of debugging
  2. odo debug info
  3. # Starting the port forwarding for a component to debug the application
  4. odo debug port-forward
  5. # Setting a local port to port forward
  6. odo debug port-forward --local-port 9292

delete

Delete an existing component.

Example using delete

  1. # Delete component named 'frontend'.
  2. odo delete frontend
  3. odo delete frontend --all-apps

describe

Describe the given component.

Example using describe

  1. # Describe nodejs component
  2. odo describe nodejs

Link a component to a service or component.

Example using link

  1. # Link the current component to the 'my-postgresql' service
  2. odo link my-postgresql
  3. # Link component 'nodejs' to the 'my-postgresql' service
  4. odo link my-postgresql --component nodejs
  5. # Link current component to the 'backend' component (backend must have a single exposed port)
  6. odo link backend
  7. # Link component 'nodejs' to the 'backend' component
  8. odo link backend --component nodejs
  9. # Link current component to port 8080 of the 'backend' component (backend must have port 8080 exposed)
  10. odo link backend --port 8080

Link adds the appropriate secret to the environment of the source component. The source component can then consume the entries of the secret as environment variables. If the source component is not provided, the current active component is assumed.

list

List all the components in the current application and the states of the components.

The states of the components

Pushed

A component is pushed to the cluster.

Not Pushed

A component is not pushed to the cluster.

Unknown

odo is disconnected from the cluster.

Example using list

  1. # List all components in the application
  2. odo list
  3. # List all the components in a given path
  4. odo list --path <path_to_your_component>

log

Retrieve the log for the given component.

Example using log

  1. # Get the logs for the nodejs component
  2. odo log nodejs

login

Log in to the cluster.

Example using login

  1. # Log in interactively
  2. odo login
  3. # Log in to the given server with the given certificate authority file
  4. odo login localhost:8443 --certificate-authority=/path/to/cert.crt
  5. # Log in to the given server with the given credentials (basic auth)
  6. odo login localhost:8443 --username=myuser --password=mypass
  7. # Log in to the given server with the given credentials (token)
  8. odo login localhost:8443 --token=xxxxxxxxxxxxxxxxxxxxxxx

logout

Log out of the current OKD session.

Example using logout

  1. # Log out
  2. odo logout

preference

Modify odo specific configuration settings within the global preference file.

Example using preference

  1. # For viewing the current preferences
  2. odo preference view
  3. # Set a preference value in the global preference
  4. odo preference set UpdateNotification false
  5. odo preference set NamePrefix "app"
  6. odo preference set Timeout 20
  7. # Enable experimental mode
  8. odo preference set experimental true
  9. # Unset a preference value in the global preference
  10. odo preference unset UpdateNotification
  11. odo preference unset NamePrefix
  12. odo preference unset Timeout
  13. # Disable experimental mode
  14. odo preference set experimental false

By default, the path to the global preference file is ~/.odo/preferece.yaml and it is stored in the environment variable GLOBALODOCONFIG. You can set up a custom path by setting the value of the environment variable to a new preference path, for example GLOBALODOCONFIG=”new_path/preference.yaml”

Table 2. Available Parameters:

NamePrefix

The default prefix is the current directory name. Use this value to set a default name prefix.

Timeout

The timeout (in seconds) for OKD server connection checks.

UpdateNotification

Controls whether an update notification is shown.

project

Perform project operations.

Example using project

  1. # Set the active project
  2. odo project set
  3. # Create a new project
  4. odo project create myproject
  5. # List all the projects
  6. odo project list
  7. # Delete a project
  8. odo project delete myproject
  9. # Get the active project
  10. odo project get

push

Push source code to a component.

Example using push

  1. # Push source code to the current component
  2. odo push
  3. # Push data to the current component from the original source.
  4. odo push
  5. # Push source code in ~/mycode to component called my-component
  6. odo push my-component --context ~/mycode
  7. # Push source code and display event notifications in JSON format.
  8. odo push -o json

registry

Create and modify custom registries.

Example using registry

  1. # Add a registry to the registry list
  2. odo registry add <registry name> <registry URL>
  3. # List a registry in the registry list
  4. odo registry list
  5. # Delete a registry from the registry list
  6. odo registry delete <registry name>
  7. # Update a registry in the registry list
  8. odo registry update <registry name> <registry URL>
  9. # List a component with a corresponding registry
  10. odo catalog list components
  11. # Create a component that is hosted by a specific registry
  12. odo create <component type> --registry <registry name>

service

Perform service catalog operations.

Example using service

  1. # Create new postgresql service from service catalog using dev plan and name my-postgresql-db.
  2. odo service create dh-postgresql-apb my-postgresql-db --plan dev -p postgresql_user=luke -p postgresql_password=secret
  3. # Delete the service named 'mysql-persistent'
  4. odo service delete mysql-persistent
  5. # List all services in the application
  6. odo service list

storage

Perform storage operations.

Example using storage

  1. # Create storage of size 1Gb to a component
  2. odo storage create mystorage --path=/opt/app-root/src/storage/ --size=1Gi
  3. # Delete storage mystorage from the currently active component
  4. odo storage delete mystorage
  5. # List all storage attached or mounted to the current component and
  6. # all unattached or unmounted storage in the current application
  7. odo storage list
  8. # Set the `-o json` flag to get a JSON formatted output
  9. odo storage list -o json

Unlink component or a service.

For this command to be successful, the service or component must have been linked prior to the invocation using odo link.

Example using unlink

  1. # Unlink the 'my-postgresql' service from the current component
  2. odo unlink my-postgresql
  3. # Unlink the 'my-postgresql' service from the 'nodejs' component
  4. odo unlink my-postgresql --component nodejs
  5. # Unlink the 'backend' component from the current component (backend must have a single exposed port)
  6. odo unlink backend
  7. # Unlink the 'backend' service from the 'nodejs' component
  8. odo unlink backend --component nodejs
  9. # Unlink the backend's 8080 port from the current component
  10. odo unlink backend --port 8080

update

Update the source code path of a component

Example using update

  1. # Change the source code path of a currently active component to local (use the current directory as a source)
  2. odo update --local
  3. # Change the source code path of the frontend component to local with source in ./frontend directory
  4. odo update frontend --local ./frontend
  5. # Change the source code path of a currently active component to git
  6. odo update --git https://github.com/openshift/nodejs-ex.git
  7. # Change the source code path of the component named node-ex to git
  8. odo update node-ex --git https://github.com/openshift/nodejs-ex.git
  9. # Change the source code path of the component named wildfly to a binary named sample.war in ./downloads directory
  10. odo update wildfly --binary ./downloads/sample.war

url

Expose a component to the outside world.

Example using url

  1. # Create a URL for the current component with a specific port
  2. odo url create --port 8080
  3. # Create a URL with a specific name and port
  4. odo url create example --port 8080
  5. # Create a URL with a specific name by automatic detection of port (only for components which expose only one service port)
  6. odo url create example
  7. # Create a URL with a specific name and port for component frontend
  8. odo url create example --port 8080 --component frontend
  9. # Delete a URL to a component
  10. odo url delete myurl
  11. # List the available URLs
  12. odo url list
  13. # Create a URL in the configuration and apply the changes to the cluster
  14. odo url create --now
  15. # Create an HTTPS URL
  16. odo url create --secure

The URLs that are generated using this command can be used to access the deployed components from outside the cluster.

utils

Utilities for terminal commands and modifying odo configurations.

Example using utils

  1. # Bash terminal PS1 support
  2. source <(odo utils terminal bash)
  3. # Zsh terminal PS1 support
  4. source <(odo utils terminal zsh)

version

Print the client version information.

Example using version

  1. # Print the client version of odo
  2. odo version

watch

odo starts watching for changes and updates the component upon a change automatically.

Example using watch

  1. # Watch for changes in directory for current component
  2. odo watch
  3. # Watch for changes in directory for component called frontend
  4. odo watch frontend