1
1
---
2
2
layout : blog
3
- title : " Kubernetes 1 .26: Retroactive Default StorageClass"
3
+ title : " Kubernetes v1 .26: Retroactive Default StorageClass"
4
4
date : 2023-01-05
5
5
slug : retroactive-default-storage-class
6
6
---
@@ -11,7 +11,7 @@ The v1.25 release of Kubernetes introduced an alpha feature to change how a defa
11
11
StorageClass was assigned to a PersistentVolumeClaim (PVC). With the feature enabled,
12
12
you no longer need to create a default StorageClass first and PVC second to assign the
13
13
class. Additionally, any PVCs without a StorageClass assigned can be updated later.
14
- This feature was graduated to beta in Kubernetes 1 .26.
14
+ This feature was graduated to beta in Kubernetes v1 .26.
15
15
16
16
You can read [ retroactive default StorageClass assignment] ( /docs/concepts/storage/persistent-volumes/#retroactive-default-storageclass-assignment )
17
17
in the Kubernetes documentation for more details about how to use that,
@@ -146,23 +146,35 @@ If you would like to see the feature in action and verify it works fine in your
146
146
The PVC won't provision or bind (unless there is an existing, suitable PV already present)
147
147
and will remain in <code>Pending</code> state.
148
148
149
+ ` ` ` shell
150
+ kubectl get pvc
149
151
```
150
- $ kc get pvc
152
+
153
+ The output is similar to this:
154
+ ``` console
151
155
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
152
156
pvc-1 Pending
153
157
```
154
158
155
159
3 . Configure one StorageClass as default.
156
160
161
+ ``` shell
162
+ kubectl patch sc -p ' {"metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
157
163
```
158
- $ kc patch sc -p '{"metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
164
+
165
+ The output is similar to this:
166
+ ``` console
159
167
storageclass.storage.k8s.io/my-storageclass patched
160
168
```
161
169
162
170
4 . Verify that PersistentVolumeClaims is now provisioned correctly and was updated retroactively with new default StorageClass.
163
171
172
+ ``` shell
173
+ kubectl get pvc
164
174
```
165
- $ kc get pvc
175
+
176
+ The output is similar to this:
177
+ ``` console
166
178
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
167
179
pvc-1 Bound pvc-06a964ca-f997-4780-8627-b5c3bf5a87d8 1Gi RWO my-storageclass 87m
168
180
```
0 commit comments