Skip to content

Instantly share code, notes, and snippets.

@vishnuhd
Last active August 20, 2019 09:00
Show Gist options
  • Save vishnuhd/d3ace0359974f23fa9ae3ec167384c0e to your computer and use it in GitHub Desktop.
Save vishnuhd/d3ace0359974f23fa9ae3ec167384c0e to your computer and use it in GitHub Desktop.
To create a persistent volume on local hard drive with docker-desktop

StorageClass

apiVersion: storage.k8s.io/v1beta1
kind: StorageClass
metadata:
  name: localstorage
provisioner: docker.io/hostpath

PV

apiVersion: v1
kind: PersistentVolume
metadata:
  name: localpv
  labels:
    type: local
spec:
  storageClassName: localstorage
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    # this is the path on laptop?
    path: "/tmp"

PVC

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  labels:
    app: app
  name: localpvc
spec:
  storageClassName: localstorage
  accessModes:
    - ReadWriteOnce
    - ReadOnlyMany
  resources:
    requests:
      storage: 2Gi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment