Error "no persistent volumes available for this claim and no storage class is set"
Back to your main question
Is it required to create the directory manually in nodes or will it be auto created by pv?
First of all, error in your output is not related with your question. As an answer for your question - Yes. It is crated by PV automatically.
In order to do achieve this, first you have to create StorageClass
with no-provisioner
as an example below
kind: StorageClassapiVersion: storage.k8s.io/v1metadata: name: manualprovisioner: kubernetes.io/no-provisionervolumeBindingMode: WaitForFirstConsumer
Then you have to create PersistentVolume
by defining this storageClassName
and hostPath
parameter like below:
apiVersion: v1kind: PersistentVolumemetadata: name: zk1-pvspec: storageClassName: manual capacity: storage: 1Gi accessModes: - ReadWriteOnce hostPath: path: /mr/zk
Then you have to create PVC and Pod/Deployment as an example below:
apiVersion: v1kind: PersistentVolumeClaimmetadata: name: myclaimspec: storageClassName: manual accessModes: - ReadWriteOnce resources: requests: storage: 1Gi---apiVersion: v1kind: Podmetadata: name: mypodspec: containers: - name: containerName image: gcr.io/google-containers/nginx:1.7.9 volumeMounts: - mountPath: "/var/www/html" name: mypd volumes: - name: mypd persistentVolumeClaim: claimName: myclaim
NOTE:
Don't forget put storageClassName: manual
parameter on both PVC and PV manifests. Otherwise they will not be able to bound to each other.
Hope it clears
You forgot to specify storageClassName: manual
in PersistentVolumeClaim
.