$ odo login -u developer -p developer
Creating applications by using devfiles with `odo` is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process. For more information about the support scope of Red Hat Technology Preview features, see https://access.redhat.com/support/offerings/techpreview/. |
The devfile is a portable file that describes your development environment. With the devfile, you can define a portable developmental environment without the need for reconfiguration.
With the devfile, you can describe your development environment, such as the source code, IDE tools, application runtimes, and predefined commands. To learn more about the devfile, see the devfile documentation.
With odo
, you can create components from the devfiles. When creating a component by using a devfile, odo
transforms the devfile into a workspace consisting of multiple containers that run on OpenShift Container Platform, Kubernetes, or Docker.
odo
automatically uses the default devfile registry but users can add their own registries.
You have installed odo
.
You must know your ingress domain cluster name. Contact your cluster administrator if you do not know it. For example, apps-crc.testing
is the cluster domain name for Red Hat CodeReady Containers.
You have enabled Experimental Mode in odo
.
To enable Experimental Mode in odo
preferences, run odo preference set Experimental true
or use the environment variable odo config set --env ODO_EXPERIMENTAL=true
Create a project to keep your source code, tests, and libraries organized in a separate single unit.
Log in to an OpenShift Container Platform cluster:
$ odo login -u developer -p developer
Create a project:
$ odo project create myproject
✓ Project 'myproject' is ready for use
✓ New project created and now using project : myproject
With odo
, you can display all the components that are available for you on the cluster. Components that are available depend on the configuration of your cluster.
To list available devfile components on your cluster, run:
$ odo catalog list components
The output lists the available odo
components:
Odo Devfile Components:
NAME DESCRIPTION REGISTRY
java-maven Upstream Maven and OpenJDK 11 DefaultDevfileRegistry
java-openliberty Open Liberty microservice in Java DefaultDevfileRegistry
java-quarkus Upstream Quarkus with Java+GraalVM DefaultDevfileRegistry
java-springboot Spring Boot® using Java DefaultDevfileRegistry
nodejs Stack with NodeJS 12 DefaultDevfileRegistry
Odo OpenShift Components:
NAME PROJECT TAGS SUPPORTED
java openshift 11,8,latest YES
dotnet openshift 2.1,3.1,latest NO
golang openshift 1.13.4-ubi7,1.13.4-ubi8,latest NO
httpd openshift 2.4-el7,2.4-el8,latest NO
nginx openshift 1.14-el7,1.14-el8,1.16-el7,1.16-el8,latest NO
nodejs openshift 10-ubi7,10-ubi8,12-ubi7,12-ubi8,latest NO
perl openshift 5.26-el7,5.26-ubi8,5.30-el7,latest NO
php openshift 7.2-ubi7,7.2-ubi8,7.3-ubi7,7.3-ubi8,latest NO
python openshift 2.7-ubi7,2.7-ubi8,3.6-ubi7,3.6-ubi8,3.8-ubi7,3.8-ubi8,latest NO
ruby openshift 2.5-ubi7,2.5-ubi8,2.6-ubi7,2.6-ubi8,2.7-ubi7,latest NO
wildfly openshift 10.0,10.1,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,8.1,9.0,latest NO
In this section, you will learn how to deploy a sample Java project that uses Maven and Java 8 JDK using a devfile.
Create a directory to store the source code of your component:
$ mkdir <directory-name>
Create a component configuration of Spring Boot component type named myspring
and download its sample project:
$ odo create java-spring-boot myspring --starter
The previous command produces the following output:
Experimental mode is enabled, use at your own risk
Validation
✓ Checking devfile compatibility [195728ns]
✓ Creating a devfile component from registry: DefaultDevfileRegistry [170275ns]
✓ Validating devfile component [281940ns]
Please use `odo push` command to create the component with source deployed
The odo create
command downloads the associated devfile.yaml
file from the recorded devfile registries.
List the contents of the directory to confirm that the devfile and the sample Java application were downloaded:
$ ls
The previous command produces the following output:
README.md devfile.yaml pom.xml src
Create a URL to access the deployed component:
$ odo url create --host apps-crc.testing
The previous command produces the following output:
✓ URL myspring-8080.apps-crc.testing created for component: myspring
To apply the URL configuration changes, please use odo push
You must use your cluster host domain name when creating the URL. |
Push the component to the cluster:
$ odo push
The previous command produces the following output:
Validation
✓ Validating the devfile [81808ns]
Creating Kubernetes resources for component myspring
✓ Waiting for component to start [5s]
Applying URL changes
✓ URL myspring-8080: http://myspring-8080.apps-crc.testing created
Syncing to component myspring
✓ Checking files for pushing [2ms]
✓ Syncing files to the component [1s]
Executing devfile commands for component myspring
✓ Executing devbuild command "/artifacts/bin/build-container-full.sh" [1m]
✓ Executing devrun command "/artifacts/bin/start-server.sh" [2s]
Pushing devfile component myspring
✓ Changes successfully pushed to component
List the URLs of the component to verify that the component was pushed successfully:
$ odo url list
The previous command produces the following output:
Found the following URLs for component myspring
NAME URL PORT SECURE
myspring-8080 http://myspring-8080.apps-crc.testing 8080 false
View your deployed application by using the generated URL:
$ curl http://myspring-8080.apps-crc.testing
With odo
, you can create both Source-to-Image (s2i) and devfile components. If you have an existing s2i component, you can convert it into a devfile component using the odo utils
command.
Run all the commands from the s2i component directory.
Run the odo utils convert-to-devfile
command, which creates devfile.yaml
and env.yaml
based on your component:
$ odo utils convert-to-devfile
Push the component to your cluster:
$ odo push
If the devfile component deployment failed, delete it by running: |
Verify that the devfile component deployed successfully:
$ odo list
Delete the s2i component:
$ odo delete --s2i