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
Generalize node lease controller #95428
Generalize node lease controller #95428
Conversation
staging/src/k8s.io/controller-manager/pkg/controllers/lease/controller.go
Outdated
Show resolved
Hide resolved
791109f
to
1d92e3f
Compare
1d92e3f
to
d9ac686
Compare
/retest |
d9ac686
to
be85edc
Compare
/cc @cheftako |
Maybe. I think the critical question is whether we want the relevant controllers to be "public". By "public" I mean do we want the controllers to be run by processes outside of the primary Kubernetes components (Eg aws-controller-manager or gcp-controller-manager) If so then we can talk about it being in either k8s.io/controller-manager or k8s.io/cloud-provider. If no then I think you want to steer clear of putting it anywhere under staging. If its under staging its public and we need to be very aware of things like our backward compatibility and deprecation policies. |
@cheftako That's a good point. I can imagine aggregated apiservers run this controller in future (either import the controller directly, or we make it part of generic apiserver). But currently it's not the goal, we only need it for kube-apiserver and kubelet. For this case, I guess we can just put it under |
be85edc
to
5a017ef
Compare
/retest |
pkg/controller/lease/controller.go
Outdated
@@ -14,15 +14,14 @@ See the License for the specific language governing permissions and | |||
limitations under the License. | |||
*/ | |||
|
|||
package nodelease | |||
package lease |
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.
Putting this under pkg/controller seems confusing. The rest of the controllers under pkg/controller are control plane logic/controller being run by a controller-manager. This seems more like an implementation of heartbeat for a process (Kubelet) than a control plane controller.
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.
That's true. The lease controller is a heartbeat implementation. It is different from control plane controllers in terms of 1. it doesn't watch any resource 2. it doesn't run leader election-- each replica of a component (kubelet) runs the lease controller simultaneously.
The other options I can think of:
- k8s.io/client-go/tools - the behavior is similar to
leaderelection
(no watch; all replicas run simultaneously) - pkg/util - we do have some utility that spawns goroutine, but it's less related to k8s resources.
- or we may create a new in-tree directory (e.g.
pkg/tools
,pkg/client/tools
) to avoid making the existing ones confusing.
@deads2k @caesarxuchao Any suggestions?
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 we are ready to support this library publicly, so I think we can keep it in k8s.io/kubernetes/pkg/client/leasecontroller
.
When we want to make it public, k8s.io/client-go/tools seems to be the most suitable place so far.
Let's see what @deads2k think.
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 trust it for kubelets, so I think we have a good degree of confidence. Because it is related to apiserver handling that would apply to any apiserver, I think it needs to be somewhere public. I think your suggestion of client-go/tools is a good one.
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.
Thanks for the comments. I update the PR to put it under client-go/tools. Please take a look
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 disagree that client-go is the right repo. component-base was invented to have reusable functionality shared by our binaries. Hence, lease controller belongs there.
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.
Component-base hosts code and best practices used by all the core components. This lease controller is not as critical IMO.
On the other hand, the recently created component-helpers hosts helpers required by two or more components, and the definition for a "helper" seems more arbitrary than a "base". I moved the controller to component-helpers. PTAL
LGTM. |
/approve |
client-go is very strange for a controller. |
7e8c4bf
to
140d1ba
Compare
140d1ba
to
4af9198
Compare
/retest |
/approve |
/lgtm |
kubelet changes look good. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, derekwaynecarr, roycaihw, sttts The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thanks for reviewing! |
|
Also |
@roycaihw can you more elaborate on why you moved the code under `k8s.io/component-helpers and why it was done after the PR got mostly approved? |
@ingvagabund Hi, @deads2k @sttts and I discussed offline about #95428 (comment) and we agreed on using
also from previous discussion in this PR:
|
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Split off from #95222 (#95222 (review)). Move nodelease controller to k8s.io/component-helpers and generalize it, so it can be reused for the apiserver lease.
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
/assign @caesarxuchao @deads2k
/sig api-machinery
/sig node