Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Devfile doc for Kubernetes and add quarkus doc #3483

Merged
merged 8 commits into from
Jul 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 65 additions & 82 deletions docs/public/deploying-a-devfile-using-odo.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ With a devfile you can describe:

Odo takes this devfile and transforms it into a workspace of multiple containers running on OpenShift, Kubernetes or Docker.

Devfiles are YAML files with a defined https://github.com/redhat-developer/devfile/blob/master/docs/devfile.md[schema].
Devfiles are YAML files with a defined https://devfile.github.io/devfile/_attachments/api-reference.html[schema].

== Odo and devfile

Odo can now create components from devfiles as recorded in registries. Odo automatically consults the default https://github.com/elsony/devfile-registry[devfile] https://github.com/eclipse/che-devfile-registry/[registries] but users can also add their own registries. Devfiles contribute new component types that users can pull to begin development immediately.
Odo can now create components from devfiles as recorded in registries. Odo automatically consults the https://github.com/odo-devfiles/registry[default registry] but users can also add their own registries. Devfiles contribute new component types that users can pull to begin development immediately.

An example deployment scenario:

Expand All @@ -31,17 +31,14 @@ An example deployment scenario:
== Deploying your first devfile

[discrete]
===== Prerequisites

* Before proceeding, you must know your ingress domain cluster name. For example: `apps-crc.testing` is the cluster domain name for https://github.com/code-ready/crc[Red Hat CodeReady Containers]
* Enable experimental mode for odo. This can be done by: `odo preference set experimental true`
==== Prerequisites for an OpenShift Cluster

== Creating a project
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, do NOT remove this section. We must have a section for creating a project in each .adoc / markdown file that corresponds to a tutorial.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simply remove / copy and paste this section after the Prerequisites for OpenShift cluster parts.

* Enable experimental mode for odo. This can be done by: `odo preference set experimental true`

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

. Log in to a OpenShift cluster:
. Log in to an OpenShift cluster:
+
[source,sh]
----
Expand All @@ -56,7 +53,17 @@ organized in a separate single unit.
✓ Project 'myproject' is ready for use
✓ New project created and now using project : myproject
----


==== Prerequisites for a Kubernetes Cluster

* Enable experimental mode for odo. This can be done by: `odo preference set experimental true`

* Before proceeding, you must know your ingress domain name or ingress IP to specify `--host` for `odo url create`.
+
Ingress IP is usually the external IP of ingress controller service, for Minikube or CRC clusters running in a virtual machine you can get it by
`minikube ip` or `crc ip`. Checkout this https://kubernetes.io/docs/concepts/services-networking/ingress/[document] to know more about ingress.


== Listing all available devfile components

Expand All @@ -80,16 +87,18 @@ organized in a separate single unit.
ruby openshift 2.4,2.5,latest NO

Odo Devfile Components:
NAME DESCRIPTION SUPPORTED
java-maven Upstream Maven and OpenJDK 11 YES
nodejs Stack with NodeJS 10 YES
java-openliberty Open Liberty microservice in Java YES
java-springboot Spring Boot® using Java YES
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

----

In our example, we will be using `java-spring-boot` to deploy a sample https://spring.io/projects/spring-boot[Springboot] component.

== Deploying a Java Spring Boot® component to an OpenShift cluster
== Deploying a Java Spring Boot® component to an OpenShift / Kubernetes cluster

In this example we will be deploying an https://github.com/odo-devfiles/springboot-ex[example Spring Boot® component] that uses https://maven.apache.org/install.html[Maven] and Java 8 JDK.

Expand Down Expand Up @@ -135,13 +144,13 @@ Alternatively, you can pass in `--starter` to `odo create` to have odo download
+
[source,sh]
----
$ odo url create --host apps-crc.testing
$ odo url create
✓ 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 your URL.
NOTE: If deploying on Kubernetes, you need to pass ingress domain name via `--host` flag.

. Push the component to the cluster:
+
Expand Down Expand Up @@ -197,7 +206,7 @@ NOTE: You must use your cluster host domain name when creating your URL.
✓ Successfully deleted component
----

== Deploying a Node.js® component to an OpenShift cluster
== Deploying a Node.js® component to an OpenShift / Kubernetes cluster

In this example we will be deploying an https://github.com/odo-devfiles/nodejs-ex[example Node.js® component] that uses https://www.npmjs.com/[NPM].

Expand Down Expand Up @@ -242,13 +251,13 @@ In this example we will be deploying an https://github.com/odo-devfiles/nodejs-e
+
[source,sh]
----
$ odo url create --host apps-crc.testing
$ odo url create
✓ URL mynodejs-8080.apps-crc.testing created for component: mynodejs

To apply the URL configuration changes, please use odo push
----
+
NOTE: You must use your cluster host domain name when creating your URL.
NOTE: If deploying on Kubernetes, you need to pass ingress domain name via `--host` flag.

. Push the component to the cluster:
+
Expand Down Expand Up @@ -304,41 +313,22 @@ NOTE: You must use your cluster host domain name when creating your URL.
✓ Successfully deleted component
----

== Deploying a Java Spring Boot® component locally to Docker

In this example, we will be deploying the same Java Spring Boot® component we did earlier, but to a locally running Docker instance.

*Prerequisites:* Docker `17.05` or higher installed

. Enabling a separate push target, using the `pushtarget` preference:
+
[source,sh]
----
$ odo preference set pushtarget docker
Global preference was successfully updated
----
+
== Deploying a Quarkus Application to an OpenShift / Kubernetes cluster

. Download the example Spring Boot® component.
+
[source,sh]
----
$ git clone https://github.com/odo-devfiles/springboot-ex
----
Alternatively, you can pass in `--starter` to `odo create` to have odo download a project specified in the devfile.
In this example we will be deploying a https://github.com/odo-devfiles/quarkus-ex[Quarkus component] that uses GraalVM and JDK1.8+.

. Change the current directory to the component directory:
. Download the example Quarkus component
+
[source,sh]
----
$ cd <directory-name>
$ git clone https://github.com/odo-devfiles/quarkus-ex && cd quarkus-ex
----

. Create a component configuration using the `java-spring-boot` component-type named `mydockerspringboot`:
. Create a Quarkus odo component
+
[source,sh]
----
$ odo create java-spring-boot mydockerspringboot
$ odo create java-quarkus myquarkus
Experimental mode is enabled, use at your own risk

Validation
Expand All @@ -353,61 +343,54 @@ Alternatively, you can pass in `--starter` to `odo create` to have odo download
+
[source,sh]
----
$ odo url create --port 8080
✓ URL java-spring-boot-8080 created for component: java-spring-boot with exposed port: 59382
$ odo url create
✓ URL myquarkus-8080.apps-crc.testing created for component: myquarkus

To apply the URL configuration changes, please use odo push
----
+
In order to access the docker application, exposed ports are required and automatically generated by odo.
NOTE: If deploying on Kubernetes, you need to pass ingress domain name via `--host` flag.

. Deploy the Spring Boot® devfile component to Docker:
. Push the component to the cluster:
+
[source,sh]
----
$ odo push

Validation
✓ Validating the devfile [52685ns]
Validation
✓ Validating the devfile [44008ns]

Creating Docker resources for component java-spring-boot
✓ Pulling image maysunfaisal/springbootbuild [879ms]
✓ Starting container for maysunfaisal/springbootbuild [397ms]
✓ Pulling image maysunfaisal/springbootruntime [1s]
✓ URL 127.0.0.1:59382 created
✓ Starting container for maysunfaisal/springbootruntime [380ms]
Creating Kubernetes resources for component myquarkus
✓ Waiting for component to start [10s]

Syncing to component java-spring-boot
✓ Checking files for pushing [2ms]
✓ Syncing files to the component [231ms]
Applying URL changes
✓ URLs are synced with the cluster, no changes are required.

Executing devfile commands for component java-spring-boot
✓ Executing devbuild command "/artifacts/bin/build-container-full.sh" [1m]
✓ Executing devrun command "/artifacts/bin/start-server.sh" [1s]
Syncing to component myquarkus
✓ Checking files for pushing [951138ns]
✓ Syncing files to the component [204ms]

Executing devfile commands for component myquarkus
✓ Executing init-compile command "mvn compile" [3m]
✓ Executing dev-run command "mvn quarkus:dev" [1s]

Pushing devfile component myquarkus
✓ Changes successfully pushed to component

Pushing devfile component java-spring-boot
✓ Changes successfully pushed to component
----
+
When odo deploys a devfile component, it pulls the images for each `dockercontainer` in `devfile.yaml` and deploys them.
+
Each docker container that is deployed is labeled with the name of the odo component.
+
Docker volumes are created for the project source, and any other volumes defined in the devfile and mounted to the necessary containers.

. View your deployed application using the generated URL:
. View your deployed application in a browser using the generated url
+
[source,sh]
----
$ curl http://127.0.0.1:59382
$ odo url list
Found the following URLs for component myspring
NAME URL PORT SECURE
myquarkus-8080 http://myquarkus-8080.apps-crc.testing 8080 false
----

. To delete your deployed application:
+
[source,sh]
----
$ odo delete
? Are you sure you want to delete the devfile component: java-spring-boot? Yes
✓ Deleting devfile component java-spring-boot [139ms]
✓ Successfully deleted component
----
You can now continue developing your application. Just run `odo push` and refresh your browser to view the latest changes.

You can also run `odo watch` to watch changes in the source code. Just refreshing the browser will render the source code changes.

Run `odo delete` to delete the application from cluster.