Description of problem: Could not use label selector to pvc and pv when there is default storageclass Version-Release number of selected component (if applicable): oc v3.6.121 kubernetes v1.6.1+5115d708d7 features: Basic-Auth GSSAPI Kerberos SPNEGO How reproducible: Always Steps to Reproduce: 1.Check default storageclas [root@ip-172-18-9-120 ~]# oc get storageclass NAME TYPE gp2 (default) kubernetes.io/aws-ebs 2.Create a pv with labels kind: PersistentVolume apiVersion: v1 metadata: name: ebs1 labels: type: local spec: capacity: storage: 1Gi accessModes: - ReadWriteOnce claimRef: name: ebs1 awsElasticBlockStore: volumeID: "aws://us-east-1d/vol-069b4699ba83241a0" fsType: "ext4" 3.Create a pvc { "apiVersion": "v1", "kind": "PersistentVolumeClaim", "metadata": { "name": "ebs1" }, "spec": { "accessModes": [ "ReadWriteOnce" ], "resources": { "requests": { "storage": "1Gi" } }, "selector": { "matchLabels": { "type": "local" } }, "persistentVolumeReclaimPolicy": "Retain" } } [root@ip-172-18-9-120 ~]# oc get pvc NAME STATUS VOLUME CAPACITY ACCESSMODES STORAGECLASS AGE ebs1 Pending gp2 3s [root@ip-172-18-9-120 ~]# oc describe pvc Name: ebs1 Namespace: default StorageClass: gp2 Status: Pending Volume: Labels: <none> Annotations: volume.beta.kubernetes.io/storage-provisioner=kubernetes.io/aws-ebs Capacity: Access Modes: Events: FirstSeen LastSeen Count From SubObjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 15s 14s 2 persistent-volume-controller Warning ProvisioningFailed Failed to provision volume with StorageClass "gp2": claim.Spec.Selector is not supported for dynamic provisioning on AWS Actual results: PV and pvc is not bond Expected results: PV and pvc should bond, there should be a method to avoid default storageclass Master Log: Node Log (of failed PODs): PV Dump: PVC Dump: StorageClass Dump (if StorageClass used by PV/PVC): Additional info:
This is currently expected behavior. Labels, selectors and storage-class are mutually exclusive by design currently. There is RFE to change this behavior in 3.8 (the title is a little off, but the feature is here): https://trello.com/c/lbxSAqUb/406-list-allowed-selectors-in-storageclass-list-allowed-keys13 Closing this bug for now.
When a default storage class is configured, the PVC must explicitly ask for storage class "" via annotation or storageclassname field in order to get bound to PV with blank storage class. This is documented upstream but maybe missing from openshift docs.
We need to document this behavior.
Changes are in PR https://github.com/openshift/openshift-docs/pull/4749
Commit pushed to master at https://github.com/openshift/openshift-docs https://github.com/openshift/openshift-docs/commit/d287bf46653b4c0fe46d291fde5dfc31bb136b74 Merge pull request #4749 from gaurav-nelson/Bug1464036-fixes BZ#1464036-added information about getting a pv with blank storage class
Changes are live at https://docs.openshift.com/container-platform/3.5/architecture/additional_concepts/storage.html#pvc-storage-class