This was discussed by k8s maintainers in https://github.com/kubernetes/kubernetes/issues/7438#issuecomment-97148195:
Allowing users to ask f
I don't think @jayme's edit to the original answer is forward compatible.
Though only documented as proposal, label selectors in PVCs seem to work with Kubernetes 1.3.0.
I've written an example that defines two volumes that are identical except in labels
. Both would satisfy any of the claims, but when claims specify
selector:
matchLabels:
id: test2
it is evident that one of the dependent pods won't start, and the test1 PV stays unbound.
Can be tested in for example minikube with:
$ kubectl create -f volumetest.yml
$ sleep 5
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
volumetest1 1/1 Running 0 8m
volumetest1-conflict 0/1 Pending 0 8m
$ kubectl get pv
NAME CAPACITY ACCESSMODES STATUS CLAIM REASON AGE
pv1 1Gi RWO Available 8m
pv2 1Gi RWO Bound default/test 8m