Adding label with description to custom StorageClass

Is it possible to add description label to custom kind: StorageClass?

TL:TR: I have tried number of ways, every time failing with

The StorageClass "azurefile-csi-retain" is invalid: metadata.labels:
  Invalid value: "Custom storage class as azurefile-csi with Retain policy":
    a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.',
    and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345',
    regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')

Here are examples I tried to kubectl apply -f mysc.yaml, none seems accepted by Kubernetes:

---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: azurefile-csi-retain
  labels:
    description: Custom storage class as azurefile-csi with Retain policy

or with well-known label description

    kubernetes.io/description: Custom storage class as azurefile-csi with Retain policy

or with variation of it

    kubernetes.io/description: |-
      Custom storage class as azurefile-csi with Retain policy

or with custom label

    example.com/description: |-
      Custom storage class as azurefile-csi with Retain policy

Eventually, I ended up with the silly

kubernetes.io/description: Custom-storage-class-as-azurefile-csi-with-Retain-policy

Why StorageClass does not accept the multi-word description?
Is this intentional or a bug, and should I report it?

Cluster information:

Kubernetes version: 1.25.5
Cloud being used: AKS
Installation method: AKS

That is intentional for all labels - They are used by the system for specific purposes and have more restrictions on what a value can be.

What you probably want to use is annotations which can be more free-text.

1 Like

Thank you @mrbobbytables for the answer.
I’ve tried your suggestion to use the annotations, a much better choice indeed:

  annotations:
    example.com/base-storage-class: azurefile-csi
    example.com/description: |-
      Custom storage class based on the default azurefile-csi and
      set with Retain as reclaim policy.