From 1e14a5f9a7ba0b34a5e82c2fef4e736e560aa44a Mon Sep 17 00:00:00 2001 From: John Collier Date: Tue, 12 May 2020 18:27:24 -0400 Subject: [PATCH 1/3] Update devfile doc samples [skip ci] Signed-off-by: John Collier --- .../public/deploying-a-devfile-using-odo.adoc | 191 ++++++++++++------ 1 file changed, 126 insertions(+), 65 deletions(-) diff --git a/docs/public/deploying-a-devfile-using-odo.adoc b/docs/public/deploying-a-devfile-using-odo.adoc index 9fe83221c64..cb2e0db9dfe 100644 --- a/docs/public/deploying-a-devfile-using-odo.adoc +++ b/docs/public/deploying-a-devfile-using-odo.adoc @@ -28,6 +28,8 @@ An example deployment scenario: .. Synchronizes your source code to the containers .. Executes any prerequisite commands +*Note that odo's devfile support is currently in preview, and requires enabling experimental mode* + == Deploying your first devfile [discrete] @@ -91,42 +93,36 @@ In our example, we will be using `java-spring-boot` to deploy a sample https://s == Deploying a Java Spring Boot® component to an OpenShift cluster -In this example we will be deploying an https://github.com/odo-devfiles/springboot-ex[example Springboot component] that uses https://maven.apache.org/install.html[Maven] and Java 8 JDK. +In this example we will be deploying a sample project associated with the java-spring-boot devfile that uses https://maven.apache.org/install.html[Maven] and Java 8 JDK. -. Download the example Spring Boot® component +. Create a directory to store the source code for the component: + [source,sh] ---- - $ git clone https://github.com/odo-devfiles/springboot-ex + $ mkdir ---- -. Change the current directory to the component directory: +. Create a component configuration of Spring Boot component-type named myspring and download its sample project: + [source,sh] ---- - $ cd ----- + $ odo create java-spring-boot myspring --downloadSource + Experimental mode is enabled, use at your own risk -. List the contents of the directory to see that the front end is a Java application: -+ -[source,sh] ----- - $ ls - chart Dockerfile Dockerfile-build Dockerfile-tools Jenkinsfile pom.xml README.md src + 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 ---- -. Create a component configuration of Spring Boot component-type named myspring: +. List the contents of the directory to see that the devfile and sample Java application was downloaded: + [source,sh] ---- - $ odo create java-spring-boot myspring - Experimental mode is enabled, use at your own risk - - Validation - ✓ Checking devfile compatibility [71105ns] - ✓ Validating devfile component [153481ns] - - Please use odo push command to create the component with source deployed + $ ls + README.md devfile.yaml pom.xml src ---- . Create a URL in order to access the deployed component: @@ -145,18 +141,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 +181,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,10 +225,11 @@ 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 + Please use `odo push` command to create the component with source deployed ---- . Create a URL in order to access the deployed component: @@ -232,18 +248,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 - 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 + Validation + ✓ Validating the devfile [89380ns] + + 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 +288,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. @@ -279,18 +314,19 @@ In this example, we will be deploying the same Java Spring Boot® component we d + You can configure a separate push target by making use of the `pushtarget` preference. -. Create a component configuration of Spring Boot component-type named mydockerspringboot: +. Create a component configuration of Spring Boot component-type named mydockerspringboot and download its sample project: + [source,sh] ---- - $ odo create java-spring-boot mydockerspringboot + $ odo create java-spring-boot --downloadSource Experimental mode is enabled, use at your own risk Validation - ✓ Checking devfile compatibility [26759ns] - ✓ Validating devfile component [75889ns] + ✓ Checking devfile compatibility [147789ns] + ✓ Creating a devfile component from registry: DefaultDevfileRegistry [133953ns] + ✓ Validating devfile component [188543ns] - 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: @@ -298,9 +334,9 @@ You can configure a separate push target by making use of the `pushtarget` prefe [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 + 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. @@ -310,18 +346,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 ---- + @@ -330,3 +374,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 From c083bfbe6e692660edbd6d8961bd3cb167c95027 Mon Sep 17 00:00:00 2001 From: John Collier Date: Fri, 15 May 2020 11:06:46 -0400 Subject: [PATCH 2/3] Address review comments Signed-off-by: John Collier --- .../public/deploying-a-devfile-using-odo.adoc | 61 +++++++++++++------ 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/docs/public/deploying-a-devfile-using-odo.adoc b/docs/public/deploying-a-devfile-using-odo.adoc index a7bb91469f1..8b44ec983f8 100644 --- a/docs/public/deploying-a-devfile-using-odo.adoc +++ b/docs/public/deploying-a-devfile-using-odo.adoc @@ -28,8 +28,6 @@ An example deployment scenario: .. Synchronizes your source code to the containers .. Executes any prerequisite commands -*Note that odo's devfile support is currently in preview, and requires enabling experimental mode* - == Deploying your first devfile [discrete] @@ -93,20 +91,29 @@ In our example, we will be using `java-spring-boot` to deploy a sample https://s == Deploying a Java Spring Boot® component to an OpenShift cluster -In this example we will be deploying a sample project associated with the java-spring-boot devfile that uses https://maven.apache.org/install.html[Maven] and Java 8 JDK. +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. -. Create a directory to store the source code for the component: +. Download the example Spring Boot® component. + [source,sh] ---- - $ mkdir + $ git clone https://github.com/odo-devfiles/springboot-ex ---- -. Create a component configuration of Spring Boot component-type named myspring and download its sample project: +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] ---- - $ odo create java-spring-boot myspring --downloadSource + $ cd +---- + +. Create a component configuration using the `java-spring-boot` component-type named `myspring`: ++ +[source,sh] +---- + $ odo create java-spring-boot myspring Experimental mode is enabled, use at your own risk Validation @@ -114,10 +121,10 @@ In this example we will be deploying a sample project associated with the java-s ✓ 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 that the devfile and sample Java application was downloaded: +. List the contents of the directory to see the devfile and sample Java application source code: + [source,sh] ---- @@ -229,7 +236,7 @@ In this example we will be deploying an https://github.com/odo-devfiles/nodejs-e ✓ Creating a devfile component from registry: DefaultDevfileRegistry [89567ns] ✓ Validating devfile component [186982ns] - 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: @@ -313,19 +320,35 @@ In this example, we will be deploying the same Java Spring Boot® component we d ---- + -. Create a component configuration using the `java-spring-boot` component-type named `mydockerspringboot` and download its sample project: +. Download the example Spring Boot® component. + [source,sh] ---- - $ odo create java-spring-boot --downloadSource - Experimental mode is enabled, use at your own risk + $ git clone https://github.com/odo-devfiles/springboot-ex +---- - Validation - ✓ Checking devfile compatibility [147789ns] - ✓ Creating a devfile component from registry: DefaultDevfileRegistry [133953ns] - ✓ Validating devfile component [188543ns] +Alternatively, you can pass in `--downloadSource` to `odo create` to have odo download a sample project. - Please use `odo push` command to create the component with source deployed +. 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 + + 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 ---- . Create a URL in order to access the deployed component: @@ -335,7 +358,7 @@ In this example, we will be deploying the same Java Spring Boot® component we d $ odo url create --port 8080 ✓ 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` + 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. From 06857707ca9285701f7131ce611e6bcbaf21c733 Mon Sep 17 00:00:00 2001 From: John Collier Date: Fri, 15 May 2020 11:11:46 -0400 Subject: [PATCH 3/3] Fix formatting Signed-off-by: John Collier --- docs/public/deploying-a-devfile-using-odo.adoc | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/public/deploying-a-devfile-using-odo.adoc b/docs/public/deploying-a-devfile-using-odo.adoc index 8b44ec983f8..ea8ed4de514 100644 --- a/docs/public/deploying-a-devfile-using-odo.adoc +++ b/docs/public/deploying-a-devfile-using-odo.adoc @@ -99,7 +99,6 @@ In this example we will be deploying an https://github.com/odo-devfiles/springbo ---- $ 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: @@ -326,7 +325,6 @@ In this example, we will be deploying the same Java Spring Boot® component we d ---- $ 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: