Skip to content

Commit 14882c6

Browse files
authored
Merge pull request #35658 from RomanBednar/retro-sc-assignment-doc
Add article about Retroactive default StorageClass assignement
2 parents 51b647b + 0a4a178 commit 14882c6

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

content/en/docs/concepts/storage/persistent-volumes.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,9 +719,13 @@ is turned on.
719719
more than one default is specified, the admission plugin forbids the creation of
720720
all PVCs.
721721
* If the admission plugin is turned off, there is no notion of a default
722-
StorageClass. All PVCs that have no `storageClassName` can be bound only to PVs that
723-
have no class. In this case, the PVCs that have no `storageClassName` are treated the
724-
same way as PVCs that have their `storageClassName` set to `""`.
722+
StorageClass. All PVCs that have `storageClassName` set to `""` can be
723+
bound only to PVs that have `storageClassName` also set to `""`.
724+
However, PVCs with missing `storageClassName` can be updated later once
725+
default StorageClass becomes available. If the PVC gets updated it will no
726+
longer bind to PVs that have `storageClassName` also set to `""`.
727+
728+
See [retroactive default StorageClass assignment](#retroactive-default-storageclass-assignment) for more details.
725729

726730
Depending on installation method, a default StorageClass may be deployed
727731
to a Kubernetes cluster by addon manager during installation.
@@ -738,6 +742,20 @@ In the past, the annotation `volume.beta.kubernetes.io/storage-class` was used i
738742
of `storageClassName` attribute. This annotation is still working; however,
739743
it won't be supported in a future Kubernetes release.
740744

745+
746+
#### Retroactive default StorageClass assignment
747+
748+
{{< feature-state for_k8s_version="v1.25" state="alpha" >}}
749+
750+
You can create a PersistentVolumeClaim without specifying a `storageClassName` for the new PVC, and you can do so even when no default StorageClass exists in your cluster. In this case, the new PVC creates as you defined it, and the `storageClassName` of that PVC remains unset until default becomes available.
751+
However, if you enable the [`RetroactiveDefaultStorageClass` feature gate](/docs/reference/command-line-tools-reference/feature-gates/) then Kubernetes behaves differently: existing PVCs without `storageClassName` update to use the new default StorageClass.
752+
753+
When a default StorageClass becomes available, the control plane identifies any existing PVCs without `storageClassName`. For the PVCs that either have an empty value for `storageClassName` or do not have this key, the control plane then updates those PVCs to set `storageClassName` to match the new default StorageClass. If you have an existing PVC where the `storageClassName` is `""`, and you configure a default StorageClass, then this PVC will not get updated.
754+
755+
In order to keep binding to PVs with `storageClassName` set to `""` (while a default StorageClass is present), you need to set the `storageClassName` of the associated PVC to `""`.
756+
757+
This behavior helps administrators change default StorageClass by removing the old one first and then creating or setting another one. This brief window while there is no default causes PVCs without `storageClassName` created at that time to not have any default, but due to the retroactive default StorageClass assignment this way of changing defaults is safe.
758+
741759
## Claims As Volumes
742760

743761
Pods access storage by using the claim as a volume. Claims must exist in the same namespace as the Pod using the claim. The cluster finds the claim in the Pod's namespace and uses it to get the PersistentVolume backing the claim. The volume is then mounted to the host and into the Pod.

0 commit comments

Comments
 (0)