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/.

About the devfile in odo

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.

Creating a Java application by using a devfile


  • 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

Creating a project

Create a project to keep your source code, tests, and libraries organized in a separate single unit.

  1. Log in to an OpenShift Container Platform cluster:

    $ odo login -u developer -p developer
  2. Create a project:

    $ odo project create myproject
     ✓  Project 'myproject' is ready for use
     ✓  New project created and now using project : myproject

Listing available devfile components

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.

  1. To list available devfile components on your cluster, run:

    $ odo catalog list components was

    The output lists the available odo components:

    Odo OpenShift Components:
     NAME              PROJECT       TAGS                        SUPPORTED
     java              openshift     11,8,latest                 YES
     nodejs            openshift     10-SCL,8,8-RHOAR,latest     YES
     dotnet            openshift     2.1,2.2,3.0,latest          NO
     golang            openshift     1.11.5,latest               NO
     httpd             openshift     2.4,latest                  NO
     modern-webapp     openshift     10.x,latest                 NO
     nginx             openshift     1.10,1.12,latest            NO
     perl              openshift     5.24,5.26,latest            NO
     php               openshift     7.0,7.1,7.2,latest          NO
     python            openshift     2.7,3.6,latest              NO
     ruby              openshift     2.4,2.5,latest              NO
     Odo Devfile Components:
     NAME                 DESCRIPTION                           SUPPORTED
     maven                Upstream Maven and OpenJDK 11         YES
     nodejs               Stack with NodeJS 10                  YES
     openLiberty          Open Liberty microservice in Java     YES
     java-spring-boot     Spring Boot® using Java               YES

Deploying a Java application using a devfile

In this section, you will learn how to deploy a sample Java project that uses Maven and Java 8 JDK using a devfile.

  1. Create a directory to store the source code of your component:

     $ mkdir <directory-name>
  2. Create a component configuration of Spring Boot component type named myspring and download its sample project:

       $ odo create java-spring-boot myspring --downloadSource

    The previous command produces the following output:

       Experimental mode is enabled, use at your own risk
        ✓  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.

  3. 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
  4. 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.
  5. Push the component to the cluster:

      $ odo push

    The previous command produces the following output:

       ✓  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
  6. 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
  7. View your deployed application by using the generated URL:

      $ curl http://myspring-8080.apps-crc.testing