1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/developer-cli-odo-deploying-a-java-application-using-a-devile.adoc

116 lines
3.0 KiB
Plaintext
Raw Normal View History

2020-06-24 14:13:59 +02:00
// Module included in the following assemblies:
//
// cli_reference/developer_cli_odo/creating-a-java-application-using-devfile
[id="deploying-a-java-application-using-a-devile_{context}"]
= Deploying a Java application using a devile
In this section, you will learn how to deploy a sample Java project that uses Maven and Java 8 JDK using a devfile.
.Procedure
. 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 --downloadSource
----
+
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
----
+
NOTE: 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
----