diff --git a/_topic_map.yml b/_topic_map.yml index 78f224e75450..98f318cc7d18 100644 --- a/_topic_map.yml +++ b/_topic_map.yml @@ -530,6 +530,8 @@ Topics: File: pushing-the-odo-init-image-to-the-restricted-cluster-registry - Name: Creating and deploying a component to the disconnected cluster File: creating-and-deploying-a-component-to-the-disconnected-cluster + - Name: Creating and deploying devfile components to the disconnected cluster + File: creating-and-deploying-devfile-components-to-the-disconnected-cluster - Name: Creating instances of services managed by Operators File: creating-instances-of-services-managed-by-operators - Name: Managing environment variables in odo diff --git a/cli_reference/developer_cli_odo/using_odo_in_a_restricted_environment/creating-and-deploying-devfile-components-to-the-disconnected-cluster.adoc b/cli_reference/developer_cli_odo/using_odo_in_a_restricted_environment/creating-and-deploying-devfile-components-to-the-disconnected-cluster.adoc new file mode 100644 index 000000000000..d6067515b5a8 --- /dev/null +++ b/cli_reference/developer_cli_odo/using_odo_in_a_restricted_environment/creating-and-deploying-devfile-components-to-the-disconnected-cluster.adoc @@ -0,0 +1,11 @@ +[id="creating-and-deploying-devfile-components-to-the-disconnected-cluster"] += Creating and deploying devfile components to the disconnected cluster +include::modules/developer-cli-odo-attributes.adoc[] +include::modules/common-attributes.adoc[] +:context: creating-and-deploying-a-component-to-the-disconnected-cluster + +toc::[] + +include::modules/developer-cli-odo-creating-a-nodejs-application-by-using-a-devfile-in-a-disconnected-cluster.adoc[leveloffset=+1] + +include::modules/developer-cli-odo-creating-a-java-application-by-using-a-devfile-in-a-disconnected-cluster.adoc[leveloffset=+1] diff --git a/modules/developer-cli-odo-creating-a-java-application-by-using-a-devfile-in-a-disconnected-cluster.adoc b/modules/developer-cli-odo-creating-a-java-application-by-using-a-devfile-in-a-disconnected-cluster.adoc new file mode 100644 index 000000000000..519d23066dbd --- /dev/null +++ b/modules/developer-cli-odo-creating-a-java-application-by-using-a-devfile-in-a-disconnected-cluster.adoc @@ -0,0 +1,193 @@ +// Module included in the following assemblies: +// +// * cli_reference/developer_cli_odo/ + +[id="developer-cli-odo-creating-a-java-application-by-using-a-devfile-in-a-disconnected-cluster_{context}"] + += Creating a Java application by using a devfile in a disconnected cluster + +[WARNING] +==== +This procedure is using external dependencies such as `quay.io/eclipse/che-java11-maven:nightly` or an example application `springboot-ex` that are not maintained by Red Hat. These dependencies are not maintained with the documentation and their functionality cannot be guaranteed. +==== + +.Prerequisites +* You have created and logged into a disconnected cluster. +* You have added `quay.io`, `registry.access.redhat.com`, `apache.org`, `quayio-production-s3.s3.amazonaws.com` URLs in your proxy configuration. + +.Procedure + +. Define your Java application in a devfile: ++ +.Example of a devfile +[source,yaml] +---- +schemaVersion: 2.0.0 +metadata: + name: java-maven + version: 1.1.0 +starterProjects: + - name: springbootproject + git: + remotes: + origin: "https://github.com/odo-devfiles/springboot-ex.git" +components: + - name: tools + container: + image: quay.io/eclipse/che-java11-maven:nightly + memoryLimit: 512Mi + mountSources: true + endpoints: + - name: 'http-8080' + targetPort: 8080 + volumeMounts: + - name: m2 + path: /home/user/.m2 + - name: m2 + volume: {} +commands: + - id: mvn-package + exec: + component: tools + commandLine: "mvn -Dmaven.repo.local=/home/user/.m2/repository -Dhttp.proxyHost= -Dhttp.proxyPort= -Dhttps.proxyHost= -Dhttps.proxyPort= package" + group: + kind: build + isDefault: true + - id: run + exec: + component: tools + commandLine: "java -jar target/*.jar" + group: + kind: run + isDefault: true + - id: debug + exec: + component: tools + commandLine: "java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=${DEBUG_PORT},suspend=n -jar target/*.jar" + group: + kind: debug + isDefault: true +---- + +. Create a Java application: ++ +[source,terminal] +---- +$ odo create java-maven --devfile --starter +---- ++ +.Example output +[source,terminal] +---- +Validation + ✓ Checking devfile existence [87716ns] + ✓ Creating a devfile component from registry: DefaultDevfileRegistry [107247ns] + ✓ Validating devfile component [396971ns] + + Starter Project + ✓ Downloading starter project springbootproject from https://github.com/odo-devfiles/springboot-ex.git [2s] + +Please use `odo push` command to create the component with source deployed +---- + +. Push the changes to the cluster: ++ +[source,terminal] +---- +$ odo push +---- ++ +.Example output +[source,terminal] +---- +I0224 14:43:18.802512 34741 util.go:727] HTTPGetRequest: https://raw.githubusercontent.com/openshift/odo/master/build/VERSION +I0224 14:43:18.833631 34741 context.go:115] absolute devfile path: '/Users/pkumari/go/src/github.com/openshift/odo/testim/devfile.yaml' +[...] +Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar (262 kB at 813 kB/s) +[INFO] Replacing main artifact with repackaged archive +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 19.638 s +[INFO] Finished at: 2021-02-24T08:59:30Z +[INFO] ------------------------------------------------------------------------ + ✓ Executing mvn-package command "mvn -Dmaven.repo.local=/home/user/.m2/repository -Dhttp.proxyHost= -Dhttp.proxyPort= -Dhttps.proxyHost= -Dhttps.proxyPort= package" [23s] + • Executing run command "java -jar target/*.jar" ... +I0224 14:29:30.557676 34426 exec.go:27] Executing command [/opt/odo/bin/supervisord ctl start devrun] for pod: java-maven-5b8f99fcdb-9dnk6 in container: tools +devrun: started + ✓ Executing run command "java -jar target/*.jar" [3s] + +Pushing devfile component java-maven + ✓ Changes successfully pushed to component +---- + +. Display the logs to verify that the application has started: ++ +[source,terminal] +---- +$ odo log +---- ++ +.Example output +[source,terminal] +---- +time="2021-02-24T08:58:58Z" level=info msg="create process:devrun" +time="2021-02-24T08:58:58Z" level=info msg="create process:debugrun" +time="2021-02-24T08:59:32Z" level=debug msg="no auth required" +time="2021-02-24T08:59:32Z" level=debug msg="succeed to find process:devrun" +time="2021-02-24T08:59:32Z" level=info msg="try to start program" program=devrun +time="2021-02-24T08:59:32Z" level=info msg="success to start program" program=devrun +ODO_COMMAND_RUN is java -jar target/*.jar +Executing command java -jar target/*.jar +[...] +---- + +. Create storage for your application: ++ +[source,terminal] +---- +$ odo storage create storage-name --path /data --size 5Gi +---- ++ +.Example output +[source,terminal] +---- +✓ Added storage storage-name to java-maven + +Please use `odo push` command to make the storage accessible to the component +---- + +. Push the changes to the cluster: ++ +[source,terminal] +---- +$ odo push +---- ++ +.Output +[source,terminal] +---- +✓ Waiting for component to start [310ms] + +Validation + ✓ Validating the devfile [100798ns] + +Creating Kubernetes resources for component java-maven + ✓ Waiting for component to start [30s] + ✓ Waiting for component to start [303ms] + +Applying URL changes + ✓ URLs are synced with the cluster, no changes are required. + +Syncing to component java-maven + ✓ Checking file changes for pushing [5ms] + ✓ Syncing files to the component [4s] + +Executing devfile commands for component java-maven + ✓ Waiting for component to start [526ms] + ✓ Executing mvn-package command "mvn -Dmaven.repo.local=/home/user/.m2/repository -Dhttp.proxyHost= -Dhttp.proxyPort= -Dhttps.proxyHost= -Dhttps.proxyPort= package" [10s] + ✓ Executing run command "java -jar target/*.jar" [3s] + +Pushing devfile component java-maven + ✓ Changes successfully pushed to component +---- diff --git a/modules/developer-cli-odo-creating-a-nodejs-application-by-using-a-devfile-in-a-disconnected-cluster.adoc b/modules/developer-cli-odo-creating-a-nodejs-application-by-using-a-devfile-in-a-disconnected-cluster.adoc new file mode 100644 index 000000000000..5faa4059c7f2 --- /dev/null +++ b/modules/developer-cli-odo-creating-a-nodejs-application-by-using-a-devfile-in-a-disconnected-cluster.adoc @@ -0,0 +1,146 @@ +// Module included in the following assemblies: +// +// * cli_reference/developer_cli_odo/ + +[id="developer-cli-odo-creating-a-nodejs-application-by-using-a-devfile-in-a-disconnected-cluster_{context}"] + += Creating a NodeJS application by using a devfile in a disconnected cluster + +[WARNING] +==== +This procedure is using external dependencies such as `nodejs-ex.git` application that are not maintained by Red Hat. These dependencies are not maintained with the documentation and their functionality cannot be guaranteed. +==== + +.Prerequisites +* You have created and logged into a disconnected cluster. +* You have added `raw.githubusercontent.com`, `registry.access.redhat.com`, and `registry.npmjs.org` URLs in your proxy. + +.Procedure + +. Define your NodeJS application in a devfile: ++ +.Example of a devfile +[source,yaml] +---- +schemaVersion: 2.0.0 +metadata: +name: nodejs +starterProjects: +- name: nodejs-starter + git: + remotes: + origin: "https://github.com/odo-devfiles/nodejs-ex.git" +components: +- name: runtime + container: + image: registry.access.redhat.com/ubi8/nodejs-12:1-36 + memoryLimit: 1024Mi + endpoints: + - name: "3000/tcp" + targetPort: 3000 + env: + - name: HTTP_PROXY + value: http://: + - name: HTTPS_PROXY + value: http://: + mountSources: true +commands: +- id: devbuild + exec: + component: runtime + commandLine: npm install + workingDir: ${PROJECTS_ROOT} + group: + kind: build + isDefault: true +- id: build + exec: + component: runtime + commandLine: npm install + workingDir: ${PROJECTS_ROOT} + group: + kind: build +- id: devrun + exec: + component: runtime + commandLine: npm start + workingDir: ${PROJECTS_ROOT} + group: + kind: run + isDefault: true +- id: run + exec: + component: runtime + commandLine: npm start + workingDir: ${PROJECTS_ROOT} + group: + kind: run +---- + +. Create the application and push the changes to the cluster: ++ +[source,terminal] +---- +$ odo create nodejs --devfile --starter $$ odo push +---- ++ +.Example output +[source,terminal] +---- +[...] +Pushing devfile component nodejs + ✓ Changes successfully pushed to component +---- + +. Create a URL to access your application and push it to th cluster: ++ +[source,terminal] +---- +$ odo url create url1 --port 3000 --host example.com --ingress && odo push +---- ++ +.Example output +[source,terminal] +---- +Validation + ✓ Validating the devfile [145374ns] + +Creating Kubernetes resources for component nodejs + ✓ Waiting for component to start [14s] + +Applying URL changes + ✓ URL url1: http://url1.abcdr.com/ created + +Syncing to component nodejs + ✓ Checking file changes for pushing [2ms] + ✓ Syncing files to the component [3s] + +Executing devfile commands for component nodejs + ✓ Executing devbuild command "npm install" [4s] + ✓ Executing devrun command "npm start" [3s] + +Pushing devfile component nodejs + ✓ Changes successfully pushed to component +---- + +. Add the storage to your application ++ +[source,terminal] +---- +$ odo storage create --path /data --size 5Gi +---- ++ +.Example output +[source,terminal] +---- +✓ Added storage abcde to nodejs + +Please use `odo push` command to make the storage accessible to the component +---- + +. Push the changes to the cluster: ++ +[source,terminal] +---- +$ odo push +----