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

feat: add command-line tool admiralctl join&unjoin #302

Closed

Conversation

miraclejzd
Copy link

Summary

Currently, users need to manually create Secret and FederatedCluster resources through YAML files to add member clusters, and this file-based approach is not very convenient. Thanks to the work in #202, the command-line tool admiralctl has taken shape. In this proposal, I am building upon this work by introducing a new subcommand, admiralctl join, corresponding to #260. With this command, users can add member clusters via the command line.

Motivation

With the command-line tool, users can conveniently add member clusters without the need to manually create Secret and FederatedCluster resources.

Proposal

Command line tool framework selection

Similar to #202, utilizing cobra as the framework for the command-line tool.

admiralctl join subcommand

  1. Retrieve the kubeconfig file of the member cluster and extract information such as server endpoint, CA, cert, key, and bearer token.
  2. Validate the legitimacy of the member cluster:
    • Check if the control-plane nodes of the member cluster are Ready.
    • Verify if the member cluster has already joined Kubeadmiral (by checking the existence of the kube-admiral-system namespace and the annotation of it).
  3. Create Secret and FederatedCluster resources through the Clientset.

Command design

./admiralctl join --help
Join a member cluster to Kubeadmiral control plane.

 If the control plane of the member cluster is not ready or has already joined, this command will do nothing.

Examples:
  # Join cluster1 to Kubeadmiral by kubeconfig
  admiralctl join cluster1 --cluster-kubeconfig=<CLUSTER_KUBECONFIG_PATH>
  
  # Support to use '--api-endpoint' to overwrite the member cluster's api-endpoint
  admiralctl join cluster1 --cluster-kubeconfig=<CLUSTER_KUBECONFIG_PATH> --api-endpoint=<CLUSTER_API_ENDPOINT>
  
  # Support to use '--use-service-account' to determine whether create a new ServiceAccount when join
  admiralctl join cluster1 --cluster-kubeconfig=<CLUSTER_KUBECONFIG_PATH> --use-service-account=false
  
  # Support to use '--cluster-context' to specify the context of member cluster
  admiralctl join cluster1 --cluster-kubeconfig=<CLUSTER_KUBECONFIG_PATH> --cluster-context=<CLUSTER_CONTEXT>

Options:
    --api-endpoint='':
        api-endpoint of the member cluster.

    --cluster-context='':
        Context name of member cluster in kubeconfig.

    --cluster-kubeconfig='':
        Path of the member cluster kubeconfig.

    --use-service-account=true:
        Whether creates a new ServiceAccount when join, corresponding to FederatedCluster.spec.useServiceAccount.
        If you set 'false', BearerToken should be in the kubeconfig.

Usage:
  admiralctl join <FCLUSTER_NAME> --cluster-kubeconfig <CLUSTER_KUBECONFIG_PATH> [options]

admiralctl unjoin subcommand

  1. Validate the legitimacy of the member cluster:
    • Verify if the cluster has already joined Kubeadmiral
    • Check if the secret of the FederatedCluster is existed.
  2. Delete the FederatedCluster resource from Kubeadmiral.

Command design

./admiralctl unjoin --help
Unjoin a FederatedCluster from Kubeadmiral federation.

 If the the federated cluster has not joined the federation, this command will do nothing.

Examples:
  # Unjoin cluster1 from Kubeadmiral federation
  admiralctl unjoin cluster1

Usage:
  admiralctl unjoin <FCLUSTER_NAME> [options]

@CLAassistant
Copy link

CLAassistant commented Jan 3, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ miraclejzd
❌ Zhida Jiang


Zhida Jiang seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@miraclejzd miraclejzd closed this Jan 3, 2024
@miraclejzd miraclejzd deleted the feat-admiralctl-join&unjoin branch January 3, 2024 08:48
@miraclejzd miraclejzd restored the feat-admiralctl-join&unjoin branch January 3, 2024 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants