Skip to content

[provisioner] StatefulSet with empty selector are blocked #285

@speedfl

Description

@speedfl

Describe the problem/challenge you have
When creating a Statefulset with a persistent volume claim, kind (and probably other distributions) adds an empty selector to the PersistentVolumeClaim:

Here is the storage class

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    cas.openebs.io/config: |
      - name: StorageType
        value: "hostpath"
      - name: BasePath
        value: "/var/openebs/local"
    meta.helm.sh/release-name: openebs
    meta.helm.sh/release-namespace: openebs
    openebs.io/cas-type: local
  creationTimestamp: "2025-09-26T07:13:30Z"
  labels:
    app.kubernetes.io/managed-by: Helm
  name: openebs-hostpath
  resourceVersion: "709"
  uid: a31abb9c-5f61-4145-ae31-8a683122022a
provisioner: openebs.io/local
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer

The StatefulSet with volumeClaimTemplate:

spec:
  volumeClaimTemplate:
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 10Gi
      storageClassName: openebs-hostpath

The created PersistentVolumeClaim

spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  selector: {} # Here is the culprit
  storageClassName: openebs-hostpath
  volumeMode: Filesystem

The volume then stay in Pending state. When looking at the logs of the openebs-localpv-provisioner I can see the following:

error syncing claim "f9083653-8bfc-49fa-b700-a60460c1ab8a": failed to provision volume with StorageClass "openebs-hostpath": claim.Spec.Selector is not supported

When creating the PersistentVolumeClaim manually I don't have any issues because I don't set the selector: {}

Describe the solution you'd like
Instead of doing a == nil an empty check must be done

Anything else you would like to add:
With a Kyverno policy it works but it is ugly

Environment:

  • OpenEBS version 4.3.0
  • Kubernetes version (use kubectl version):
Client Version: v1.33.0
Kustomize Version: v5.6.0
Server Version: v1.32.2
  • Cloud provider or hardware configuration:
  • OS (e.g: cat /etc/os-release):
  • kernel (e.g: uname -a):
  • others:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions