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

Install storage in your application cluster using Rook

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

    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

    • SQL Server HA on RHEL: Meet Pacemaker HA Agent v2 (tech preview)

    • Deploy with confidence: Continuous integration and continuous delivery for agentic AI

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    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

    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.