Skip to content
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

Merged

Conversation

roycaihw
Copy link
Member

@roycaihw roycaihw commented Oct 9, 2020

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?:

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [KEP]: https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/1965-kube-apiserver-identity/README.md

/assign @caesarxuchao @deads2k
/sig api-machinery
/sig node

@k8s-ci-robot k8s-ci-robot added the release-note-none Denotes a PR that doesn't merit a release note. label Oct 9, 2020
@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/node Categorizes an issue or PR as relevant to SIG Node. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 9, 2020
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. labels Oct 9, 2020
@roycaihw roycaihw force-pushed the cleanup/generalize-lease-controller branch from 791109f to 1d92e3f Compare October 9, 2020 01:43
@k8s-ci-robot k8s-ci-robot added the area/dependency Issues or PRs related to dependency changes label Oct 9, 2020
@roycaihw roycaihw force-pushed the cleanup/generalize-lease-controller branch from 1d92e3f to d9ac686 Compare October 9, 2020 18:23
@roycaihw
Copy link
Member Author

roycaihw commented Oct 9, 2020

/retest

@roycaihw roycaihw force-pushed the cleanup/generalize-lease-controller branch from d9ac686 to be85edc Compare October 12, 2020 22:50
@roycaihw
Copy link
Member Author

/cc @cheftako
Is k8s.io/controller-manager a good place to host controllers used by multiple components (kubelet, kube-apiserver)?

@cheftako
Copy link
Member

cheftako commented Oct 13, 2020

/cc Walter Fender
Is k8s.io/controller-manager a good place to host controllers used by multiple components (kubelet, kube-apiserver)?

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.

@roycaihw
Copy link
Member Author

@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 k8s.io/kubernetes/pkg/controller, and move it to staging in future if needed.

@roycaihw roycaihw force-pushed the cleanup/generalize-lease-controller branch from be85edc to 5a017ef Compare October 13, 2020 21:41
@k8s-ci-robot k8s-ci-robot added the sig/apps Categorizes an issue or PR as relevant to SIG Apps. label Oct 13, 2020
@roycaihw
Copy link
Member Author

/retest

@@ -14,15 +14,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package nodelease
package lease
Copy link
Member

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.

Copy link
Member Author

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:

  1. k8s.io/client-go/tools - the behavior is similar to leaderelection (no watch; all replicas run simultaneously)
  2. pkg/util - we do have some utility that spawns goroutine, but it's less related to k8s resources.
  3. 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?

Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Member Author

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

Copy link
Contributor

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.

Copy link
Member Author

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

@caesarxuchao
Copy link
Member

LGTM.

@deads2k
Copy link
Contributor

deads2k commented Oct 21, 2020

/approve

@sttts
Copy link
Contributor

sttts commented Oct 22, 2020

client-go is very strange for a controller.

@roycaihw roycaihw force-pushed the cleanup/generalize-lease-controller branch from 7e8c4bf to 140d1ba Compare October 22, 2020 18:40
@roycaihw roycaihw force-pushed the cleanup/generalize-lease-controller branch from 140d1ba to 4af9198 Compare October 22, 2020 19:01
@roycaihw
Copy link
Member Author

/retest

@sttts sttts added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Oct 23, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Oct 23, 2020
@sttts
Copy link
Contributor

sttts commented Oct 23, 2020

/approve

@deads2k
Copy link
Contributor

deads2k commented Oct 23, 2020

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 23, 2020
@derekwaynecarr
Copy link
Member

kubelet changes look good.

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 23, 2020
@k8s-ci-robot k8s-ci-robot merged commit f20a36f into kubernetes:master Oct 23, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone Oct 23, 2020
@roycaihw
Copy link
Member Author

Thanks for reviewing!

@ingvagabund
Copy link
Contributor

k8s.io/component-helpers/lease is not the right name for the root directory. The convention (although not described in the readme) is to use a team owning the code. E.g. scheduling, auth, etc. In this case, the right name is node and the expected path is k8s.io/component-helpers/node/lease. @deads2k since you were the one that suggested this structure.

@ingvagabund
Copy link
Contributor

Also k8s.io/component-helpers staging repo is for high-level helpers. Node lease controller is not a helper. This PR was not meant to be merged.

@ingvagabund
Copy link
Contributor

@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?

@roycaihw
Copy link
Member Author

roycaihw commented Nov 3, 2020

@ingvagabund Hi, @deads2k @sttts and I discussed offline about #95428 (comment) and we agreed on using component-helpers to host the lease controller. Options we discussed:

  • client-go: strange for hosting a controller (although leader elector is there, which is sort of questionable)
  • component-base: best practices used by all the core components. The lease controller is not as critical, and it's only used by two components (kube-apiserver and kubelet)
  • component-helper: the definition of a helper is unclear. The original proposed name for this repo was library-go, which seemed broader

also from previous discussion in this PR:

  • controller-manager: the lease controller 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. It is more like an implementation of heartbeat for a process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/dependency Issues or PRs related to dependency changes area/kubelet area/release-eng Issues or PRs related to the Release Engineering subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/release Categorizes an issue or PR as relevant to SIG Release. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet