Skip to content

Commit ed8f6a2

Browse files
author
Arvind Thirumurugan
committed
add steps in readme to build tools as kubectl plugins
1 parent e41a25b commit ed8f6a2

2 files changed

Lines changed: 90 additions & 10 deletions

File tree

tools/draincluster/README.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,51 @@
1+
# Steps to build draincluster as a kubectl plugin
2+
3+
1. Build the binary for the `draincluster` tool by running the following command in the root directory of the fleet repo:
4+
5+
```bash
6+
go build -o ./hack/tools/bin/kubectl-draincluster ./tools/draincluster/main.go
7+
```
8+
9+
2. Move the binary to a directory in your `PATH` so that it can be run as a kubectl plugin. For example, you can move it to
10+
`/usr/local/bin`:
11+
12+
```bash
13+
sudo cp ./hack/tools/bin/kubectl-draincluster /usr/local/bin/
14+
```
15+
16+
3. Make the binary executable by running the following command:
17+
18+
```bash
19+
chmod +x /usr/local/bin/kubectl-draincluster
20+
```
21+
22+
4. Verify that the plugin is recognized by kubectl by running the following command:
23+
24+
```bash
25+
kubectl plugin list
26+
```
27+
28+
you should see the `draincluster` plugin listed in the output:
29+
30+
```
31+
The following compatible plugins are available:
32+
33+
/usr/local/bin/kubectl-draincluster
34+
```
35+
36+
please refer to the [kubectl plugin documentation](https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/) for
37+
more information.
38+
139
# Drain Member Cluster connected to a fleet
240

3-
To drain a member cluster connected to a fleet, you can use the `draincluster` tool. This tool allows you to remove all
4-
resources propagated to the member cluster from the hub cluster by any `Placement` resource.
5-
This is useful when you want to temporarily move all workloads off a member cluster in preparation for an
6-
event like upgrade or reconfiguration.
41+
After following the steps above to build the `draincluster` tool as a kubectl plugin, you can use it to remove all
42+
resources propagated to the member cluster from the hub cluster by any `Placement` resource. This is useful when you
43+
want to temporarily move all workloads off a member cluster in preparation for an event like upgrade or reconfiguration.
744

845
The `draincluster` tool can be used to drain a member cluster by running the following command:
946

1047
```
11-
go run tools/draincluster/main.go --hubClusterContext <hub-cluster-context> --clusterName <memberClusterName>
48+
kubectl draincluster --hubClusterContext <hub-cluster-context> --clusterName <memberClusterName>
1249
```
1350

1451
the tool currently is a go program that takes the hub cluster context and the member cluster name as arguments.

tools/uncordoncluster/README.md

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,49 @@
1+
# Steps to build draincluster as a kubectl plugin
2+
3+
1. Build the binary for the `uncordoncluster` tool by running the following command in the root directory of the fleet repo:
4+
5+
```bash
6+
go build -o ./hack/tools/bin/kubectl-uncordoncluster ./tools/uncordoncluster/main.go
7+
```
8+
9+
2. Move the binary to a directory in your `PATH` so that it can be run as a kubectl plugin. For example, you can move it to
10+
`/usr/local/bin`:
11+
12+
```bash
13+
sudo cp ./hack/tools/bin/kubectl-uncordoncluster /usr/local/bin/
14+
```
15+
16+
3. Make the binary executable by running the following command:
17+
18+
```bash
19+
chmod +x /usr/local/bin/kubectl-uncordoncluster
20+
```
21+
22+
4. Verify that the plugin is recognized by kubectl by running the following command:
23+
24+
```bash
25+
kubectl plugin list
26+
```
27+
28+
you should see the `uncordoncluster` plugin listed in the output:
29+
30+
```
31+
The following compatible plugins are available:
32+
33+
/usr/local/bin/kubectl-uncordoncluster
34+
```
35+
36+
please refer to the [kubectl plugin documentation](https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/) for
37+
more information.
38+
39+
140
# Uncordon Member Cluster connected to a fleet
241

3-
To uncordon a member cluster connected to a fleet, you can use the `uncordoncluster` tool. This tool allows you to
4-
uncordon a member cluster that has been cordoned using the `draincluster` tool.
42+
After following the steps above to build the `uncordoncluster` tool as a kubectl plugin, you can use it to uncordon a
43+
member cluster that has been cordoned using the `draincluster` tool.
544

645
```
7-
go run tools/uncordoncluster/main.go --hubClusterContext <hub-cluster-context> --clusterName <memberClusterName>
46+
kubectl uncordoncluster --hubClusterContext <hub-cluster-context> --clusterName <memberClusterName>
847
```
948

1049
the tool currently is a go program that also takes the hub cluster context and the member cluster name as arguments.
@@ -25,5 +64,9 @@ CURRENT NAME CLUSTER AUTHINFO
2564
* hub hub clusterUser_clusterResourceGroup_hub
2665
```
2766

28-
The command removes all taints added to a `MemberCluster` resource and hence if any `ClusterResourcePlacementEviction`
29-
object present which can propagate resources to the member cluster, it can continue to do so.
67+
Here you can see that the context of the hub cluster is called `hub` under the `NAME` column.
68+
69+
The command removes the `cordon` taint added to a `MemberCluster` resource by the `draincluster` tool. If the `cordon`
70+
taint is not present, the command will not have any effect. Once the taint is removed if there are no other taints on the
71+
`MemberCluster` resource, the member cluster will be uncordoned and resource can be propagated to it from the hub cluster
72+
using `Placement` resources.

0 commit comments

Comments
 (0)