Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

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

November 10, 2022
Francesco Ilario
Related topics:
GoKubernetesOperators
Related products:
Developer ToolsetRed Hat OpenShift

    Binding is the task of finding a backing service and connecting it to an application, such as a database. There are several ways to bind applications to cloud services in Kubernetes and Red Hat OpenShift. The odo command-line interface (CLI) consolidates steps that developers normally have to perform manually, and abstracts away Kubernetes and OpenShift background concepts.

    With odo, you can concentrate on creating applications instead of administering the cluster. The odo tool automates deployment configurations, build configurations, service routes, and other Kubernetes and OpenShift elements.

    The Service Binding Operator, employed by odo, makes the application developer's life a lot easier by providing a consistent and declarative Service Binding method.

    This two-part series demonstrates how to use odo to create an application and a database service, bind the application to the database using the Service Binding Operator, and get access to the application's REST API. This article prepares the environment with the necessary tools. In part 2, Implementation of RestAPI application with MongoDB using SBO, we will install MongoDB and the application, and bind them together.

    A REST application example

    We will use a REST application written in Go as an example here. The application connects to a MongoDB database using the Service Binding Operator and allows you to manage entries in the database. Data consists of place names and descriptions. The REST API's endpoints allow you to add details to the MongoDB instance and perform create, read, update, and delete (CRUD) operations.

    When you request a binding, the Service Binding Operator looks at the data stored within the custom resource (CR) and its corresponding custom resource definition (CRD) inside the service. This data contains the parameters required to bind the application to the service. The Service Binding Operator then projects this binding data into the application's workload resources as environment variables or files. To learn more about the Service Binding Operator and its integration with other products, refer to the Service Binding documentation.

    Prerequisites

    To run and interact with the application, you must complete the following procedures successfully:

    1. Install Go and odo packages
    2. Set up an OpenShift cluster with administrator access
    3. Install the Percona Distribution for MongoDB Operator
    4. Install the Service Binding Operator

    We will use the following versions of these tools to showcase the application:

    • Go 1.18.7
    • odo v3.0.0
    • OpenShift 4.11
    • Percona Distribution for MongoDB Operator 1.13.0, provided by Percona

    The following steps provide instructions for each prerequisite.

    Step 1: Install Go and odo packages

    Install Go following the official guidelines.
     
    The odo installation process is as simple as downloading the binary for your OS/ARCH and placing it into a folder referenced by your PATH environment variable. In the following you find the installation procedure for Linux/amd64 and odo-v3.0.0. For a different OS or architecture, check the odo Installation page.
     
    1. Download the latest release from the mirror site

      $ curl -L https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/odo/v3.0.0/odo-linux-amd64 -o odo
      
        % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                       Dload  Upload   Total   Spent    Left  Speed
        0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
        0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
      100 66.7M  100 66.7M    0     0  3261k      0  0:00:20  0:00:20 --:--:-- 3729k
    2. Install odo, you might have to provide your password for root access:

      $ sudo install -o root -g root -m 0755 odo /usr/local/bin/odo
      [sudo] password for user:

      If you are not allowed to use sudo or you prefer a rootless installation, you can install the odo tool to a local folder, like for example ~/.local/bin, and configure your shell:

      $ mkdir -p ~/.local/bin
      $ mv odo ~/.local/bin
      $ export PATH=${HOME}/.local/bin/odo:${PATH}
      
    3. Verify that odo is installed:

      $ odo version
      odo v3.0.0 (8694f1946)

    Step 2: Set up an OpenShift cluster

    There are several ways to use OpenShift, like using crc or running a managed cluster. You can find more details in the getting started page. To complete the demo, please ensure to have a cluster with at least 16GB of memory.
     
    After you install and log into your own cluster, or log into a managed cluster in the cloud, create a project with the following command:
    $ odo create project mongodb-restapi
     ✓  Project "mongodb-restapi" is ready for use
     ✓  New project created and now using project: mongodb-restapi

    Step 3: Install the Percona Distribution for MongoDB Operator

    We are not installing from OperatorHub because the installation should be done to our specific mongodb-restapi OpenShift namespace.

    Follow these two steps:

    1. Install the Percona Distribution for MongoDB Operator:

      $ oc create -f https://raw.githubusercontent.com/redhat-developer/openshift-app-services-demos/main/samples/sbo/restapi-mongodb-odo/operators/mongodb-percona-distribution.yaml
      
      subscription.operators.coreos.com/percona-server-mongodb-operator created
      operatorgroup.operators.coreos.com/operatorgroup created
    2. Verify that you have successfully installed the Percona Distribution for MongoDB Operator. Figure 6 shows the output.
      $ oc get csv -n mongodb-restapi
      NAME                                 DISPLAY                                     VERSION   REPLACES   PHASE
      percona-server-mongodb-operator.v1   Percona Distribution for MongoDB Operator   1.13.0               Succeeded

    Step 4: Install the Service Binding Operator

    The Service Binding Operator is always installed in all namespaces. Here, we are not installing from the OperatorHub because we must install the Operator in a particular namespace named openshift-operators.

    The following two steps will complete the process:

    1. Install the Service Binding Operator:

      $ oc create -f https://raw.githubusercontent.com/redhat-developer/openshift-app-services-demos/main/samples/sbo/restapi-mongodb-odo/operators/servicebinding-operator.yaml
      
      subscription.operators.coreos.com/my-service-binding-operator created
      
    2. Verify that the Service Binding Operator is successfully installed in your namespace:

      $ oc get csv -n mongodb-restapi
      
      NAME                                 DISPLAY                                     VERSION   REPLACES                          PHASE
      percona-server-mongodb-operator.v1   Percona Distribution for MongoDB Operator   1.13.0                                      Succeeded
      service-binding-operator.v1.3.0      Service Binding Operator                    1.3.0     service-binding-operator.v1.2.0   Succeeded

    Summary

    The installation and setup are now complete. In the next article, you will clone the application and create a database component for it. If you have questions, please comment below. We welcome your feedback.

    Last updated: November 8, 2023

    Related Posts

    • Creating OpenShift components with odo interactive mode

    • Examining Kubernetes internals using a REST API example

    • Where can I find REST API client libraries for OpenShift?

    • Installing MongoDB on Red Hat Enterprise Linux

    Recent Posts

    • Tekton joins the CNCF as an incubating project

    • Federated identity across the hybrid cloud using zero trust workload identity manager

    • Confidential virtual machine storage attack scenarios

    • Introducing virtualization platform autopilot

    • Integrate zero trust workload identity manager with Red Hat OpenShift GitOps

    What’s up next?

    Learn and experiment with Kubernetes using the no-cost Developer Sandbox for Red Hat OpenShift! This hands-on tutorial walks you through how to create an application using Kubernetes step-by-step.

    Start the activity
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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

    Chat Support

    Please log in with your Red Hat account to access chat support.