Skip to content

Commit ef9187d

Browse files
authored
docs: polish readme structure (#504)
Signed-off-by: Mike Ng <[email protected]>
1 parent e26cc6b commit ef9187d

File tree

1 file changed

+223
-83
lines changed

1 file changed

+223
-83
lines changed

README.md

Lines changed: 223 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,165 +1,245 @@
11
[comment]: # ( Copyright Contributors to the Open Cluster Management project )
2-
# clusteradm CLI & CLI Plugin
32

4-
A CLI and kubernetes CLI plugin that allows you to interact with open-cluster-management to manage your Hybrid Cloud presence from the command-line.
3+
# clusteradm
54

6-
## Quick start
5+
[![Go Report Card](https://goreportcard.com/badge/open-cluster-management.io/clusteradm)](https://goreportcard.com/report/open-cluster-management.io/clusteradm)
6+
[![License](https://img.shields.io/github/license/open-cluster-management-io/clusteradm)](/LICENSE)
7+
[![GitHub release](https://img.shields.io/github/release/open-cluster-management-io/clusteradm.svg)](https://github.com/open-cluster-management-io/clusteradm/releases/)
78

8-
### Install the clusteradm command-line:
9+
**clusteradm** is the command-line tool for [Open Cluster Management (OCM)](https://open-cluster-management.io/), providing a unified interface to manage multi-cluster Kubernetes environments from the command line.
10+
11+
## Overview
12+
13+
[Open Cluster Management (OCM)](https://open-cluster-management.io/) is a CNCF sandbox project that enables end-to-end visibility and control across your Kubernetes clusters using a powerful hub-agent architecture. OCM provides:
14+
15+
- **Cluster Lifecycle Management**: Register, manage, and monitor multiple Kubernetes clusters
16+
- **Application Distribution**: Deploy and manage applications across multiple clusters
17+
- **Policy & Governance**: Enforce security policies and compliance across your fleet
18+
- **Add-on Extensibility**: Extend functionality with a rich ecosystem of add-ons
19+
20+
**clusteradm** serves as the primary CLI tool for interacting with OCM, enabling administrators to:
21+
- Initialize hub clusters and register managed clusters
22+
- Deploy and manage multi-cluster applications
23+
- Configure policies and governance
24+
- Manage cluster sets and placements
25+
- Install and configure add-ons
26+
27+
## Quick Start
28+
29+
### Installation
930

1031
#### From install script:
1132

1233
```shell
1334
curl -L https://raw.githubusercontent.com/open-cluster-management-io/clusteradm/main/install.sh | bash
1435
```
1536

16-
#### From go install:
37+
#### From Go:
1738

1839
```shell
19-
go install open-cluster-management.io/clusteradm/cmd/clusteradm
40+
go install open-cluster-management.io/clusteradm/cmd/clusteradm@latest
2041
```
2142

22-
#### From binaries:
43+
#### From releases:
2344

24-
The binaries for several platforms are available [here](https://github.com/open-cluster-management-io/clusteradm/releases).
25-
- Download the compressed file from [here](https://github.com/open-cluster-management-io/clusteradm/releases)
26-
- Uncompress the file and place the output in a directory of your $PATH
45+
Download the latest binary from [GitHub Releases](https://github.com/open-cluster-management-io/clusteradm/releases) and add it to your `$PATH`.
2746

2847
#### From source:
2948

30-
Go 1.17 is required in order to build or contribute on this project as it leverage the `go:embed` tip.
31-
The binary will be installed in `$GOPATH/bin`
49+
Go 1.23+ is required to build from source.
3250

3351
```bash
3452
git clone https://github.com/open-cluster-management-io/clusteradm.git
3553
cd clusteradm
3654
make build
37-
clusteradm
55+
./bin/clusteradm
3856
```
3957

40-
### Initialize a hub and join a cluster
58+
### Basic Usage
59+
60+
Set up a multi-cluster environment in three steps:
4161

4262
```bash
43-
# Initialize the hub
44-
kubectl config use-context <hub cluster context> # kubectl config use-context kind-hub
63+
# 1. Initialize the hub cluster
64+
kubectl config use-context <hub-cluster-context>
4565
clusteradm init
4666

47-
# Request a managed cluster to join the hub
48-
kubectl config use-context <managed cluster context> # kubectl config use-context kind-managed-cluster
49-
clusteradm join --hub-token <token> --hub-apiserver <api server url> --cluster-name <cluster name>
67+
# 2. Join a managed cluster to the hub
68+
kubectl config use-context <managed-cluster-context>
69+
clusteradm join --hub-token <token> --hub-apiserver <hub-api-url> --cluster-name <cluster-name>
5070

51-
# Accept the managed cluster request on the hub
52-
kubectl config use-context <hub cluster context> # kubectl config use-context kind-hub
53-
clusteradm accept --clusters <list of clusters> # clusteradm accept --clusters c1,c2,...
71+
# 3. Accept the managed cluster on the hub
72+
kubectl config use-context <hub-cluster-context>
73+
clusteradm accept --clusters <cluster-name>
5474
```
5575

56-
After each above clusteradm command, the clusteradm will print out the next clusteradm command to execute which can be copy/paste.
76+
After each command, clusteradm provides the next command to execute, making the process seamless.
5777

58-
## Contributing
78+
## Commands
5979

60-
See our [Contributing Document](CONTRIBUTING.md) for more information.
80+
clusteradm organizes commands into logical groups for different aspects of cluster management.
6181

62-
## Commands
82+
### General Commands
6383

64-
The commands are composed of a verb and a noun and then a number of parameters.
65-
Logs can be gather by setting the klog flag `-v`.
66-
To get the logs in a separate file:
67-
```
68-
clusteradm <subcommand> -v 2 > <your_logfile>
69-
```
70-
or
71-
```
72-
clusteradm <subcommand> -v 99 --logtostderr=false --log-file=<your_log_file>
73-
```
84+
| Command | Description |
85+
|---------|-------------|
86+
| `create` | Create OCM resources (placements, cluster sets, sample apps, work) |
87+
| `delete` | Delete OCM resources (cluster sets, tokens, work) |
88+
| `get` | Display OCM resources (clusters, hub info, tokens, placements, work, add-ons) |
89+
| `install` | Install hub add-ons |
90+
| `uninstall` | Uninstall hub add-ons |
91+
| `upgrade` | Upgrade cluster manager or klusterlet |
92+
| `version` | Display clusteradm and cluster version information |
7493

75-
### version
94+
### Registration Commands
7695

77-
Display the clusteradm version and the kubeversion
96+
| Command | Description |
97+
|---------|-------------|
98+
| `init` | Initialize a hub cluster |
99+
| `join` | Join a cluster to the hub as a managed cluster |
100+
| `accept` | Accept cluster join requests on the hub |
101+
| `unjoin` | Remove a cluster from the hub |
102+
| `clean` | Clean up OCM components from the hub cluster |
78103

79-
`clusteradm version`
104+
### Cluster Management Commands
80105

81-
### init
106+
| Command | Description |
107+
|---------|-------------|
108+
| `addon` | Manage add-ons (enable, disable, create) |
109+
| `clusterset` | Manage cluster sets (bind, unbind, set) |
110+
| `proxy` | Access managed clusters through the cluster proxy |
82111

83-
Initialize the hub by deploying the hub side resources to manage clusters.
112+
### Logging and Debugging
84113

85-
`clusteradm init [--use-bootstrap-token]`
114+
Get detailed logs by setting the klog flag:
86115

87-
it returns the command line to launch on the spoke to join the hub.
88-
> 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.
116+
```bash
117+
# Basic logging
118+
clusteradm <command> -v 2 > logfile.log
119+
120+
# Verbose logging to file
121+
clusteradm <command> -v 99 --logtostderr=false --log-file=debug.log
122+
```
89123

90-
### get token
124+
## Detailed Command Reference
91125

92-
Get the latest token to import a new managed cluster.
126+
### Cluster Lifecycle
93127

94-
`clusteradm get token --context ${CTX_HUB_CLUSTER}`
95-
### join
128+
#### Initialize a Hub Cluster
96129

97-
Install the agent on the spoke.
130+
```bash
131+
clusteradm init [--use-bootstrap-token]
132+
```
98133

99-
`clusteradm join --hub-token <token> --hub-apiserver <hub_apiserver_url> --cluster-name c1 [--ca-file <path-to-ca-file>] [--force-internal-endpoint-lookup]`
134+
Deploys OCM hub components and returns the join command for managed clusters.
100135

101-
it returns the command line to launch on the hub the accept the spoke onboarding.
136+
> **Note**: Do not run `init` against a [multicluster-controlplane](https://github.com/open-cluster-management-io/multicluster-controlplane) instance. Use `clusteradm get token --use-bootstrap-token` instead.
102137
103-
> 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.
138+
#### Get Join Token
104139

105-
> 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.
140+
```bash
141+
clusteradm get token [--use-bootstrap-token]
142+
```
106143

107-
### accept
144+
Retrieves the latest token for joining managed clusters.
108145

109-
Accept the CSRs on the hub to approve the spoke clusters to join the hub.
146+
#### Join a Managed Cluster
110147

111-
`clusteradm accept --clusters <cluster1>, <cluster2>,....`
148+
```bash
149+
clusteradm join --hub-token <token> --hub-apiserver <hub-url> --cluster-name <name> \
150+
[--ca-file <ca-file>] [--force-internal-endpoint-lookup]
151+
```
112152

113-
### unjoin
153+
Installs the klusterlet agent on a managed cluster.
114154

115-
Uninstall the agent on the spoke
155+
**Options:**
156+
- `--ca-file`: Provide a custom CA file for hub verification
157+
- `--force-internal-endpoint-lookup`: Required for clusters behind NAT (e.g., kind clusters)
116158

117-
`clusteradm unjoin --cluster-name c1`
118-
> Note: the applied resources on managed cluster would be checked and prompt a warning if still exist any.
159+
#### Accept Cluster Registration
119160

120-
### clean
161+
```bash
162+
clusteradm accept --clusters <cluster1>,<cluster2>,...
163+
```
121164

122-
Clean up the multicluster hub control plane and other initialized resources on the hub cluster
165+
Approves cluster join requests on the hub.
123166

124-
`clusteradm clean --context ${CTX_HUB_CLUSTER}`
167+
#### Remove a Managed Cluster
125168

126-
### install hub-addon
169+
```bash
170+
clusteradm unjoin --cluster-name <cluster-name>
171+
```
127172

128-
Install specific built-in add-on(s) to the hub cluster.
173+
Removes klusterlet components from a managed cluster.
129174

130-
`clusteradm install hub-addon --names argocd`
175+
### Add-on Management
131176

132-
`clusteradm install hub-addon --names governance-policy-framework`
177+
#### Install Hub Add-ons
133178

134-
### enable addons
179+
```bash
180+
# Install specific add-ons
181+
clusteradm install hub-addon --names argocd
182+
clusteradm install hub-addon --names governance-policy-framework
183+
```
135184

136-
Enable specific add-on(s) agent deployment to the given managed clusters of the specified namespace
185+
#### Enable Add-ons on Managed Clusters
137186

138-
`clusteradm addon enable --names argocd --namespace <namespace> --clusters <cluster1>,<cluster2>,....`
187+
```bash
188+
clusteradm addon enable --names <addon-name> --namespace <namespace> --clusters <clusters>
139189

140-
`clusteradm addon enable --names governance-policy-framework --namespace <namespace> --clusters <cluster1>,<cluster2>,....`
190+
# Examples
191+
clusteradm addon enable --names argocd --namespace argocd --clusters cluster1,cluster2
192+
clusteradm addon enable --names governance-policy-framework --namespace open-cluster-management-agent-addon --clusters cluster1
193+
```
141194

142-
`clusteradm addon enable --names config-policy-controller --namespace <namespace> --clusters <cluster1>,<cluster2>,....`
195+
### Cluster Sets and Placement
143196

144-
### create sample application
197+
#### Create Cluster Sets
145198

146-
Create and deploy a sample Argo CD ApplicationSet
199+
```bash
200+
clusteradm create clusterset <clusterset-name>
201+
```
147202

148-
`clusteradm create sampleapp sample-appset`
203+
#### Bind Clusters to Sets
149204

150-
## Version Bundles
205+
```bash
206+
clusteradm clusterset bind <clusterset-name> --clusters <cluster1>,<cluster2>
207+
```
151208

152-
By default, clusteradm uses a built-in version bundle that defines the versions of all OCM components to be installed. You can request a specific version bundle using the `--bundle-version` flag. You can override individual component versions within the selected version bundle using the `--bundle-version-overrides` flag:
209+
#### Create Placements
153210

154211
```bash
155-
# Override component versions within the default version bundle:
156-
clusteradm init --bundle-version-overrides /path/to/bundle-overrides.json
212+
clusteradm create placement <placement-name> --clusters <cluster1>,<cluster2>
213+
```
214+
215+
### Application Deployment
216+
217+
#### Create Sample Applications
218+
219+
```bash
220+
clusteradm create sampleapp <app-name>
221+
```
222+
223+
Creates and deploys sample applications using Argo CD ApplicationSets.
224+
225+
### Cluster Proxy
226+
227+
Access managed clusters through the cluster proxy:
157228

158-
# Override component versions within a specific version bundle:
159-
clusteradm init --bundle-version v0.16.0 --bundle-version-overrides /path/to/bundle-overrides.json
229+
```bash
230+
clusteradm proxy health --cluster-name <cluster-name>
231+
clusteradm proxy kubectl --cluster-name <cluster-name> -- <kubectl-args>
160232
```
161233

162-
The version bundle override file must be a JSON file containing one or more OCM component versions. Example:
234+
## Version Bundles
235+
236+
clusteradm uses version bundles to ensure compatibility between OCM components. You can:
237+
238+
- Use the default bundle: `clusteradm init`
239+
- Specify a version: `clusteradm init --bundle-version v0.16.0`
240+
- Override component versions: `clusteradm init --bundle-version-overrides /path/to/overrides.json`
241+
242+
Example override file:
163243

164244
```json
165245
{
@@ -170,4 +250,64 @@ The version bundle override file must be a JSON file containing one or more OCM
170250
}
171251
```
172252

173-
This is useful when you need to use specific versions of components or when working with custom builds.
253+
## Examples
254+
255+
### Multi-cluster Application Deployment
256+
257+
```bash
258+
# 1. Create a cluster set
259+
clusteradm create clusterset production
260+
261+
# 2. Bind clusters to the set
262+
clusteradm clusterset bind production --clusters web-cluster,api-cluster
263+
264+
# 3. Create a placement for the application
265+
clusteradm create placement web-app-placement --clusterset production
266+
267+
# 4. Deploy using ManifestWork or Argo CD
268+
clusteradm create work my-web-app --clusters web-cluster,api-cluster
269+
```
270+
271+
### Policy Enforcement
272+
273+
```bash
274+
# 1. Install policy framework
275+
clusteradm install hub-addon --names governance-policy-framework
276+
277+
# 2. Enable on managed clusters
278+
clusteradm addon enable --names governance-policy-framework \
279+
--namespace open-cluster-management-agent-addon \
280+
--clusters cluster1,cluster2
281+
282+
# 3. Enable config policy controller
283+
clusteradm addon enable --names config-policy-controller \
284+
--namespace open-cluster-management-agent-addon \
285+
--clusters cluster1,cluster2
286+
```
287+
288+
## Contributing
289+
290+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on:
291+
292+
- Code contribution process
293+
- Development environment setup
294+
- Testing guidelines
295+
- Community guidelines
296+
297+
## Community & Support
298+
299+
### Get Connected
300+
301+
- **Website**: [open-cluster-management.io](https://open-cluster-management.io/)
302+
- **Slack**: [#open-cluster-mgmt](https://kubernetes.slack.com/archives/C01GE7YSUUF) on Kubernetes Slack
303+
- **Mailing List**: [[email protected]](https://groups.google.com/g/open-cluster-management)
304+
- **YouTube**: [OCM Community](https://www.youtube.com/channel/UC7xxOh2jBM5Jfwt3fsBzOZw)
305+
- **Community Meetings**: [Calendar](https://calendar.google.com/calendar/u/0/[email protected])
306+
307+
## License
308+
309+
This project is licensed under the [Apache License 2.0](LICENSE).
310+
311+
---
312+
313+
Built by the [Open Cluster Management community](https://github.com/open-cluster-management-io)

0 commit comments

Comments
 (0)