Launching an application using CSF as the POD's storage

Content Software for File CLI Reference

Version
4.2.x
Audience
anonymous
Part Number
MK-HCSF001-03

Now that we have a storage class and a PVC in place, we can configure the Kubernetes pods to provision volumes using the Content Software for File system.

We'll take an example application that echos the current timestamp every 10 seconds, and provide it with the previously created pvc-wekafs-dir PVC.

Multiple pods can share a volume produced by the same PVC as long as the accessModes parameter is set to ReadWriteMany.

csi-wekafs/examples/dynamic/csi-app-on-dir.yaml
1 kind: Pod
2 apiVersion: v1
3 metadata:
4 name: my-csi-app
5 spec:
6 containers:
7 - name: my-frontend
8 image: busybox
9 volumeMounts:
10 - mountPath: "/data"
11 name: my-csi-volume
12 command: ["/bin/sh"]
13 args: ["-c", "while true; do echo `date` >> /data/temp.txt; sleep
14 volumes:
15 - name: my-csi-volume
16 persistentVolumeClaim:
17 claimName: pvc-wekafs-dir # defined in pvc-wekafs-dir.yaml

Now we will apply that pod:

1 $ kubectl apply -f csi-app-on-dir.yaml
2 pod/my-csi-app created

Kubernetes will allocate a persistent volume and attach it to the pod, it will use a directory within the WekaFS filesystem as defined in the storage class mentioned in the persistent volume claim. The pod will be in Running status, and the temp.txt file will get updated with occasional date information.

1 get pod my-csi-app
2 NAME READY STATUS RESTARTS AGE
3 my-csi-app 1/1 Running 0 85s
4
5 # if we go to a wekafs mount of this filesystem we can see a directory
6 $ ls -l /mnt/weka/podsFilesystem/csi-volumes
7 drwxr-x--- 1 root root 0 Jul 19 12:18 pvc-d00ba0fe-04a0-4916-8fea-ddbbc
8
9 # inside that directory, the temp.txt file from the running pod can be
10 $ cat /mnt/weka/podsFilesystem/csi-volumes/pvc-d00ba0fe-04a0-4916-8fea
11 Sun Jul 19 12:50:25 IDT 2020
12 Sun Jul 19 12:50:35 IDT 2020
13 Sun Jul 19 12:50:45 IDT 2020