Using the Storage Provisioner Gluster Addon

storage-provisioner-gluster addon

Gluster, a scalable network filesystem that provides dynamic provisioning of PersistentVolumeClaims.

Starting Minikube

This addon works within Minikube, without any additional configuration.

  1. $ minikube start

Enabling storage-provisioner-gluster

To enable this addon, simply run:

  1. $ minikube addons enable storage-provisioner-gluster

Within one minute, the addon manager should pick up the change and you should see several Pods in the storage-gluster namespace:

  1. $ kubectl -n storage-gluster get pods
  2. NAME READY STATUS RESTARTS AGE
  3. glusterfile-provisioner-dbcbf54fc-726vv 1/1 Running 0 1m
  4. glusterfs-rvdmz 0/1 Running 0 40s
  5. heketi-79997b9d85-42c49 0/1 ContainerCreating 0 40s

Some of the Pods need a little more time to get up an running than others, but in a few minutes everything should have been deployed and all Pods should be READY:

  1. $ kubectl -n storage-gluster get pods
  2. NAME READY STATUS RESTARTS AGE
  3. glusterfile-provisioner-dbcbf54fc-726vv 1/1 Running 0 5m
  4. glusterfs-rvdmz 1/1 Running 0 4m
  5. heketi-79997b9d85-42c49 1/1 Running 1 4m

Once the Pods have status Running, the glusterfile StorageClass should have been marked as default:

  1. $ kubectl get sc
  2. NAME PROVISIONER AGE
  3. glusterfile (default) gluster.org/glusterfile 3m

Creating PVCs

The storage in the Gluster environment is limited to 10 GiB. This is because the data is stored in the Minikube VM (a sparse file /srv/fake-disk.img).

The following yaml creates a PVC, starts a CentOS developer Pod that generates a website and deploys an NGINX webserver that provides access to the website:

  1. ---
  2. #
  3. # Minimal PVC where a developer can build a website.
  4. #
  5. kind: PersistentVolumeClaim
  6. apiVersion: v1
  7. metadata:
  8. name: website
  9. spec:
  10. accessModes:
  11. - ReadWriteMany
  12. resources:
  13. requests:
  14. storage: 2Mi
  15. storageClassName: glusterfile
  16. ---
  17. #
  18. # This pod will just download a fortune phrase and store it (as plain text) in
  19. # index.html on the PVC. This is how we create websites?
  20. #
  21. # The root of the website stored on the above PVC is mounted on /mnt.
  22. #
  23. apiVersion: v1
  24. kind: Pod
  25. metadata:
  26. name: centos-webdev
  27. spec:
  28. containers:
  29. - image: centos:latest
  30. name: centos
  31. args:
  32. - curl
  33. - -o/mnt/index.html
  34. - https://api.ef.gy/fortune
  35. volumeMounts:
  36. - mountPath: /mnt
  37. name: website
  38. # once the website is created, the pod will exit
  39. restartPolicy: Never
  40. volumes:
  41. - name: website
  42. persistentVolumeClaim:
  43. claimName: website
  44. ---
  45. #
  46. # Start a NGINX webserver with the website.
  47. # We'll skip creating a service, to keep things minimal.
  48. #
  49. apiVersion: v1
  50. kind: Pod
  51. metadata:
  52. name: website-nginx
  53. spec:
  54. containers:
  55. - image: gcr.io/google_containers/nginx-slim:0.8
  56. name: nginx
  57. ports:
  58. - containerPort: 80
  59. name: web
  60. volumeMounts:
  61. - mountPath: /usr/share/nginx/html
  62. name: website
  63. volumes:
  64. - name: website
  65. persistentVolumeClaim:
  66. claimName: website

Because the PVC has been created with the ReadWriteMany accessMode, both Pods can access the PVC at the same time. Other website developer Pods can use the same PVC to update the contents of the site.

The above configuration does not expose the website on the Minikube VM. One way to see the contents of the website is to SSH into the Minikube VM and fetch the website there:

  1. $ kubectl get pods -o wide
  2. NAME READY STATUS RESTARTS AGE IP NODE
  3. centos-webdev 0/1 Completed 0 1m 172.17.0.9 minikube
  4. website-nginx 1/1 Running 0 24s 172.17.0.9 minikube
  5. $ minikube ssh
  6. _ _
  7. _ _ ( ) ( )
  8. ___ ___ (_) ___ (_)| |/') _ _ | |_ __
  9. /' _ ` _ `\| |/' _ `\| || , < ( ) ( )| '_`\ /'__`\
  10. | ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )( ___/
  11. (_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)
  12. $ curl http://172.17.0.9
  13. I came, I saw, I deleted all your files.
  14. $

Last modified July 7, 2023: Add addon readmes to website (cf976f6dd)