-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix inconsistency in documentation of default storageclass #48200
base: main
Are you sure you want to change the base?
fix inconsistency in documentation of default storageclass #48200
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @iheartNathan! |
✅ Pull request preview available for checkingBuilt without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
must revisit their `StorageClass` objects and mark only one as default. | ||
This admission controller does nothing when no default `StorageClass` exists. When more than one storage | ||
class is marked as default, and you then create a PersistentVolumeClaim with no storageClassName set, | ||
Kubernetes uses the most recently created default StorageClass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this revision is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the behaviour I experienced when I tested on a cluster.
This is expected behaviour mentioned here - https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class-1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By design, storage classes are referenced by a PVC which is dynamically provisioned. If a PVC is not dynamically provisioned, a user don't need to care about storageClassName
, right?
When documenting a feature, please make sure you understand the use case(s) and what
you write here will not cause further confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think a PVC is what's dynamically provisioned, what's dynamically provisioned is a PV from a storageclass by a PVC.
A storageclass may or may not be referenced by a PVC, if it does reference a storageclass a PV is created from the referenced storageclass, if it doesn't it uses a default storageclass to dynamically provision the PV.
If there are more than one default storageclass , and there is no storageclass referenced by the PVC, the PVC uses the more recently created default stroageclass to dynamically provision the PV (this is made possible by the mutating admission controller - DefaultStorageClass)
This is also documented here - https://kubernetes.io/docs/concepts/storage/storage-classes/#default-storageclass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A storageclass may or may not be referenced by a PVC, if it does reference a storageclass a PV is created from the referenced storageclass, if it doesn't it uses a default storageclass to dynamically provision the PV.
The point here that not all PV are dynamically provisioned. A PVC which does not reference any StorageClass still has to be dynamically provisioned? I don't believe so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with #48200 (comment)
The change looks correct to me @tengqm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is partially correct. We have to scope the PVs to those that are dynamically provisioned.
class is marked as default, it rejects any creation of `PersistentVolumeClaim` with an error and an administrator | ||
must revisit their `StorageClass` objects and mark only one as default. | ||
This admission controller does nothing when no default `StorageClass` exists. When more than one storage | ||
class is marked as default, and you then create a PersistentVolumeClaim with no storageClassName set, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit)
class is marked as default, and you then create a PersistentVolumeClaim with no storageClassName set, | |
class is marked as default, and you then create a PersistentVolumeClaim with no `storageClassName` set, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the defaulting at admission time happen even if volumeName
is set? If not, maybe we should mention that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I experienced - the admission controller assigned the most recent class to the PVC, but the PVC was in a pending status until a volume with a name matching the volumeName
on the PVC and the storageClassName
on both the PV and PVC were matching was statically provisioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider this...
I have a PV statically provisioned, and I know its name. Now I'm creating a PVC to bind to that PV. In this PVC, I'm not specifying a storageClassName
but I'm setting the volumeName
to express my intent. This is a pretty valid (and a common) use case.
Now, re-read your revision. Does it still look correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sftim, @tengqm - #48200 (comment) has been included in the revision.
8dbccc7
to
ee39a3a
Compare
ee39a3a
to
55edcdc
Compare
class is marked as default, and you then create a `PersistentVolumeClaim` with no `storageClassName` set, | ||
Kubernetes uses the most recently created default `StorageClass`. | ||
When a `PersistentVolumeClaim` is created with a specified `volumeName`, it remains in a pending state | ||
if the static volume's `storageClassName` does not match the `StorageClass` on the `PersistentVolumeClaim`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if I'm creating a PVC with 'volumeName' specified, but no 'storageClassName'?
The PVC still has to be checked for storage class matching?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the PVC still checks for matching storage class, the below show the events on a PVC with a specified volumeName
that has been mutated by the DefaultStroageClass
admission controller.
controlplane $ k describe pvc pvc-nginx
Name: pvc-nginx
Namespace: default
StorageClass: nfs-csi
Status: Pending
Volume: pv-nginx
Labels: <none>
Annotations: <none>
Finalizers: [kubernetes.io/pvc-protection]
Capacity: 0
Access Modes:
VolumeMode: Filesystem
Used By: nginx-nfs-example
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning VolumeMismatch 3s (x3 over 23s) persistentvolume-controller Cannot bind to requested volume "pv-nginx": storageClassName does not match
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean ... remove the 'storageClassName' from the PVC, setting only 'volumeName'.
Will this binding succeed? I guess so.
The admission controller has nothing to check for this PVC, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The admission controller may backfill the storage class for the PVC when the binding is a success. But that is a different topic. The PVC will not be pending for storage class matching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remove the storageClass
from the PVC, setting only volumeName
, the spec is immutable after creation.
As long as here is at least one storage class setup as default, here is also no way to create a PVC without a storageClass
, the admission controller is always on the look out for PVC without one specified to mutate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remove the
storageClass
from the PVC, setting onlyvolumeName
, the spec is immutable after creation.
Immutable should be fine.
As long as here is at least one storage class setup as default, here is also no way to create a PVC without a
storageClass
, the admission controller is always on the look out for PVC without one specified to mutate it.
This is a surprise for me. Maybe we need to consult SIG Storage for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed this at sig storage triage today. The intended behavior is that if you set storageClassName
to nil and there is a default storageclass set, then storageClassName
will be set with the default storageclass.
If you specifically don't want a default storageclass to be set, then you need to set storageClassName
to empty string.
There is a bug with the "retroactive default storageclass" feature though where it's not following this intended behavior, but I don't think we're discussing the retroactive scenario here (ie default storageclass gets configured after the PVC is created)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question is this, @msau42:
If I am creating a PVC in a cluster, and the cluster has a default storage class.
I'm not specifying storageClassName
in my PVC spec, and I'm only specifying volumeName
, can the PVC be created?
Right. I can understand that the PVC may and may not receive a storageClassName
after creation, but that is a different topic.
Description
fixes this issue
Issue
Closes: #42288