Skip to content

✨ Expose ManagedCluster annotations during join via clusteradm flag #481

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

Conversation

arturshadnik
Copy link
Contributor

Summary

This PR adds a new optional flag --klusterlet-annotation to the clusteradm join command. With this flag, users can annotate ManagedClusters during the registration process.

Example usage:

clusteradm join --hub-token <token> \
--hub-apiserver <hub_apiserver_url> \
--cluster-name <cluster_name> \
--klusterlet-annotation key1=value1

Multiple annotations can be set by passing the flag multiple times:

clusteradm join --hub-token <token> \
--hub-apiserver <hub_apiserver_url> \
--cluster-name <cluster_name> \
--klusterlet-annotation key1=value1 \
--klusterlet-annotation key2=value2

Since Klusterlet requires all annotations to have a prefix of agent.open-cluster-management.io, the command is set up to automatically prefix any key which does not have it. This will simplify the command for end-users. Both of the following uses are valid and will result in the same outcome:

--klusterlet-annotation key1=value1
--klusterlet-annotation agent.open-cluster-management.io/key1=value1
kubectl get managedclusters cluster1 -o yaml --context kind-clusteradm-e2e-test-hub | grep annotations -A 2        
                 
    annotations:
      agent.open-cluster-management.io/key1: value1

This PR also adds an e2e test to ensure the annotations are correctly applied to the ManagedCluster.

Related issue(s)

Fixes #480

@openshift-ci openshift-ci bot requested review from qiujian16 and ycyaoxdu March 17, 2025 21:20
@qiujian16
Copy link
Member

/approve
/lgtm

Copy link

openshift-ci bot commented Mar 28, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: arturshadnik, qiujian16

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

@openshift-merge-bot openshift-merge-bot bot merged commit 9d0fa06 into open-cluster-management-io:main Mar 28, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose ability to set ManagedCluster annotations during clusteradm join
2 participants