-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Introduce controller aliases for KCM and CCM #115813
Conversation
staging/src/k8s.io/cloud-provider/app/names/controller_names.go
Outdated
Show resolved
Hide resolved
e53f1ca
to
0182918
Compare
@@ -3,6 +3,7 @@ rules: | |||
allowedPrefixes: | |||
- k8s.io/kubernetes/cmd/kube-controller-manager/app/options | |||
- k8s.io/kubernetes/cmd/kube-controller-manager/app/config | |||
- k8s.io/kubernetes/cmd/kube-controller-manager/app/names |
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.
For nodeipam controller. Should be safe.
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.
|
||
import cpnames "k8s.io/cloud-provider/app/names" | ||
|
||
// canonical controller names |
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.
can this explain where these names are used (command-line invocations, events, contextual logging...?), and the policy around changing them (I think the policy will be "don't")
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.
good idea, I have added a documentation for these names inside both of the names packages
staging/src/k8s.io/cloud-provider/app/names/controller_names.go
Outdated
Show resolved
Hide resolved
cmd/cloud-controller-manager/main.go
Outdated
// "node-controller" is the shared identity of all node controllers, including node, node lifecycle, and node ipam. | ||
// See https://github.com/kubernetes/kubernetes/pull/72764#issuecomment-453300990 for more context. | ||
InitContext: app.ControllerInitContext{ | ||
ClientName: "node-controller", | ||
}, | ||
Constructor: nodeIpamController.StartNodeIpamControllerWrapper, | ||
} | ||
controllerAliases["nodeipam"] = kcmnames.NodeIpamControllerName |
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.
it's a little strange to use the kcmnames.NodeIpamControllerName for the name but define the alias locally here
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 thought about this in a way that the old name belonged to CCM when the aliases did not exist yet. Theoretically it could have been a different name from KCM.
- due to import restrictions I am not defining it in CCMControllerAliases
- all the nodeipam controller relevant bits are in CCM
main
package so it is in a relevant place
I suppose I could also import and use the KCMControllerAliases, if we don't want to have a lonely string around.
cmd/cloud-controller-manager/main.go
Outdated
"k8s.io/cloud-provider/options" | ||
"k8s.io/component-base/cli" | ||
cliflag "k8s.io/component-base/cli/flag" | ||
_ "k8s.io/component-base/metrics/prometheus/clientgo" // load all the prometheus client-go plugins | ||
_ "k8s.io/component-base/metrics/prometheus/version" // for version metric registration | ||
"k8s.io/klog/v2" | ||
kcmnames "k8s.io/kubernetes/cmd/kube-controller-manager/app/names" |
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 pretty sure we don't want references to k8s.io/kubernetes/cmd/kube-controller-manager
from cloud-controller-manager... should the nodeipam name be in k8s.io/cloud-provider/app/names instead?
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 like to have the controller name defined in the same place/module where the controller lives. And the nodeipam controller lives in KCM and is imported by CCM
kubernetes/cmd/cloud-controller-manager/nodeipamcontroller.go
Lines 37 to 39 in 894cfdf
nodeipamcontrolleroptions "k8s.io/kubernetes/cmd/kube-controller-manager/app/options" | |
nodeipamcontroller "k8s.io/kubernetes/pkg/controller/nodeipam" | |
nodeipamconfig "k8s.io/kubernetes/pkg/controller/nodeipam/config" |
KCM imports CCM controllers/options/names as well. We prevent circular dependency by choosing the relevant packages for nodeipam controller and only importing them in the main
package of CCM
- k8s.io/kubernetes/cmd/kube-controller-manager/app/options |
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 really sure if anyone uses CCM from K/K. It seems that it was some step in Cloud Provider Extraction/Migration that is not-used anymore.
@cheftako and @nckturner, do you know the exact context about this CCM implementation and if anyone uses 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.
No one (afaik) uses the cloud-controller-manager binary thats built from the cmd/cloud-controller-manager
, but everyone uses the cloud-provider library in staging.
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.
Do we want to deprecate or remove the support for the binary and the relevant code in parallel with this PR?
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, we can propose it in a PR.
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 proposing a deprecation in #117564 - more details in the PR.
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.
So are we OK with this because it is going away?
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.
Some extra content: cmd/cloud-controller-manager previously stays as an example for new incoming cloud providers. Do we still plan to have a way to educate the incoming cloud provider if this is 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.
Please correct me if I am wrong, but I do not see an issue with the imports as I mentioned in the earlier comment, even if the example CCM does not go away.
We can start with the deprecation and have some time to discuss where to move it before the removal. We can also keep the README in cmd/cloud-controller-manager and reference the new location after that.
// 1. use of shortcuts should be avoided | ||
// 2. kubernetes resources should be written together without a dash ("-") | ||
const ( | ||
ServiceAccountTokenControllerName = "serviceaccount-token-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.
nit: is it stuttery to end every constant with Name
when we're already in a package called names
?
can we do anything in a unit test to enforce consistency on these names (all lowercase, -
instead of _
, end in -controller
, etc)?
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.
+1 for both
I have updated controllermanager_test
to enforce the consistency via a regex. Should I also limit the length of the controller name as we do in DNS1123 validations? Not sure if that is useful.
} | ||
|
||
func TestControllerNamesDeclaration(t *testing.T) { | ||
declaredControllers := sets.New( |
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.
should this set of all declared controller names live in the names
package?
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 like to keep one source of truth for this set, which would be KnownControllers
. This is just to test that this source is well defined. I do not see a benefit of exposing additional set (source) in the names
package at this moment.
83b9a01
to
033edc2
Compare
attachdetach unit test failed which should not be affected by these changes |
Ideally: add a list of old and new name mappings (adding these to a new page within https://k8s.io/docs/reference/) |
I am not sure if it is necessary to advertise these mappings that much (as a new page). Can we rather enhance existing kube-controller-manager page and inject a note there mentioning the aliases behaviour with a link to 1.26 doc for the old names? (they can be found in the help for Nevertheless I can open a doc PR once this one gets resolved and continue the discussion there. |
Editing the existing (auto generated) page means editing the generator code, which may not be simpler. Of course the help for |
/triage accepted |
1 similar comment
/triage accepted |
d0d4758
to
7f6083f
Compare
manually rebased - needed to fix an error for the tests |
and move the to cloud-provider module
7f6083f
to
85d9339
Compare
observed flake #114852 |
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
LGTM label has been added. Git tree hash: 99586855218ffbf9bb158fb4805c2ea758c5cb68
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: atiratree, soltysh, thockin 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 |
I have opened a followup to this PR #120371 which tries to encapsulate the controllers as suggested by @thockin in #115813 (comment) |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
There are many inconsistencies in the naming of KCM and CCM controllers. We would like to have consistent naming of controllers now when we switch to contextual logging . This is important for
This PR introduces aliases for estabilished controllers like
podgc
. User has two options when specifying--controllers
flag:pod-garbage-collector-controller
podgc
name (alias) which will internally resolve topod-garbage-collector-controller
a followup will look into modifying each controller to pick up the new names for:
running_managed_controllers
metric (ControllerStarted, ControllerStopped)Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
for more details please see this discussion: https://groups.google.com/a/kubernetes.io/g/dev/c/I9l8SSM599s/m/PtzEMIS8BAAJ
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: