Creating and deploying devfile components to the disconnected cluster
- Creating a NodeJS application by using a devfile in a disconnected cluster
- Creating a Java application by using a devfile in a disconnected cluster
Creating a NodeJS application by using a devfile in a disconnected cluster
This procedure is using external dependencies such as |
Prerequisites
You have created and logged into a disconnected cluster.
You have added
raw.githubusercontent.com
,registry.access.redhat.com
, andregistry.npmjs.org
URLs in your proxy.
Procedure
Define your NodeJS application in a devfile:
Example of a devfile
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://<proxy-host>:<proxy-port>
- name: HTTPS_PROXY
value: http://<proxy-host>:<proxy-port>
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:
$ odo create nodejs --devfile <path-to-your-devfile> --starter $$ odo push
Example output
[...]
Pushing devfile component nodejs
✓ Changes successfully pushed to component
Create a URL to access your application and push it to the cluster:
$ odo url create url1 --port 3000 --host example.com --ingress && odo push
Example output
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
$ odo storage create <storage-name> --path /data --size 5Gi
Example output
✓ Added storage abcde to nodejs
Please use `odo push` command to make the storage accessible to the component
Push the changes to the cluster:
$ odo push
Creating a Java application by using a devfile in a disconnected cluster
This procedure is using external dependencies such as |
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
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=<proxy-host> -Dhttp.proxyPort=<proxy-port> -Dhttps.proxyHost=<proxy-host> -Dhttps.proxyPort=<proxy-port> 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:
$ odo create java-maven --devfile <path-to-your-devfile> --starter
Example output
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:
$ odo push
Example output
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=<proxy-host> -Dhttp.proxyPort=<proxy-port> -Dhttps.proxyHost=<proxy-host> -Dhttps.proxyPort=<proxy-port> 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:
$ odo log
Example output
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:
$ odo storage create storage-name --path /data --size 5Gi
Example output
✓ 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:
$ odo push
Output
✓ 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=<proxy-host> -Dhttp.proxyPort=<proxy-port> -Dhttps.proxyHost=<proxy-host> -Dhttps.proxyPort=<proxy-port> package" [10s]
✓ Executing run command "java -jar target/*.jar" [3s]
Pushing devfile component java-maven
✓ Changes successfully pushed to component