-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
[Federation][kubefed]: Use StorageClassName for etcd pvc #46323
[Federation][kubefed]: Use StorageClassName for etcd pvc #46323
Conversation
417aaf9
to
50c091d
Compare
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.
Couple of questions
@@ -159,6 +160,7 @@ func (o *initFederationOptions) Bind(flags *pflag.FlagSet, defaultServerImage, d | |||
flags.StringVar(&o.dnsProviderConfig, "dns-provider-config", "", "Config file path on local file system for configuring DNS provider.") | |||
flags.StringVar(&o.etcdImage, "etcd-image", defaultEtcdImage, "Image to use for etcd server.") | |||
flags.StringVar(&o.etcdPVCapacity, "etcd-pv-capacity", "10Gi", "Size of persistent volume claim to be used for etcd.") | |||
flags.StringVar(&o.etcdPVStorageClass, "etcd-pv-storage-class", "", "The storage class of the persistent volume claim used for etcd. Must be provided if a default storage class is not enabled for the host cluster.") |
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 a change in behavior from the alpha annotation, and I want to make sure you're aware and making the decision consciously: If a user runs without specifying etcd-pv-storage-class
and their cluster doesn't have a default storage class installed this will result in the PVC not provisioning a new volume and instead waiting to bind to an existing PV, whereas the alpha annotation always provisioned a new volume.
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, I'm aware of that change, and I'm looking for feedback from someone on the federation side as to whether that is acceptable. For openshift it's an essential change since support for the alpha annotation has already been removed.
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 think it is fine. We need to get rid of the alpha annotation at some point or we will be forced to do it anyway.
federation/pkg/kubefed/init/init.go
Outdated
capacity, err := resource.ParseQuantity(etcdPVCapacity) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
annotations := map[string]string{federation.FederationNameAnnotation: federationName} | ||
if len(etcdPVStorageClass) > 0 { | ||
annotations["volume.beta.kubernetes.io/storage-class"] = etcdPVStorageClass |
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.
Is there anyway to change this behavior based on k8s cluster version?
- k8s.version >= 1.6
- Use GA storageClass field
- k8s.version >= 1.4 && k8s.version < 1.6
- Use beta annotation
- k8s.version >= 1.2 && k8s.version < 1.4
- Use alpha annotation
- k8s.version < 1.2
- Unsupported
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.
@liggitt made the comment that since federation doesn't currently support version skew, it should really be using whichever mechanism is current (i.e. stable field for >= 1.6). I'll update the PR accordingly.
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 very different than the version skew conversation we are having right now. The current conversation is about the skew between the cluster versions and the federation control plane version. This conversation is about hosting the federation control plane. The answers to these two could be very different.
It seems odd to me that we are now going to say that users can't host federation control plane in clusters older than 1.6 using kubefed while they could with kubefed 1.5 and 1.6. I don't feel too strongly about it, but in the absence of a well defined version skew statement, I would rather be liberal and use the beta annotation to accommodate 1.5 clusters. We don't have to worry about clusters older than 1.5 since kubefed did not even exist before then.
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.
LGTM once @saad-ali's comments are addressed
50c091d
to
2c886e9
Compare
I've revised the PR to use the stable field instead of an annotation. I'd appreciate feedback as to whether it is acceptable to require users to specify a storage class if a default is not provided for the host cluster. Given that this will be the behavior going forward, this change would appear necessary in the future if not now. |
It sounds like you understand the implications of this change, so the change LGTM as long as federation folks are ok with it. |
@@ -662,6 +669,7 @@ func createPVC(clientset client.Interface, namespace, svcName, federationName, e | |||
api.ResourceStorage: capacity, | |||
}, | |||
}, | |||
StorageClassName: storageClassName, |
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.
Better to not set this field, if none is specified by user, so that DefaultStorageClass
is used.
Here is note from the documentation in https://kubernetes.io/docs/concepts/storage/persistent-volumes/#storageclasses
-
Do not use
volume.beta.kubernetes.io/storage-class
: with any value including the empty string since it will prevent DefaultStorageClass admission controller from running if enabled. -
In the future, we expect most clusters to have DefaultStorageClass enabled, and to have some form of storage available. However, there may not be any storage class names which work on all clusters, so continue to not set one by default. At some point, the alpha annotation will cease to have meaning, but the unset storageClass field on the PVC will have the desired effect.
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'm not sure what your concern is. Isn't assigning a field a value of nil effectively the same as not setting the field?
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.
LGTM. I overlooked above if condition.
@k8s-bot pull-kubernetes-federation-e2e-gce test this |
/approve Reviewed 3 of 3 files at r1. Comments from Reviewable |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: madhusudancs, marun, shashidharatd
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
@k8s-bot pull-kubernetes-e2e-gce-etcd3 test this |
Automatic merge from submit-queue (batch tested with PRs 46686, 45049, 46323, 45708, 46487) |
This PR updates kubefed to use the StorageClassName field added in 1.6 for etcd's pvc to allow the user to specify which storage class they want to use. If no value is provided to
kubefed init
, the field will not be set, and initialization of the pvc may fail on a cluster without a default storage class configured.The alpha annotation that was previously used (
volume.alpha.kubernetes.io/storage-class
) was deprecated as of 1.4 according to the following blog post:http://blog.kubernetes.io/2016/10/dynamic-provisioning-and-storage-in-kubernetes.html
Release note:
cc: @kubernetes/sig-federation-pr-reviews