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

🌱 Add --additional-sync-machine-labels to allow syncing additional labels to Nodes #11650

Merged
merged 1 commit into from
Jan 27, 2025

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.

Any value specified by the flag would be additional to the list to default values.

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 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 Show resolved Hide resolved
@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
main.go Outdated Show resolved Hide resolved
docs/book/src/reference/api/metadata-propagation.md Outdated Show resolved Hide resolved
@ykakarap ykakarap force-pushed the sync-machine-labels branch from 0c12e60 to 114bd3a Compare January 15, 2025 18:20
@nrb
Copy link
Contributor

nrb commented Jan 16, 2025

@enxebre An issue was created, #11657.

This PR looks good to me; the documentation is clear, and the use of file path globbing would support my intended use case.

@ykakarap ykakarap force-pushed the sync-machine-labels branch from 3643897 to 3aeb947 Compare January 23, 2025 19:05
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 23, 2025
@ykakarap ykakarap force-pushed the sync-machine-labels branch from 3aeb947 to 272b936 Compare January 23, 2025 19:11
Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

Just a few minor findings

docs/book/src/reference/api/metadata-propagation.md Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@sbueringer sbueringer changed the title 🌱 sync defined machine labels to node 🌱 Add --additional-sync-machine-labels to allow syncing additional labels to Nodes Jan 24, 2025
@ykakarap ykakarap force-pushed the sync-machine-labels branch from 272b936 to 5f8e673 Compare January 24, 2025 22:31
@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 5f8e673 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.

@sbueringer
Copy link
Member

Thx!

/lgtm

/assign @enxebre @nrb @vincepri @fabriziopandini @chrischdi

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 27, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: e8198decdcb51738cdbd4d38b3c9eeb9b0f99f4a

@sbueringer
Copy link
Member

/test pull-cluster-api-e2e-main

@enxebre
Copy link
Member

enxebre commented Jan 27, 2025

/lgtm

@vincepri
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vincepri

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 Jan 27, 2025
@k8s-ci-robot k8s-ci-robot merged commit 819d3f3 into kubernetes-sigs:main Jan 27, 2025
19 of 20 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.10 milestone Jan 27, 2025
@ykakarap
Copy link
Contributor Author

/cherry-pick release-1.9

@k8s-infra-cherrypick-robot

@ykakarap: #11650 failed to apply on top of branch "release-1.9":

Applying: sync machine labels
.git/rebase-apply/patch:74: trailing whitespace.
A default list of labels would always be synced from the Machines to the Nodes. An additional list of labels can be synced from the Machine to the Node by providing a list of regexes as a flag to the manager. 
.git/rebase-apply/patch:84: trailing whitespace.
- [ ] 01/09/2025: Update to support configurable label syncing Ref:[11657](https://github.com/kubernetes-sigs/cluster-api/issues/11657) 
warning: 2 lines add whitespace errors.
Using index info to reconstruct a base tree...
M	controllers/alias.go
M	internal/controllers/machine/machine_controller.go
M	main.go
Falling back to patching base and 3-way merge...
Auto-merging main.go
CONFLICT (content): Merge conflict in main.go
Auto-merging internal/controllers/machine/machine_controller.go
Auto-merging controllers/alias.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 sync machine labels

In response to this:

/cherry-pick release-1.9

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.

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/machine Issues or PRs related to machine lifecycle management cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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
10 participants