Compared to other solutions Google Cloud Platform relies far too heavily on it’s CLI to perform basic actions on infrastructure. In fact, 90% of the documentation only explains how to perform tasks using the CLI which is confusing when some of the set up may have been done using the nice, comfortable web ui. The potential is great, but their refusal to make life easy for those who just want to get things done with a GUI without learning “yet another” CLI or hitting the terminal at all is pretty short-sighted. For most non-enterprise users, the learning curve is laughable, it really doesn’t have to be.
One of the most basic things a containerised web application may require is persistent storage. It’s a common requirement and not much to ask. The Kubernetes web ui makes it as hard as possible to get started with muddling terminology, docs and missing functionality. So let’s clarify some terminology…
It is what it is, a disk that doesn’t go away when pods are destroyed. When you create a new cluster and node pool using the Web UI, 100GB of persistent storage is assigned by default.
(PVC) These are configurations that exist at the cluster level. They are simply a configuration that can be referred to in a workload configuration. Things like the amount of the volume to claim, permissions and namespace can be set. Frustratingly, you can’t add these using the web ui, even though you can manage the existing ones. Management is done through the storage menu found by clicking the menu item in the image above.
Creating a PersistentVolumeClaim
From the Kubernetes Clusters menu, click the “Connect” button next to the cluster you want to add storage to (if you don’t see it, refresh the page). Click “Run in Cloud Shell”. After the shell loads, press the enter key to execute the predefined command. You are now working in the correct cluster.
- Create a yaml file:
- Open the yaml file in an editor:
- Paste the following PVC configuration into the editor and change the name, namespace and storage values to your own requirements.
Note: It’s important that the namespace is the same as the workload.
- Hit ctrl+x to tell the editor you want to leave, it will ask you if you want to save, press
yand hit enter.
- Now create the PVC:
kubectl create -f pstorage.yaml
- Check it out in the Storage menu on the Web UI and make sure the namespace and name are correct.
- Go to the workload who’s pods you want to have access to this PVC and press the edit button to edit the YAML configuration.
Check out the following configuration…
- mountPath: /var/www/html
- name: cool-data
Copy the volumeMounts and volumes sections and place them appropriately in your own workload configuration.
- Set the name to the same as the PVC in previous steps.
- Set the mountPath to where you want the PVC mounted in the pods filesystem.
- Set the subPath to a unique subdirectory which will be used on the PVC to prevent conflicts.
- Press Save
- If the workload doesn’t reinitialise with fresh pods, go in and delete the pod to force the reinitialisation.
That’s it! Your pods will now have access to the Persistent Storage.
This tutorial is too long, I hope this will all be configurable in the Web UI in the near future.