From 46ea6c3d0870ab3682f3a9d36be3304dba176048 Mon Sep 17 00:00:00 2001 From: John Collier Date: Wed, 27 May 2020 23:57:17 -0400 Subject: [PATCH] Update samples for deploying a devfile in deploying-a-devfile-using-odo.adoc (#3163) * Update devfile doc samples [skip ci] Signed-off-by: John Collier * Address review comments Signed-off-by: John Collier * Fix formatting Signed-off-by: John Collier --- .../public/deploying-a-devfile-using-odo.adoc | 192 +++++++++++++----- 1 file changed, 137 insertions(+), 55 deletions(-) diff --git a/docs/public/deploying-a-devfile-using-odo.adoc b/docs/public/deploying-a-devfile-using-odo.adoc index 3c9f0c693f0..ea8ed4de514 100644 --- a/docs/public/deploying-a-devfile-using-odo.adoc +++ b/docs/public/deploying-a-devfile-using-odo.adoc @@ -93,12 +93,13 @@ In our example, we will be using `java-spring-boot` to deploy a sample https://s 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. -. Download the example Spring Boot® component +. Download the example Spring Boot® component. + [source,sh] ---- $ git clone https://github.com/odo-devfiles/springboot-ex ---- +Alternatively, you can pass in `--downloadSource` to `odo create` to have odo download a sample project. . Change the current directory to the component directory: + @@ -107,14 +108,6 @@ In this example we will be deploying an https://github.com/odo-devfiles/springbo $ cd ---- -. List the contents of the directory to confirm that the front end is indeed a Java application: -+ -[source,sh] ----- - $ ls - chart Dockerfile Dockerfile-build Dockerfile-tools Jenkinsfile pom.xml README.md src ----- - . Create a component configuration using the `java-spring-boot` component-type named `myspring`: + [source,sh] @@ -123,10 +116,19 @@ In this example we will be deploying an https://github.com/odo-devfiles/springbo Experimental mode is enabled, use at your own risk Validation - ✓ Checking devfile compatibility [71105ns] - ✓ Validating devfile component [153481ns] + ✓ 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 +---- - Please use odo push command to create the component with source deployed +. List the contents of the directory to see the devfile and sample Java application source code: ++ +[source,sh] +---- + $ ls + README.md devfile.yaml pom.xml src ---- . Create a URL in order to access the deployed component: @@ -145,18 +147,27 @@ NOTE: You must use your cluster host domain name when creating your URL. + [source,sh] ---- - $ odo push - • Push devfile component myspring ... - ✓ Waiting for component to start [30s] + $ odo push + + 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] - Applying URL changes - ✓ URL myspring-8080: http://myspring-8080.apps-crc.testing created - ✓ Checking files for pushing [752719ns] - ✓ Syncing files to the component [887ms] - ✓ Executing devbuild command "/artifacts/bin/build-container-full.sh" [23s] - ✓ Executing devrun command "/artifacts/bin/start-server.sh" [2s] - ✓ Push devfile component myspring [57s] - ✓ Changes successfully pushed to component + Pushing devfile component myspring + ✓ Changes successfully pushed to component ---- . List the URLs of the component: @@ -176,6 +187,16 @@ NOTE: You must use your cluster host domain name when creating your URL. $ curl http://myspring-8080.apps-crc.testing ---- +. To delete your deployed application: ++ +[source,sh] +---- + $ odo delete + ? Are you sure you want to delete the devfile component: myspring? Yes + ✓ Deleting devfile component myspring [152ms] + ✓ Successfully deleted component +---- + == Deploying a Node.js® component to an OpenShift 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]. @@ -210,8 +231,9 @@ In this example we will be deploying an https://github.com/odo-devfiles/nodejs-e Experimental mode is enabled, use at your own risk Validation - ✓ Checking devfile compatibility [106956ns] - ✓ Validating devfile component [250318ns] + ✓ Checking devfile compatibility [111738ns] + ✓ Creating a devfile component from registry: DefaultDevfileRegistry [89567ns] + ✓ Validating devfile component [186982ns] Please use odo push command to create the component with source deployed ---- @@ -232,18 +254,27 @@ NOTE: You must use your cluster host domain name when creating your URL. + [source,sh] ---- - $ odo push - • Push devfile component mynodejs ... - ✓ Waiting for component to start [27s] + $ odo push + + Validation + ✓ Validating the devfile [89380ns] - Applying URL changes - ✓ URL mynodejs-3000: http://mynodejs-3000.apps-crc.testing created - ✓ Checking files for pushing [1ms] - ✓ Syncing files to the component [839ms] - ✓ Executing devbuild command "npm install" [3s] - ✓ Executing devrun command "nodemon app.js" [2s] - ✓ Push devfile component mynodejs [33s] - ✓ Changes successfully pushed to component + Creating Kubernetes resources for component mynodejs + ✓ Waiting for component to start [3s] + + Applying URL changes + ✓ URL mynodejs-3000: http://mynodejs-3000.apps-crc.testing created + + Syncing to component mynodejs + ✓ Checking files for pushing [2ms] + ✓ Syncing files to the component [1s] + + Executing devfile commands for component mynodejs + ✓ Executing devbuild command "npm install" [3s] + ✓ Executing devrun command "nodemon app.js" [2s] + + Pushing devfile component mynodejs + ✓ Changes successfully pushed to component ---- . List the URLs of the component: @@ -263,6 +294,16 @@ NOTE: You must use your cluster host domain name when creating your URL. $ curl http://mynodejs-8080.apps-crc.testing ---- +. To delete your deployed application: ++ +[source,sh] +---- + $ odo delete + ? Are you sure you want to delete the devfile component: mynodejs? Yes + ✓ Deleting devfile component mynodejs [139ms] + ✓ 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. @@ -278,18 +319,34 @@ In this example, we will be deploying the same Java Spring Boot® component we d ---- + +. Download the example Spring Boot® component. ++ +[source,sh] +---- + $ git clone https://github.com/odo-devfiles/springboot-ex +---- +Alternatively, you can pass in `--downloadSource` to `odo create` to have odo download a sample project. + +. Change the current directory to the component directory: ++ +[source,sh] +---- + $ cd +---- + . Create a component configuration using the `java-spring-boot` component-type named `mydockerspringboot`: + [source,sh] ---- - $ odo create java-spring-boot mydockerspringboot - Experimental mode is enabled, use at your own risk + $ odo create java-spring-boot mydockerspringboot + Experimental mode is enabled, use at your own risk - Validation - ✓ Checking devfile compatibility [26759ns] - ✓ Validating devfile component [75889ns] + 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 + Please use odo push command to create the component with source deployed ---- . Create a URL in order to access the deployed component: @@ -297,7 +354,7 @@ In this example, we will be deploying the same Java Spring Boot® component we d [source,sh] ---- $ odo url create --port 8080 - ✓ URL local-mydockerspringboot-8080 created for component: mydockerspringboot with exposed port: 37833 + ✓ URL java-spring-boot-8080 created for component: java-spring-boot with exposed port: 59382 To apply the URL configuration changes, please use odo push ---- @@ -309,18 +366,26 @@ In order to access the docker application, exposed ports are required and automa [source,sh] ---- $ odo push - • Push devfile component mydockerspringboot ... - ✓ Pulling image maysunfaisal/springbootbuild [601ms] - - Applying URL configuration - ✓ URL 127.0.0.1:37833 created - ✓ Starting container for maysunfaisal/springbootbuild [550ms] - ✓ Pulling image maysunfaisal/springbootruntime [581ms] - - Applying URL configuration - ✓ URL 127.0.0.1:37833 created - ✓ Starting container for maysunfaisal/springbootruntime [505ms] - ✓ Push devfile component mydockerspringboot [2s] + + Validation + ✓ Validating the devfile [52685ns] + + 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] + + Syncing to component java-spring-boot + ✓ Checking files for pushing [2ms] + ✓ Syncing files to the component [231ms] + + 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] + + Pushing devfile component java-spring-boot ✓ Changes successfully pushed to component ---- + @@ -329,3 +394,20 @@ When odo deploys a devfile component, it pulls the images for each `dockercontai 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: ++ +[source,sh] +---- + $ curl http://127.0.0.1:59382 +---- + +. 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 +---- \ No newline at end of file