Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

How the odo CLI simplifies Kubernetes development

November 20, 2023
Cedric Clyburn
Related topics:
Kubernetes
Related products:
Red Hat OpenShift

Share:

    Within the inner loop phase of application development, we’re working with continuous coding, building, and testing our application until it’s ready for staging or production. However, when we deploy to cloud-native solutions like Kubernetes or Red Hat OpenShift, this gets a bit more tricky. There are complexities in knowing Kubernetes and DevOps concepts and a steep learning curve. But that’s exactly where odo comes in. This is a developer-focused command line interface (CLI) for fast, iterative, and simplified container-based application development. Let’s take a look at how to use odo to locally deploy to Podman and then to a Kubernetes and remote OpenShift cluster.

    What is odo?

    The odo open source CLI tool for rapid cloud-native development facilitates an iterative coding process on Kubernetes and OpenShift and is powered by the open Devfile standard. Specifically, odo can supercharge our path to development within a container in just two commands, odo init and odo dev, which auto-detects our source code and allows live coding. The simple syntax helps to focus on coding, abstracting all the complexities away from Kubernetes and even letting us start without a cluster by running our containerized application locally in the Podman container engine (Figure 1).

    Checking out the odo.dev homepage
    Figure 1. Checking out the odo.dev homepage.

    Getting started with odo

    Let’s take a look at how we can easily install the odo CLI tool, then bootstrap a project using the Kubernetes-ready Quarkus Java framework and begin to see how odo helps us in the inner loop of cloud-native development without hassle.

    Installing the odo CLI tool

    To install odo, head to the website’s installation page to learn about the process for your machine. It’s a simple binary, but being on macOS, I could easily install odo using the Homebrew package manager with brew install odo-dev (Figure 2).

    Installing odo using the Homebrew package manager on macOS.
    Figure 2. Installing odo through the Homebrew package manager on macOS.

    To debug and test remote applications using odo directly from your IDE, the OpenShift Toolkit for VSCode and JetBrains includes the odo binary to interact with your Kubernetes or OpenShift cluster directly, without leaving your development environment (Figure 3).

    Using odo within the OpenShift Toolkit extension.
    Figure 3. Odo being used by the OpenShift Toolkit for VSCode.

    Initializing an application with odo

    While you may already have a project you’d like to use with odo, let’s start with an example project containing some source code using the container-first Java framework, Quarkus. By visiting the Quarkus quickstart page, we can learn how to quickly generate a project that includes a RESTful endpoint (Figure 4). Make sure to select the Generate your application button on the right-hand side to download a.zip file containing the project (which includes GreetingResource.java exposed on /hello and an index.html landing page for our application).

    Downloading Quarkus starter code for testing with odo.
    Figure 4. Downloading an example Quarkus project to be used with odo.

    From here, let’s head into our terminal to initialize our application, using the odo init command. This will auto-detect our source code, and download the appropriate devfile.yaml that contains the definition of our development environment as code, specifying components, commands, and configurations. As shown in Figure 5, we can simply use the default settings for this process.

    $ odo init
    Initializing our application with the odo init command.
    Figure 5. Viewing the Quarkus project and initializing it using odo.

    Developing an application locally with Podman and odo

    With our code and Devfile ready to go, we can now use the odo dev command to facilitate the development of our application. For example, this includes making changes and previewing in-real time, testing Kubernetes support for our application, and debugging our application. First, let’s start off by targeting Podman for local development before moving on to a Kubernetes cluster (Figure 6).

    $ odo dev --platform=podman
    Starting a containerized development session by targeting the Podman engine.
    Figure 6. Starting a containerized development session by targeting the Podman engine.

    Congratulations! You’ve started development on your Quarkus application, and you can now access the running pod locally with Podman, in addition to some other resources, such as the odo web console and the port forwarding of the application (Figure 7).

    A view of a Quarkus application running locally with Podman.
    Figure 7. Viewing the running Quarkus application in our browser.

    Let’s now begin modifying our source code within the IDE to see odo immediately keeping our containerized application up to date. For this, we’ve added a bit of text to our endpoint. Within seconds, the pod has already been re-deployed. Now, we can see these changes live by calling the example endpoint via our terminal (Figure 8).

    A screenshot of iterating on code with odo.
    Figure 8. Making changes to our Quarkus project to see real-time updates.

    We can also check this out visually by using Podman Desktop, a graphical tool to visualize containers and pods. Within the Pods section of the interface, we can see our running Pod, logs, metadata, and more (Figure 9).

    A view of the running pod within Podman Desktop.
    Figure 9. Visualizing Pod logs through Podman Desktop.

    Developing an application for Kubernetes with odo

    Recently, odo has added support for Podman and local development of containers without access to a cluster. Let’s demonstrate using odo for development on Kubernetes. Of course, you can use any compliant Kubernetes cluster with odo, whether it's a hosted cloud provider, a self-managed cluster, or hosted locally with a tool like Minikube. The process is easy if you’re already connected to your Kubernetes cluster. Simply create a new namespace using the following command (Figure 10):

    $ odo create namespace odo-dev
    A screenshot of creating a new namespace for development using odo.
    Figure 10. Creating a new namespace for our odo development on Kubernetes.

    Now, with our devfile.yaml already in the project, we can continue our inner loop development just as we did with Podman, but now in our Kubernetes cluster. Use the odo dev command to start development, and watch the magic happen as odo takes care of all of the resource creation and watches for live coding changes (Figure 11).

    $ odo dev
    Developing on Kubernetes with odo.
    Figure 11. Starting to iterate on our application with odo dev command.

    Developing an application for OpenShift with odo

    You don’t have a Kubernetes cluster already? No worries. For this next example, we’ll be using the freely available Developer Sandbox for Red Hat OpenShift, which provides immediate access to an OpenShift cluster built on Kubernetes right in your browser.

    First, select Start your sandbox for free to log in with your Red Hat account and get free 30-day access to the Developer Sandbox (Figure 12).

    Viewing the homepage of Developer Sandbox for Red Hat OpenShift.
    Figure 12. Visiting the Developer Sandbox for Red Hat OpenShift homepage.

    To connect odo to this OpenShift cluster, select the Copy login command button from the top-right of the OpenShift Web Console, where you can display your login token and copy it to the clipboard (Figure 13).

    Copying the login token from the Developer Sandbox.
    Figure 13. Copying the login command from the Developer Sandbox for odo authentication.

    Here’s the trick, if you don’t already have the OpenShift `oc` CLI. Replace odo in the command with oc, and you’ll be ready to enter the login token and successfully connect to your cluster (Figure 14). You’ll automatically be defaulted to your single project/namespace in the Developer Sandbox, so we can continue on without making a new project.

    $ odo login <token>
    Authenticating to our OpenShift cluster using odo.
    Figure 14. Authenticating to the OpenShift cluster using the odo login command.

    Finally, let’s kick off the inner loop activities in this cloud-native Kubernetes environment with the odo dev command, which will deploy our Quarkus application to OpenShift similar to how we just did with the Kubernetes cluster. We’ll now see the Quarkus app container running within a pod on our cluster with a service already set up (Figure 15). We also have the ability to create an OpenShift route to access our application externally.

    $ odo dev
    Viewing the deployment of an application in OpenShift.
    Figure 15. Iterating and viewing the deployment of our application in OpenShift.

    With odo, you can easily iterate your application against the Kubernetes or OpenShift cluster, as well as test and debug without having a deep understanding of the platform. For more advanced topics, feel free to head to the documentation site to learn about topics such as connecting to a service, running applications using odo in a production environment, and troubleshooting.

    Summary

    In short, odo makes it easy to navigate the complex world of Kubernetes, providing first-class deployment support for Podman and Kubernetes. With just a few simple commands, developers can set up their projects, make live updates, and odo will handle your application's building, pushing, and deployment. Be sure to check out the open source project at odo.dev, star the project on GitHub, and give it a try!

    Related Posts

    • How odo 3.0 GA improves the developer experience

    • Set up an OpenShift cluster to deploy an application in odo CLI

    • How to use odo the developer-centric CLI with OpenShift 4

    Recent Posts

    • Unleashing multimodal magic with RamaLama

    • Integrate Red Hat AI Inference Server & LangChain in agentic workflows

    • Streamline multi-cloud operations with Ansible and ServiceNow

    • Automate dynamic application security testing with RapiDAST

    • Assessing AI for OpenShift operations: Advanced configurations

    What’s up next?

    As a developer, you want to develop software without the overhead of do-it-yourself operations. With odo, the OpenShift CLI, you can develop cloud-native applications without learning dozens of commands. Our odo cheat sheet provides the commands you need to get started.

    Get the cheat sheet
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue