Learn KOP - Managed Storage Utilize - Rafay Product Documentation

Part 3: Utilize

What Will You Do

In this part of the self-paced exercise, you will test each type of storage exposed by the managed storage add-on.


Block, Shared Filesystem, Object

To test the block storage exposed by the managed storage add-on, you will create a stateful application that uses the block storageclass.

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 storageclass created by the managed system add-on, Rook Ceph.

Note, that the workload is using the "rook-ceph-block" storageclass 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: rook-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 storageclass.

kubectl get persistentvolumeclaims -A

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


To test the filesystem storage exposed by the managed storage add-on, you will create a stateful application that uses the filesystem storageclass.

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 storageclass created by the managed system add-on, Rook Ceph.

Note, that the workload is using the "rook-cephfs" filesystem storageclass 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: rook-cephfs
  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 storageclass.

kubectl get persistentvolumeclaims -A

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


To test the object storage exposed by the managed storage add-on, you will create a container which will be used to upload and read to the object storage.

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 the managed storage add-on.

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 rafay-infra
kubectl get secret ceph-delete-bucket -n rafay-infra -o yaml
echo 'ENCODED_VALUE' | base64 --decode

Now, you will retrieve the region of the bucket.

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

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

kubectl get cephobjectstore -n rafay-infra
kubectl get cephobjectstore ceph-objectstore -n rafay-infra -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! At this point, you have successfully deployed a test application that is using the Rook Ceph managed storage add-on.