So I have spent far to long trying to mount a local disk into my k8s cluster. My aim is to run pihole on my home system in k8s, primarily to educate me.

So after a night out (maybe with some alcohol) and an old friend John he suggested I look at the latest beta which contains local. He also talked me into buying a server rack from ebay but that is another story.

I have got my head around helm and so I was keen to keep using it. I copied and pasted the pv into my local helm chart.

apiVersion: v1
kind: PersistentVolume
metadata:
   name: }-pv
spec:
  capacity:
  storage: 5Gi
  # volumeMode field requires BlockVolume Alpha feature gate to be enabled.
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Delete
  storageClassName: local-storage
  local:
    path: /mnt/pihole
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
            - example-node

This ran successfully but the pod would not bind with the pvc. After hitting my head against the wall for 30mins, i sat down and read the yaml above.

kubernetes.io/hostname

So i changed example-node to my hostname and it all magically worked!

Moral of the story, read the sample config before you use it.

https://kubernetes.io/docs/concepts/storage/volumes/

kubernetes-incubator/external-storage
external-storage - External storage plugins, provisioners, and helper librariesgithub.com

By Chris Phillips on May 6, 2018.

Canonical link

Exported from Medium on April 6, 2019.