Coming soon! This product is currently available only in a closed trial. Click here to stay informed on when it will go live and to receive more updates.
Persistent Volumes in Kubernetes allow the operators to store data outside the Pods that will be persistent across updates or reboot. It also allows these Persistent Volumes to be mounted on multiple pods.
See the official Kubernetes documentation on Persistent Volumes for more information.
Contents
Using Kubernetes Persistent Volumes
In order to use Persistent Volumes, you must declare a PersistentVolumeClaim in order to request some space.
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: example-pvc spec: storageClassName: cloudstack-custom accessModes: - ReadWriteOnce resources: requests: storage: 1Gi
The only part which is special here is "
cloudstack-custom"
which is a pre-defined storage class declared by Leaseweb when we have provisioned your cluster.
The other interesting part is the spec.resources.requests.storage which requests exactly 1 Gi for the volume, which allows choosing the specific size you desire for that volume.Then, to use this PersistentVolume in a container, you can use the PersistentVolume's name to specify in your Pod, such as :
apiVersion: v1 kind: Pod metadata: name: example-pod spec: containers: - name: example image: busybox volumeMounts: - mountPath: "/data" name: example-volume stdin: true stdinOnce: true tty: true volumes: - name: example-volume persistentVolumeClaim: claimName: example-pvc
- Once you have applied both of these configurations using
kubectl apply -f
, a new pod will be added, and the volume will be mounted under /data.
Relevant documentation about Kubernetes Persistent Volumes
Topic | Links |
---|---|
Persistent Volumes | https://kubernetes.io/docs/concepts/storage/persistent-volumes/ |
Volumes | https://kubernetes.io/docs/concepts/storage/volumes/ |