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

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

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

Share:

    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

    • Expand Model-as-a-Service for secure enterprise AI

    • OpenShift LACP bonding performance expectations

    • Build container images in CI/CD with Tekton and Buildpacks

    • How to deploy OpenShift AI & Service Mesh 3 on one cluster

    • JVM tuning for Red Hat Data Grid on Red Hat OpenShift 4

    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

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

    Red Hat legal and privacy links

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

    Report a website issue