Recently, I installed the k8s via kubeadm init
on my CentOS7 clusters. Unfortunately, I suffered a lots of problems. The biggest problem is "How to create a dynamic local storage/volume for automatically assign PVs for PVCs?"
Q: Why local storage not cloud storage service?
A: This is a limitation of new lab of my university.
Problem description:
The k8s(v1.18.0) did not create a default storage class for me after the installing process successfully. I not sure about that whether the situation normally. However, when I install my first application, JupyterHub, on k8s, I got error from it because it could found a suitable PV to fit a PVC hub-db-dir
. And then I attempt to manually a local storage class and a PV such below:
local-storage.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
hub-db-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: hub-db-pv
namespace: jhub
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-storage
local:
path: /home/k8s_data_dir/jhub_dir
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- node1
- node2
- node3
- node4
The JupyterHub work after I apply these yaml
files. I thought that will success to use JupyterHub. But I so naive. I enter the main page of JupyterHub then failure to running, because the JupyterHub create a new PVC for me but it could not bound a suitable PV.
I guess that the error cause by my local storage class which unable to auto create a PV to fit a PVC. Then I try to use an external provisioner sig-storage-lib-external-provisioner
but it can not fix my problem of local storage. (I according to the tutorial of sig-storage-lib-external-provisioner
to do.)
So, my questions are:
Finally, I honest to thank you for your help!
High level steps to achieve dynamic PV creation using local-storage
StorageClass
From the docs here on how to manage local volumes in your Kubernetes cluster.
Prepare and set up local volumes in discovery directory
Next from the docs here