Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

HostPath Storage using Persistent VolumeVolume 

This is the simplest and best approach for bare metal deployments when a network file system is not available. 


Define storage class and make it the default

...

Local Storage using Persistent Volume and ClaimClaim 


We can use disk space on a node by defining a PersistentVolume (see below) and then making a claim against that volume by specifying the storageclass name in the PersistentVolumeClaim.

  • Only one claim can be made against a volume.
  • File path (local.path) must exist for the volume to be usable.
  • USE HOSTPATH STORAGE since it will create the folders for you.


Code Block
apiVersion: v1
kind: PersistentVolume
metadata:
  name: local-storage
spec:
  capacity:
    storage: 10Gi
  # volumeMode field requires BlockVolume Alpha feature gate to be enabled.
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Persist
  storageClassName: local-storage
  local:
    path: /var/k8s/LOCAL_STORAGE
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - k8sworker1
          - k8sworker2
          - k8sworker3
          - docker-for-desktop

...