Parth Gandhi
Parth Gandhi

Reputation: 351

Creating multiple PV and PVC in same kubernetes namespace

I am trying to create multiple PV and PVC(for each one of the PV) in a single namespace and it is not allowing me to do so. Is this an expected behavior? i am using NFS.

NAME                          CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM                                                 STORAGECLASS   REASON    AGE
nfs-office-tools-service-pv   70Gi       RWX            Retain           Bound       office-tools-service-ns/nfs-office-tools-service-pv   manual                   4d
nfs-perfqa-jenkins-pv         20Gi       RWX            Retain           Available                                                         manual                   8m
nfs-perfqa-pv                 2Gi        RWX            Retain           Bound       perfqa/nfs-perfqa-pvc         

                    manual                   17d

When i create a new PVC for the newly created PV, it is giving error as below: enter image description here

Below are the yaml for PV and PVC:

PV.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-perfqa-jenkins-pv
  namespace: perfqa
spec:
  storageClassName: manual
  capacity:
    storage: 20Gi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/nfs_share/docker/test/jenkins"

PVC.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nfs-perfqa-jenkins-pvc
  namespace: default
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 20Gi

Upvotes: 1

Views: 5579

Answers (2)

Shashank V
Shashank V

Reputation: 11193

Your cluster has ResourceQuota or LimitRange with requests.storage set to 2Gi. So you cannot create PVC with 20Gi.

Upvotes: 2

P Ekambaram
P Ekambaram

Reputation: 17621

First of all note that persistent volume is defined at cluster level. it is not defined at namespace level.

correct pv definition as below

apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-perfqa-jenkins-pv
spec:
  storageClassName: manual
  capacity:
    storage: 20Gi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/nfs_share/docker/test/jenkins"

There is no issue with pv. it is created and is available

nfs-perfqa-jenkins-pv         20Gi       RWX            Retain           Available

also check for resourceQuota in default namespace. You might have set max storage limit to 2GB

Upvotes: 0

Related Questions