Sun Sep 17
In Kubernetes it is possible to maintain persistent data
-
The core concepts are:
volume classes(vc)persistent volumes(pv) based onvc- persistent volume claims
(pvc) based onpvc.podspecs that specify volumes based onpvc` containerspecs (within pod specs) that specifyvolumeMountsbased onpodvolumes``
-
So each of these is based upon the former until
vchits the raw layer of whatever the kubernetes is hosted upon. -
Since Kubernetes 1.6 it has been possible to create
pvcs directly without needing to first createpvs. This is referred to as dynamic provisioning. link -
More about the concept can be read on the storage docs. The third sub-section just links to a blog post, so incomplete?
-
A blog post going over the topic in an end-to-end example can be found here
-
Another example is [one section on the k8s task-oriented docs
-
Example:
❯ kc get pv NAME CAPACITY ACCESSMODES RECLAIMPOLICY STATUS CLAIM STORAGECLASS REASON AGE pvc-46c2c0df-9c19-11e7-a0d1-0800271d32bc 1Gi RWO Delete Bound default/mypvc standard 47m ❯ kc get pvc NAME STATUS VOLUME CAPACITY ACCESSMODES STORAGECLASS AGE mypvc Bound pvc-46c2c0df-9c19-11e7-a0d1-0800271d32bc 1Gi RWO standard 47m ❯ cat ./deployment.yaml apiVersion: apps/v1beta1 kind: Deployment metadata: name: dgraph labels: app: dgraph spec: # ReplicaSet replicas: 1 template: # Pod metadata: labels: app: dgraph spec: volumes: - name: dgraph persistentVolumeClaim: claimName: mypvc containers: - name: dgraph image: dgraph/dgraph:latest ports: - name: ui containerPort: 8080 - name: client containerPort: 9080 command: - dgraph args: - -bindall=true - -memory_mb=2048 volumeMounts: - name: dgraph mountPath: /dgraph