Working in a fast, iterative manner isn’t a practice exclusive to software developers: It’s the way people like to work. Being able to make a series of small changes and testing each change along the way to addressing a larger problem helps assure that the right choices are being made toward the end result.
For developers working with OpenShift, the experience described above shouldn’t be any different. odo is a developer-centric CLI that helps developers implement, design and test source code with OpenShift faster. It’s one of a series of tools being released for general availability with the launch of OpenShift 4.2.
With odo, the ability to work on local source code, make changes, and just as quickly push changes up to an OpenShift cluster is possible with this easy-to-use tool. If you’re familiar with git, the flow of using odo should be very familiar.
By running a few CLI commands, you can push up local source code you are working on to OpenShift and have that source running on a container. Whenever you are ready to deploy code out to an OpenShift project, you can view several programming language options available with odo by running the command below:
$ odo catalog list components odo Supported OpenShift Components: NAME PROJECT TAGS java openshift 11,8,latest nodejs openshift 10,8,8-RHOAR,latest OpenShift Components: NAME PROJECT TAGS dotnet openshift 2.1,2.2,latest golang openshift 1.11.5,latest httpd openshift 2.4,latest modern-webapp openshift 10.x,latest nginx openshift 1.10,1.12,latest perl openshift 5.24,5.26,latest php openshift 7.0,7.1,7.2,latest python openshift 2.7,3.6,latest ruby openshift 2.4,2.5,latest
These language options correspond to what are called builder images, which are container image definitions that can be used to support application source code developed in a particular language. In addition to selecting a language itself, you will be able to choose a particular version of a language as well.
To select a language, in the root of the source code directory you are working in locally, you can run the following command
$ odo create <language> app
odo create command specifies that you are creating a local configuration that will be used to track how you want your code to be deployed out to OpenShift.
<language> in the above command corresponds to the programming language your application is written in.
app corresponds to the name of the application that will be deployed. While you can give the application a specific name, it is not mandatory and you can deploy your code without specifying a name.
If you were deploying a Node.js application using odo, the odo command you would run would be similar to what is shown below:
$ odo create nodejs app
odo create, all that is needed to deploy your code out to OpenShift is to run the following command:
$ odo push
odo create is similar to the idea of a
git init where you are initializing that a local directory has source code written in a particular language. Editing the source code locally after running
odo create is similar to a
git commit. When you are committing to a change, you haven’t actually pushed that change remotely to be available in a git repository yet. odo follows this same flow that gives you control of when source code is actually deployed out to OpenShift.
odo push completes, your source code will be running on a container out in your OpenShift project. After an initial deployment via
odo push, odo has the ability to quickly change and redeploy source code to your OpenShift cluster.
To alter an application component after a first
odo push, you can simply change your source code locally and run
odo push again. Upon completion of the command, your changes should be running on OpenShift.
While running an additional
odo push is easy enough to push code changes, you can further simplify your redeployment using
odo watch. By running
odo watch in the directory you are working in, your code changes will automatically pushed up to OpenShift each time you make a local change without running
odo push again.
Another exciting feature that is currently in tech preview as part of the odo GA release is the ability to debug source code that is deployed on OpenShift. odo has a command called
odo debug that allows you to remotely debug your code. The benefits of using a debugger locally are great, but odo allows you to have those same capabilities for code that is running in the environment it will eventually be hosted in. Keep an eye out for developments around
odo debug as it reaches a more mature state in future releases.
In addition to working with source code changes, odo allows you to manage other aspects of your deployed source code, such as creating a url for the application, linking your deployed application component to other application components deployed on OpenShift, viewing logs of deployed applications, and many other features. odo helps you focus on the source code you are writing for applications rather than all the details of hosting that application component on OpenShift.
odo is one of the many tools being built at Red Hat that reflects the way developers like to work. Developing directly against a development environment and knowing that the code you are working on runs on OpenShift from the start of your work to the end is what odo was created for.
In addition to this blog post, I have put together a video that walks through the capabilities of odo and shows how to deploy an application out to OpenShift. You can find out how to install, get started, and submit feedback on odo in the odo GitHub repository. We have an interactive tutorial available that allows users to learn more about odo and use it to deploy and iterate on a sample application with OpenShift. You can also view some of our past blog posts and videos on adding support for a programming language with odo (blog, video) and using interactive mode with odo.
We are excited to see all the creative ways that developers use odo, and, more importantly, see all the things you create with it.
Learn more about application development with OpenShift at developers.redhat.com/openshift.Last updated: June 27, 2023