storage

I’m sure there are better ways to do storage, but this my lab is pretty limited.

storageClass

First a storageClass is created. persistentVolumes will use this storageClass.

The following configuration can be saves as local-data.yml and applied with kubectl apply -f local-data.yml.

---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: local-data
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer

persistentVolumes

Create a persistentVolume on each of the worker nodes. I guess I need 1 pv per persistentVolumeClaim?

This config creates 3 PVs, one for each node I plan on creating.

---

apiVersion: v1
kind: PersistentVolume
metadata:
  name: local-elasticsearch1
spec:
  capacity:
    storage: 200Gi
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-data
  local:
    path: /data/elasticsearch1
  nodeAffinity:
    required:
      nodeSelectorTerms:
        - matchExpressions:
          - key: kubernetes.io/hostname
            operator: In
            values:
            - caladan
            - synchrony

---

apiVersion: v1
kind: PersistentVolume
metadata:
  name: local-elasticsearch2
spec:
  capacity:
    storage: 200Gi
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-data
  local:
    path: /data/elasticsearch2
  nodeAffinity:
    required:
      nodeSelectorTerms:
        - matchExpressions:
          - key: kubernetes.io/hostname
            operator: In
            values:
            - caladan
            - synchrony

---

apiVersion: v1
kind: PersistentVolume
metadata:
  name: local-elasticsearch3
spec:
  capacity:
    storage: 200Gi
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-data
  local:
    path: /data/elasticsearch3
  nodeAffinity:
    required:
      nodeSelectorTerms:
        - matchExpressions:
          - key: kubernetes.io/hostname
            operator: In
            values:
            - caladan
            - synchrony

retain

Because of persistentVolumeReclaimPolicy: Retain the data won’t be deleted even when the pv is deleted. Because of this, the stuff on the drive should be deleted manually, or new directories should be created/configured for the data.