No Kubernetes service is complete without supporting persistent storage. Our managed Kubernetes service, Fly Kubernetes, has grown up a little more today: it now supports persistent volumes. If you want to add persistent storage to your cluster, this is for you.
Using persistent volumes
Persistent volumes are requested using PersistentVolumeClaims (PVCs). The PersistentVolumeClaim describes the persistent volume: which type of storage you want, the size of that storage and other such attributes. The actual underlying storage, in our case that is a Fly Volume, is dynamically provisioned from this information.
Here is an example from our docs of creating a PersistentVolume to use in a Pod:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: myclaim
spec:
selector:
matchLabels:
region: iad
storageClassName: flyio-volume
accessModes:
- ReadWriteOncePod
resources:
requests:
storage: 5Gi
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx:latest
volumeMounts:
- mountPath: "/var/www/html"
name: mypd
resources:
limits:
memory: "512Mi"
cpu: "1"
volumes:
- name: mypd
persistentVolumeClaim:
claimName: myclaim
Persistent volumes are built on top of Fly Volumes. Therefore, they come with all the same constraints that Fly Volumes have, mainly: one volume per pod and the pod must be in the same region as the volume.
Generic ephemeral volumes
We’ve taken it a step further and additionally support generic ephemeral volumes. These are volumes that are tied to the lifecycle of your pod. They are created when your Pod is created and deleted when your Pod is deleted. Under the hood, generic ephemeral volumes uses same underlying PVC/PV machinery. Below is an example of using an ephemeral volume with your Pod:
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
image: nginx:latest
volumeMounts:
- mountPath: "/var/www/html"
name: scratch-volume
resources:
limits:
memory: "512Mi"
cpu: "1"
volumes:
- name: scratch-volume
ephemeral:
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOncePod
storageClassName: "flyio-volume"
resources:
requests:
storage: 5Gi
Wrap up
For more details, check out the documentation. Give it a spin and let us know if there are any issues or feedback, we’d love to hear from you!