Skip to content

Commit

Permalink
update doc for join command (#295)
Browse files Browse the repository at this point in the history
* update doc for join command

Signed-off-by: ycyaoxdu <[email protected]>

* Update README.md

Co-authored-by: Jian Qiu <[email protected]>
Signed-off-by: ycyaoxdu <[email protected]>

---------

Signed-off-by: ycyaoxdu <[email protected]>
Co-authored-by: Jian Qiu <[email protected]>
  • Loading branch information
ycyaoxdu and qiujian16 authored Feb 28, 2023
1 parent 2e33a5a commit e4bfc3f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,25 @@ Initialize the hub by deploying the hub side resources to manage clusters.
`clusteradm init [--use-bootstrap-token]`

it returns the command line to launch on the spoke to join the hub.
> NOTE: Do not run init command against a [multicluster-controlplane](https://github.com/open-cluster-management-io/multicluster-controlplane) instance. It is already an initialized hub on start. Instead, use `clusteradm get token --use-bootstrap-token` to get the join command.
### get token

Get the latest token to import a new managed cluster.

`clusteradm get token --context ${CTX_HUB_CLUSTER}`

### join

Install the agent on the spoke.

`clusteradm join --hub-token <token> --hub-apiserver <hub_apiserver_url> --cluster-name c1`
`clusteradm join --hub-token <token> --hub-apiserver <hub_apiserver_url> --cluster-name c1 [--ca-file <path-to-ca-file>] [--force-internal-endpoint-lookup]`

it returns the command line to launch on the hub the accept the spoke onboarding.

> NOTE: The `--ca-file` flag is used to provide a valid CA for hub. The ca data is fetched from cluster-info configmap in kube-public namespace of the hub cluster, then from kube-root-ca.crt configmap in kube-public namespace if the cluster-info configmap does not exist.
> NOTE: If you're trying to join a hub cluster which is initialized from a kind cluster, please set the `--force-internal-endpoint-lookup` flag.
### accept

Accept the CSRs on the hub to approve the spoke clusters to join the hub.
Expand All @@ -111,6 +115,7 @@ Accept the CSRs on the hub to approve the spoke clusters to join the hub.
Uninstall the agent on the spoke

`clusteradm unjoin --cluster-name c1`
> Note: the applied resources on managed cluster would be checked and prompt a warning if still exist any.
### clean

Expand Down
8 changes: 5 additions & 3 deletions pkg/cmd/join/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import (
)

var example = `
# Join a cluster to the hub
# Join a cluster to the hub
%[1]s join --hub-token <tokenID.tokenSecret> --hub-apiserver <hub_apiserver_url> --cluster-name <cluster_name>
# Join a cluster to the hub with hosted mode
%[1]s join --hub-token <tokenID.tokenSecret> --hub-apiserver <hub_apiserver_url> --cluster-name <cluster_name> --mode hosted --managed-cluster-kubeconfig <path_to_kubeconfig>
# join a cluster to the hub with hosted mode
%[1]s join --hub-token <tokenID.tokenSecret> --hub-apiserver <hub_apiserver_url> --cluster-name <cluster_name> --mode hosted --managed-cluster-kubeconfig <managed-cluster-kubeconfig-file>
# join a cluster to the hub while the hub provided no valid CA data in kube-public namespace
%[1]s join --hub-token <tokenID.tokenSecret> --hub-apiserver <hub_apiserver_url> --cluster-name <cluster_name> --ca-file <ca-file>
`

// NewCmd ...
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/join/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (o *Options) complete(cmd *cobra.Command, args []string) (err error) {

// code logic of building hub client in join process:
// 1. use the token and insecure to fetch the ca data from cm in kube-public ns
// 2. if not found, assume using a authorized ca.
// 2. if not found, assume using an authorized ca.
// 3. use the ca and token to build a secured client and call hub

//Create an unsecure bootstrap
Expand Down

0 comments on commit e4bfc3f

Please sign in to comment.