Skip to content

Commit

Permalink
Explicitly set the PVC's storageClassName to default
Browse files Browse the repository at this point in the history
In the registry-cache extension we deploy PVCs to the Shoot. We see cases where the PVC and StorageClass creation can be racy. In K8s < 1.26, when the default StorageClass is created after the PVC, the PVC hangs in Pending state with reason `no persistent volumes available for this claim and no storage class is set`. In K8s, there is a feature gate called `RetroactiveDefaultStorageClass` which makes possible the StorageClass from PVC to be set when the PVC is created before the StorageClass. See https://kubernetes.io/docs/concepts/storage/persistent-volumes/#retroactive-default-storageclass-assignment
In the registry-cache extension we decided to hard-code the StorageClass name to `default` for time being. When it is ensured that `RetroactiveDefaultStorageClass` is enabled by default in the supported K8s versions, then we can drop this.
  • Loading branch information
ialidzhikov committed Oct 7, 2023
1 parent 31cdc3c commit 40a6d73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/component/registrycaches/registrycaches.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ func computeResourcesDataForRegistryCache(cache *v1alpha1.RegistryCache, image s
corev1.ResourceStorage: *cache.Size,
},
},
// TODO(ialidzhikov): Currently the PVC and StorageClass creation is racy. If PVC gets created before the StorageClass, then it hangs in Pending state with reason "no persistent volumes available for this claim and no storage class is set".
// There is a K8s feature called RetroactiveDefaultStorageClass that aims to fix the above-described behaviour. See https://kubernetes.io/docs/concepts/storage/persistent-volumes/#retroactive-default-storageclass-assignment.
// Consider dropping this when the extension no longer supports a K8s version where the RetroactiveDefaultStorageClass feature gate is not enabled by default (K8s < 1.26).
StorageClassName: pointer.String("default"),
},
},
},
Expand Down
1 change: 1 addition & 0 deletions pkg/component/registrycaches/registrycaches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ spec:
resources:
requests:
storage: ` + size + `
storageClassName: default
status: {}
status:
availableReplicas: 0
Expand Down

0 comments on commit 40a6d73

Please sign in to comment.