For the exercise you will have access to a Red Hat OpenShift cluster. You can use the Kubernetes documentation if you want, and use the kubectl commands. Or if you prefer, you can use the Red Hat OpenShift documentation and use the oc commands.
If you already know the commands but don’t remember the options, you can use the --help after the command to get help, or -h for short. For example:
kubectl create deployment --help
kubectl create deployment -h
This exercise also requires git on your terminal, see Install git
-
The application is available on https://github.com/ericbos111/nodejs-sample
It uses port 3001.
-
Install the OpenShift cli from the OpenShift web interface > Help (the question mark)

or from mirror.openshift.com, choose the same version as the cluster version. What I usually do is copy the link, and then from my terminal window, fetch this link with curl:
curl -lO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/4.18.9/openshift-client-linux-amd64-rhel9-4.18.9.tar.gz
Decompress the file with tar xvf
tar xvf https://mirror.openshift.com/pub/openshift-v4/clients/ocp/4.18.9/openshift-client-linux-amd64-rhel9-4.18.9.tar.gz
Copy the files to your path
cp oc kubectl /usr/local/bin/
- Login to the cluster, you can copy the login command from the web interface, or use something like this
oc login api.<instance>.techzone.ibm.com:6443 -u kubeadmin -p <password>
- Create your own namespace or project, using the official documentation.
oc new-project eric
- Deploy this application to your namespace in any way you like.
oc new-app https://github.com/ericbos111/nodejs-sample
- Create a Service and an Ingress or a Route, using the official documentation.
oc create route edge --service=nodejs-sample --port=3001
Get the Ingress or Route, using the official documentation.
oc get route
Verify if you can access the route, either from your browser or with curl
curl -k https://<route>
If you are getting errors, you might want to edit your service to make sure that it uses port 3001 as the target port
- Now, if you want to challenge yourself, you can fork the repo to your own Github, edit the application (in your own repository) and restart the build, for example, change the text “Hello from Node.js Starter Application!” to something else. Observe what happens. After some time, the result of your curl command will have changed.
Before you begin creating an application with this devfile code sample, it's helpful to understand the relationship between the devfile and Dockerfile and how they contribute to your build. You can find these files at the following URLs:
- The
devfile.yamlfile has animage-buildcomponent that points to yourDockerfile. - The
Dockerfilecontains the instructions you need to build the code sample as a container image. - The
devfile.yamlkubernetes-deploycomponent points to adeploy.yamlfile that contains instructions for deploying the built container image. - The
devfile.yamldeploycommand completes the outerloop deployment phase by pointing to theimage-buildandkubernetes-deploycomponents to create your application.
This stack is licensed under the EPL 2.0 license.
- For more information about Node.js, see How do I start with Node.js after I installed it?.
- For more information about devfiles, see Devfile.io.
- For more information about Dockerfiles, see Dockerfile reference.