-
Notifications
You must be signed in to change notification settings - Fork 40.3k
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
add lease endpoint reconciler #51698
add lease endpoint reconciler #51698
Conversation
Hi @rphillips. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@rphillips Could you describe which files are equal to OpenShift's and which lines/files you added/edited to make it easier to review? |
/ok-to-test |
pkg/master/master.go
Outdated
ttl := c.MasterEndpointReconcileTTL | ||
config, err := c.StorageFactory.NewConfig(kapi.Resource("apiServerIPInfo")) | ||
if err != nil { | ||
glog.Fatalf("Error determining service IP ranges: %v", err) |
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 this an acceptable pattern to exit the application at this point instead of returning an error?
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 think so. It is during config setup
@lpabon The OpenShift files are marked with their original location. Everything else is written or generated for this PR |
/release-note-none |
/test pull-kubernetes-unit |
/release-note |
a462c9c
to
1c9ec47
Compare
pkg/master/master.go
Outdated
func (c *Config) createEndpointReconciler() EndpointReconciler { | ||
glog.Infof("Using reconciler: %v", c.EndpointReconcilerType) | ||
switch c.EndpointReconcilerType { | ||
case "": |
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 option to disable the reconciler, would be useful for people who use self-hosted k8s.
Then they can just create a kubernetes
service which use selector.
See: kubernetes/community#939 (comment) and kubernetes/community#939 (comment)
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 added a none
reconciler to not do anything on the reconcile loop.
/test pull-kubernetes-e2e-gce-bazel |
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 haven't yet reviewed the code that you're upstreaming from openshift.
@@ -164,6 +166,9 @@ func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet) { | |||
fs.IntVar(&s.MasterCount, "apiserver-count", s.MasterCount, | |||
"The number of apiservers running in the cluster, must be a positive number.") | |||
|
|||
fs.StringVar(&s.EndpointReconcilerType, "alpha-endpoint-reconciler-type", "master-count", |
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.
Default should be s.EndpointReconcilerType
, and that should be initialized properly (look for where other defaults are set).
Description must clearly specify what the options are.
AllowPrivileged: false, | ||
ServiceNodePortRange: DefaultServiceNodePortRange, | ||
MasterCount: 5, | ||
EndpointReconcilerType: "master-count", |
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.
Make a type and constants for this rather than write the string everywhere.
pkg/election/doc.go
Outdated
limitations under the License. | ||
*/ | ||
|
||
// Package election provides objects for managing the list of active masters via leases. |
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.
Please make this a sub-directory under pkg/master/
Also, add a disclaimer here that this is not the intended way for any apiserver other than kube-apiserver to accomplish this task.
pkg/master/master.go
Outdated
|
||
const ( | ||
// DefaultMasterCountReconciler will select the original reconciler | ||
MasterCountReconciler = "master-count" |
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.
Oh, you already have these constants! give them a type and use them everywhere. :)
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.
(you may need to put them in a more visible place)
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.
Probably should make them CamelCase to be consistent with other constants for type
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 problem was the circular dependency it caused, but I'll look into it.
pkg/master/master.go
Outdated
@@ -155,6 +180,58 @@ type completedConfig struct { | |||
*Config | |||
} | |||
|
|||
func (c *Config) createMasterCountReconciler() EndpointReconciler { |
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 adding a "reconcilers.go" file to collect these?
pkg/master/master.go
Outdated
switch c.EndpointReconcilerType { | ||
case "": | ||
fallthrough | ||
case MasterCountReconciler: |
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.
case "", MasterCountReconciler:
is more concise.
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.
But consider rejecting ""
as a flag value on start up.
pkg/master/master.go
Outdated
case NoneEndpointReconciler: | ||
return c.createNoneReconciler() | ||
default: | ||
glog.Fatalf("Reconciler not implemented: %v", c.EndpointReconcilerType) |
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.
%q
pkg/master/master.go
Outdated
StorageConfig: endpointConfig, | ||
Decorator: generic.UndecoratedStorage, | ||
DeleteCollectionWorkers: 0, | ||
ResourcePrefix: c.StorageFactory.ResourcePrefix(kapi.Resource("endpoints")), |
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 would use something that clearly won't collide with the endpoints api. "kube-apiserver-endpoint"
?
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.
@ncdc I don't remember whether there was a reason we didn't do that before?
@ncdc since you're the original author if you want to review |
@rphillips Was there a specific aspect you thought I should look at? This just changes how Endpoints is populated for the apiserver? This needs a better release note. See kubernetes/community#484 for guidance. |
rebased |
/test pull-kubernetes-federation-e2e-gce |
/lgtm But we need to @kubernetes/sig-release-feature-requests to approve this if the intent is still to deliver for 1.8. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rphillips, smarterclayton Associated issue: 939 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/retest Review the full test history for this PR. |
1 similar comment
/retest Review the full test history for this PR. |
Automatic merge from submit-queue (batch tested with PRs 52240, 48145, 52220, 51698, 51777). If you want to cherry-pick this change to another branch, please follow the instructions here.. |
Great to see this. Thanks! I think user-facing documentation about the problem and the reconcilers would be useful? Maybe in https://kubernetes.io/docs/admin/high-availability/? Happy to open a PR if it makes sense. |
@alexbrand An user-facing docs PR for this would make sense to me 👍 @rphillips Please graduate this to beta in v1.10 and add e2e tests #57617 |
@luxas FYI, this has been documented kubernetes/website#6695. |
Great! Thanks @tengqm! |
@tengqm I've been on vacation. thanks! |
When a cluster is bootstrapped with multiple kube-apiservers, the `kubernetes` service contains a list of all of these endpoints. By default, this list of endpoints will *not* be updated if one of the apiservers goes down. This can lead to the api becoming unresponsive and breaking it. To have the endpoints automatically keep track of the apiservers that are available the `--endpoint-reconciler-type` option `lease` needs to be added. (The default option for 1.10 `master-count` only changes the endpoint when the count changes: https://github.com/apprenda/kismatic/issues/987) See: kubernetes/kubernetes#22609 kubernetes/kubernetes#56584 kubernetes/kubernetes#51698
When a cluster is bootstrapped with multiple kube-apiservers, the `kubernetes` service contains a list of all of these endpoints. By default, this list of endpoints will *not* be updated if one of the apiservers goes down. This can lead to the api becoming unresponsive and breaking it. To have the endpoints automatically keep track of the apiservers that are available the `--endpoint-reconciler-type` option `lease` needs to be added. (The default option for 1.10 `master-count` only changes the endpoint when the count changes: https://github.com/apprenda/kismatic/issues/987) See: kubernetes/kubernetes#22609 kubernetes/kubernetes#56584 kubernetes/kubernetes#51698
When a cluster is bootstrapped with multiple kube-apiservers, the `kubernetes` service contains a list of all of these endpoints. By default, this list of endpoints will *not* be updated if one of the apiservers goes down. This can lead to the api becoming unresponsive and breaking it. To have the endpoints automatically keep track of the apiservers that are available the `--endpoint-reconciler-type` option `lease` needs to be added. (The default option for 1.10 `master-count` only changes the endpoint when the count changes: https://github.com/apprenda/kismatic/issues/987) See: kubernetes/kubernetes#22609 kubernetes/kubernetes#56584 kubernetes/kubernetes#51698
What this PR does / why we need it: Adds OpenShift's LeaseEndpointReconciler to register kube-apiserver endpoints within the storage registry.
Adds a command-line argument
alpha-endpoint-reconciler-type
to the kube-apiserver.Defaults to the old MasterCount reconciler.
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes kubernetes/community#939 fixes #22609Release note:
/cc @lavalamp @smarterclayton @ncdc