Log In

Volume Management

Although containers are ephemeral, there are often cases where data must be persisted so as to not lose any files. Ketch can be used to seamlessly deploy an application that binds to an existing persistent volume to not lose any of this essential data. This is done by attaching a Persistent Volume Claim (PVC) to the Ketch App at a specified directory path.

To learn more about PVC's: Kubernetes Documentation

A bounded PVC must exist prior to deploying an application. In the case that a PVC has been created, you must ensure that a matching volume exists. Ketch will validate the parameters being passed in as well as check that the PVC exists.

Here is a sample manifest:

apiVersion: v1
kind: PersistentVolume
  name: pv-volume-1
    type: local
  storageClassName: manual
    storage: 10Gi
    - ReadWriteOnce
    path: "/mnt/data"
apiVersion: v1
kind: PersistentVolumeClaim
  name: pvc-1
  storageClassName: manual
    - ReadWriteOnce
      storage: 3Gi

Creating an App with Volume Support

The example below illustrates all of the parameters pertaining to mounting a volume as well as Pod Security Policies that can be set.

The volume flag must be set if any of the volume related flags are being used.

ketch app deploy <app-name> -i <image> -k <framework-name> --volume <pvc-name> --volume-mount-path <volume-mount-path> --fs-group <group-id> --volume-mount-options <volume-mount-options> --run-as-user <user-id>
--volumeName of the volume to bind to the application.pvc-1
--volume-mount-pathPath to mount a volume./var/lib/mysql
--fs-groupThe fsGroup for pod's security context; root if not set.1
--volume-mount-optionsOptions for volume mount. (default [])readOnly=true
--run-as-userThe user to use for running pod's processes; root if not set0

Validating Ketch Volume

After the application is deployed, you can verify that the volume exists in the container. In the example below, the pod name is fetched and the ls command is then executed to check if the volume exists.

kubectl describe pods | grep Name
kubectl exec -it <pod-name> -- /bin/bash -c "ls </volume/path>"