Recipes - Rook-Ceph and Rafay - Rafay Product Documentation

Utilize

Utilize Rook Ceph Storage

In this part, you will create sample workloads that will use the three different types of storage Rook Ceph exposes. Rook Ceph exposes block, file and object storage to the cluster.


Step 1: Utilize Storage

In this step, you will test each type of storage exposed by Rook Ceph.

Select each storage type below to test.

To test the block storage exposed by Rook Ceph, you will create a stateful application that uses the block storage class.

Create Namespace

First, you will create a namespace for the test workload you will soon be creating.


Create Workload

Next, you will create a MySQL workload which will utilize the storage class created by Rook Ceph.

Note, that the workload is using the "ceph-block" storage class for the persistent volume claim.

---
apiVersion: v1
kind: Service
metadata:
  name: mysql
  labels:
spec:
  ports:
    - port: 3306
  selector:
    tier: mysql
  clusterIP: None
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pv-claim
  labels:
spec:
  storageClassName: ceph-block
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
  labels:
    tier: mysql
spec:
  selector:
    matchLabels:
      tier: mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        tier: mysql
    spec:
      containers:
      - image: mysql:5.6
        name: mysql
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: changeme
        ports:
        - containerPort: 3306
          name: mysql
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: mysql-pv-claim

Validate Storage

Next, you will validate that the created workload is using a persistent volume claim from the Rook Ceph storage class.

kubectl get persistentvolumeclaims -A

You will see the persistent volume claim for the deployed workload. The PVC is using the Rook Ceph block storage class.


To test the filesystem storage exposed by Rook Ceph, you will create a stateful application that uses the filesystem storage class.

Create Namespace

First, you will create a namespace for the test workload you will soon be creating.


Create Workload

Next, you will create a WordPress workload which will utilize the filesystem storage class created by Rook Ceph.

Note, that the workload is using the "ceph-filesystem" filesystem storage class for the persistent volume claim.

apiVersion: v1
kind: Service
metadata:
  name: wordpress-mysql
  labels:
    app: wordpress
  namespace: wordpress
spec:
  ports:
    - port: 3306
  selector:
    app: wordpress
    tier: mysql
  clusterIP: None
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pv-claim
  labels:
    app: wordpress
  namespace: wordpress
spec:
  storageClassName: ceph-filesystem
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: wordpress-mysql
  labels:
    app: wordpress
    tier: mysql
  namespace: wordpress
spec:
  selector:
    matchLabels:
      app: wordpress
      tier: mysql
  strategy:
    type: Recreate
  replicas: 3
  template:
    metadata:
      labels:
        app: wordpress
        tier: mysql
    spec:
      containers:
        - image: mysql:5.6
          name: mysql
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: changeme
          ports:
            - containerPort: 3306
              name: mysql
          volumeMounts:
            - name: mysql-persistent-storage
              mountPath: /var/lib/mysql
      volumes:
        - name: mysql-persistent-storage
          persistentVolumeClaim:
            claimName: mysql-pv-claim

Validate Storage

Next, you will validate that the created workload is using a persistent volume claim from the Rook Ceph filesystem storage class.

kubectl get persistentvolumeclaims -A

You will see the persistent volume claim for the deployed workload. The PVC is using the Rook Ceph filesystem storage class.


To test the object storage exposed by Rook Ceph, you will create a container which will be used to upload and read to the object storage.

Create Objectbucketclaim

First, you will create an object bucket claim that will utilize the object storage class exposed by Rook Ceph.

apiVersion: objectbucket.io/v1alpha1
kind: ObjectBucketClaim
metadata:
  name: ceph-bucket
spec:
  generateBucketName: ceph-bkt
  storageClassName: ceph-bucket

Create Namespace

First, you will create a namespace for the test workload you will soon be creating.


Create Workload

Next, you will create a workload which will be used to utilize the object storage exposed by Rook Ceph.

apiVersion: v1
kind: Pod
metadata:
 name: s3cmd
spec:
 containers:
 - name: s3cmd
   image: d3fk/s3cmd:stable
   command:
     - sh
     - -c
     - while true; do echo Hello; sleep 30; done

Retrieve Configuration Details

In this section, you will retrieve the object storage buckets configuration details. These details can be used to access the object storage. You can use these details to access the object storage through many different tools such as s3cmd and boto3.

Now, you will obtain the access key and secret key of the object storage bucket.

kubectl get ObjectBucketClaim -n rook-ceph
kubectl get secret ceph-bucket -n rook-ceph -o yaml
echo 'ENCODED_VALUE' | base64 --decode

Now, you will retrieve the region of the bucket.

kubectl get sc
kubectl get sc ceph-bucket -o yaml

Now, you will retrieve the S3 endpoint of the bucket.

kubectl get cephobjectstore -n rook-ceph
kubectl get cephobjectstore ceph-objectstore -n rook-ceph -o yaml

Configure Storage Bucket

Next, you will configure the s3cmd tool in the previously deployed workload to use the object storage bucket. Note, you can use the previously obtained object storage details to configure other tools or applications to access and use the object storage.

s3cmd --configure

Now, you are ready to test the S3 storage.

s3cmd ls
echo "Hello Rook" > /tmp/rookObj
s3cmd put /tmp/rookObj <BUCKET PATH>
s3cmd ls <BUCKET PATH>
s3cmd get <FILE PATH> /tmp/download.txt
cat /tmp/download.txt

Recap

Congratulations! You have successfully created and used multiple types of Rook Ceph distributed storage.