Skip to content

Instantly share code, notes, and snippets.

@pjxiao
Created January 16, 2020 02:35
Show Gist options
  • Save pjxiao/afedbf19f33d90c1b989644e3c3c1bec to your computer and use it in GitHub Desktop.
Save pjxiao/afedbf19f33d90c1b989644e3c3c1bec to your computer and use it in GitHub Desktop.
Example: API objects which create a PVC and a bound pre-previsioned PV
---
# Reference: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/#persistentvolume-v1-core
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-test-volume
spec:
storageClassName: dir
capacity:
storage: 256Mi
accessModes:
# ReadWriteOnce: the volume can be mounted as read-write by a single node
# see: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes
- ReadWriteOnce
hostPath:
# see: https://minikube.sigs.k8s.io/docs/reference/persistent_volumes/
path: "/data/pv-test"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pv-test-claim
spec:
# the volume can be mounted as read-write by a single node
# see: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes
accessModes: ["ReadWriteOnce"]
storageClassName: dir # XXX: storageClassName seems required for a claim to bind
resources:
requests:
storage: 256Mi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment