Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat 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
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud 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

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • 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

Install storage in your application cluster using Rook

July 13, 2022
Praveen Kumar
Related topics:
Kubernetes
Related products:
Developer ToolsRed Hat OpenShift Local

Share:

    Developers running applications in the cloud have traditionally separated their applications from storage, but recent services such as the Rook Operator for Kubernetes make it easy to create storage in the cloud. This article shows how to use Rook for object storage. Our example runs a single-node Red Hat OpenShift cluster on your laptop or desktop using Red Hat OpenShift Local (previously known as CodeReady Containers). We'll install Rook, create object storage on OpenShift Local, and perform some bucket notifications.

    Rook is an open source offering from the Cloud Native Computing Foundation (CNCF). This article creates storage using the Ceph object store.

    Install and run Red Hat OpenShift Local

    You can download the latest release of OpenShift Local and follow the installation instructions to run it.

    Add disk space for Rook

    OpenShift Local doesn't provide additional disk space, so users need to create it manually and attach it to the instance. This process is specific to your operating system. The following steps work on GNU/Linux:

    $ qemu-img create -f raw /full/path/to/crc-extra-disk 30G
    $ sudo virsh attach-disk crc --source /full/path/to/crc-extra-disk --target vdb --cache none

    Log in to the OpenShift cluster

    Log in as the kubeadmin administrative user:

    $ crc console --credentials
    $ oc login -u kubeadmin -p <password> https://api.crc.testing:6443
    $ oc whoami
    kubeadmin

    Install Rook resources

    Rook requires custom resource definitions (CRDs), an Operator, and other resources that you can install through OpenShift's oc administative commmand:

    $ oc apply -f https://raw.githubusercontent.com/rook/rook/master/deploy/examples/crds.yaml
    $ oc apply -f https://raw.githubusercontent.com/rook/rook/master/deploy/examples/common.yaml
    $ oc apply -f https://raw.githubusercontent.com/rook/rook/master/deploy/examples/operator-openshift.yaml
    $ oc apply -f https://raw.githubusercontent.com/rook/rook/master/deploy/examples/cluster-test.yaml

    Use a secure port for the object store:

    $ cat <<EOF | oc apply -f -
    #################################################################################################################
    # Create an object store with settings for a test environment. Only a single OSD is required in this example.
    #  kubectl create -f object-test.yaml
    #################################################################################################################
    apiVersion: ceph.rook.io/v1
    kind: CephObjectStore
    metadata:
      name: my-store
      namespace: rook-ceph # namespace:cluster
    spec:
      metadataPool:
        replicated:
          size: 1
      dataPool:
        replicated:
          size: 1
      preservePoolsOnDelete: false
      gateway:
        service:
          annotations:
            service.beta.openshift.io/serving-cert-secret-name: my-store-tls
        securePort: 443
        instances: 1
    EOF

    Wait until all the pods in the rook-ceph namespace are running. You can check that they are running through the following command:

    $ oc get pods -n rook-ceph
    NAME                                                READY   STATUS      RESTARTS   AGE
    csi-cephfsplugin-provisioner-6f54f6c477-5sp9k       6/6     Running     0          29m
    csi-cephfsplugin-z96pz                              3/3     Running     0          29m
    csi-rbdplugin-provisioner-6d765b47d5-pkc8j          6/6     Running     0          29m
    csi-rbdplugin-ssgc9                                 3/3     Running     0          29m
    rook-ceph-mgr-a-5b8f9998c6-vrglx                    1/1     Running     0          27m
    rook-ceph-mon-a-7445f49f8-6tfjj                     1/1     Running     0          27m
    rook-ceph-operator-5df4d596d5-sfrtw                 1/1     Running     0          31m
    rook-ceph-osd-0-5f46f4cb58-498w6                    1/1     Running     0          26m
    rook-ceph-osd-prepare-crc-8rwmc-master-0--1-zjcgc   0/1     Completed   0          26m
    rook-ceph-rgw-my-store-a-6847bcf96b-cwc9s           1/1     Running     0          17m

    Create an object bucket claim

    An object bucket claim (OBC) is a CRD that creates a storage class. The following commands create your OBC:

    $ oc apply -f https://raw.githubusercontent.com/rook/rook/master/deploy/examples/storageclass-bucket-delete.yaml
    $ oc apply -f https://raw.githubusercontent.com/rook/rook/master/deploy/examples/object-bucket-claim-delete.yaml

    See the OBC configuration documentation for more information.

    Allow external access

    OpenShift has a route resource to expose a service externally, which you can use for the rook-ceph-rgw-my-store service:

    $ oc create route passthrough --service=rook-ceph-rgw-my-store -n rook-ceph
    $ oc get route -n rook-ceph
    NAME                     HOST/PORT                                           PATH   SERVICES                 PORT    TERMINATION   WILDCARD
    rook-ceph-rgw-my-store   rook-ceph-rgw-my-store-rook-ceph.apps-crc.testing          rook-ceph-rgw-my-store   https   passthrough   None

    Upload a file to your object store

    Amazon Web Services (AWS) provides a command-line interface (CLI) to carry out just about anything you need to do on AWS. Download the CLI if you don't already have it; you can find the Linux version here. Install it as explained in the accompanying documentation.

    To make sure you have the AWS CLI installed, enter:

    $ aws --version
    aws-cli/1.23.6 Python/3.6.8 Linux/4.18.0-348.el8.x86_64 botocore/1.25.6

    Export the required AWS variables from the cluster:

    $ export AWS_ACCESS_KEY_ID=$(kubectl -n default get secret ceph-notification-bucket -o jsonpath='{.data.AWS_ACCESS_KEY_ID}' | base64 --decode)
    $ export AWS_SECRET_ACCESS_KEY=$(kubectl -n default get secret ceph-notification-bucket -o jsonpath='{.data.AWS_SECRET_ACCESS_KEY}' | base64 --decode)
    $ export AWS_URL=https://rook-ceph-rgw-my-store-rook-ceph.apps-crc.testing

    Get the bucket from the OBC:

    $ export BUCKET_NAME=$(kubectl get objectbucketclaim ceph-notification-bucket -o jsonpath='{.spec.bucketName}')

    Upload the file and ensure that it's available:

    $ echo "hello world" > hello.txt
    $ aws --no-verify-ssl --endpoint-url "$AWS_URL" s3 cp hello.txt s3://"$BUCKET_NAME"
    upload: ./hello.txt to s3://ceph-bkt-f51b12b7-1240-48a0-b6a5-fa0a15c18e94/hello.txt
    $ aws --no-verify-ssl --endpoint-url "$AWS_URL" s3 ls s3://"$BUCKET_NAME"
    2022-05-04 04:49:57         12 hello.txt

    Object storage is easy to install in the cloud

    This article has shown how to use the Rook Operator to create storage in the same cluster where your application runs. The principles can be extended to many cloud environments and types of storage.

    Last updated: November 8, 2023

    Recent Posts

    • Migrating Ansible Automation Platform 2.4 to 2.5

    • Multicluster resiliency with global load balancing and mesh federation

    • Simplify local prototyping with Camel JBang infrastructure

    • Smart deployments at scale: Leveraging ApplicationSets and Helm with cluster labels in Red Hat Advanced Cluster Management for Kubernetes

    • How to verify container signatures in disconnected OpenShift

    What’s up next?

    Cover of the ebook OpenShift for Developers

    Get a hands-on introduction to daily life as a developer crafting code on OpenShift, the open source container application platform from Red Hat, with OpenShift for Developers.

    Download the e-book
    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