305-998-7702 | 415-800-2922 info@rx-m.com

Configure Applications with Persistent Storage

Learn how to put the latest open source technology into practice with hands-on training, delivered by industry experts, aligned to your desired business outcomes

The volumes array under a pod manifest and volumeMounts array in a container manifest configure how applications running under Kubernetes use persistent storage.

Entries under the volumes array in a pod manifest declare what storage plugins or objects a pod has available for its containers to use as storage. Certain volume types, PersistentVolumes, PersistentVolumeClaims, ConfigMaps and Secrets are all valid entries under the volumes array. Each volume entry is given a name.

Containers under pods use the volumeMounts array to mount any volumes made available by the pod. The container references the volume by the name configured on the pod level.

The example below shows a pod configured to expose a host directory and the PersistentVolumeClaim example above for its containers to use:

apiVersion: v1
kind: Pod
metadata:
  name: cka-volumes
spec:
  restartPolicy: OnFailure
  containers:
    - name: cka-volumes
      image: alpine
      command:
      - top
      volumeMounts:
      - name: app-logs
        mountPath: /logs
      - name: app-certs
        mountPath: /certs
  volumes:
    - name: app-logs
      persistentVolumeClaim:
        claimName: app-log-pvc
    - name: app-certs
      hostPath:
        path: /etc/ssl/certs

This example uses a PersistentVolumeClaim to store application log data and also mounts a hostPath to use certificates of its host.

Learn more about using persistent storage with your applications on Kubernetes using: