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

🌱 sync defined machine labels to node #11650

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ykakarap
Copy link
Contributor

@ykakarap ykakarap commented Jan 7, 2025

What this PR does / why we need it:

Add an flag to the CAPI manager to dictate the labels that should be synced form the Machine to the node. If the flag is not specified it defaults to:

Has node-role.kubernetes.io as prefix.
Belongs to node-restriction.kubernetes.io domain.
Belongs to node.cluster.x-k8s.io domain.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #11657

/area machine

@k8s-ci-robot k8s-ci-robot added area/machine Issues or PRs related to machine lifecycle management do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 7, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign neolit123 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 7, 2025
@ykakarap ykakarap force-pushed the sync-machine-labels branch from df52d4f to cb79cc3 Compare January 7, 2025 22:29
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 7, 2025
@ykakarap ykakarap force-pushed the sync-machine-labels branch from cb79cc3 to 2d97f8a Compare January 7, 2025 22:52
main.go Outdated Show resolved Hide resolved
@ykakarap ykakarap force-pushed the sync-machine-labels branch from 2d97f8a to 5ff55f6 Compare January 7, 2025 23:06
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 7, 2025
@ykakarap ykakarap changed the title [WIP] 🌱 sync machine labels 🌱 sync machine labels Jan 7, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 7, 2025
@ykakarap ykakarap changed the title 🌱 sync machine labels 🌱 sync machine labels to node Jan 7, 2025
@ykakarap ykakarap changed the title 🌱 sync machine labels to node 🌱 sync defined machine labels to node Jan 7, 2025
main.go Outdated
@@ -254,6 +255,14 @@ func InitFlags(fs *pflag.FlagSet) {
"Use deprecated infrastructure machine naming")
_ = fs.MarkDeprecated("use-deprecated-infra-machine-naming", "This flag will be removed in v1.9.")

fs.StringArrayVar(&syncMachineLabels, "sync-machine-labels", []string{
"node-role.kubernetes.io",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a use case to disable these ones? i.e should the flag always be additive over the core ones supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have a strong preference i this case. From the original proposal it looks like the default labels were chosen because the they were identified as the recommended set of labels to sync down.
I am +1 if we should do additive to default list.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we know if some users might prefer a more granular setup and have different labels for different clusters?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's give sane defaults, if users want to disable or only allow a subnet, it should be an open choice imo

@enxebre
Copy link
Member

enxebre commented Jan 8, 2025

Thanks! let's please make sure to add a counter part issue and update the original proposal https://github.com/kubernetes-sigs/cluster-api/blob/12cd150d55330e04b2639396469786a6020a5b82/docs/proposals/20220927-label-sync-between-machine-and-nodes.md

@ykakarap
Copy link
Contributor Author

ykakarap commented Jan 8, 2025

TODO:

  • Update CAPI Book
  • Update the proposal
  • Create issue

@nrb
Copy link
Contributor

nrb commented Jan 9, 2025

Thanks for this!

Something that would be useful here is some sort of wildcard support, in case administrators would like all labels propagated.

@vincepri
Copy link
Member

vincepri commented Jan 9, 2025

Something that would be useful here is some sort of wildcard support, in case administrators would like all labels propagated.

This is supported by setting *

https://github.com/kubernetes-sigs/cluster-api/pull/11650/files#diff-d4d6212206abc46c562f8e0ede7e3c6aa9b87390648a7f25ad96699446b1c525R761-R766

@ykakarap ykakarap force-pushed the sync-machine-labels branch from 5ff55f6 to 804d45d Compare January 9, 2025 21:52
@k8s-ci-robot
Copy link
Contributor

@ykakarap: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-apidiff-main 804d45d link false /test pull-cluster-api-apidiff-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/machine Issues or PRs related to machine lifecycle management cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide configuration to allow users to define their own prefixes to sync labels from Machines to Nodes
6 participants