Skip to content

Commit 61963f6

Browse files
committed
Add Readme to Kind example
1 parent e0b7baf commit 61963f6

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

examples/kind/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Kind Provider Example
2+
3+
This example demonstrates how to use the Kind provider to manage multiple Kubernetes clusters created with Kind (Kubernetes in Docker).
4+
5+
## Overview
6+
7+
The Kind provider allows you to:
8+
1. Automatically discover and connect to multiple Kind clusters
9+
2. Run controllers that can operate across all discovered clusters
10+
3. Test multicluster scenarios locally using Docker containers
11+
12+
## Prerequisites
13+
14+
- [Kind](https://kind.sigs.k8s.io/docs/user/quick-start/) installed and available in your PATH
15+
- Docker running on your machine
16+
- `kubectl` configured to access Kind clusters
17+
18+
## Usage
19+
20+
### 1. Create Kind Clusters
21+
22+
First, create multiple Kind clusters for testing:
23+
24+
```bash
25+
kind create cluster --name fleet-alpha
26+
kind create cluster --name fleet-beta
27+
```
28+
29+
This will create two Kind clusters:
30+
- `fleet-alpha` accessible via context `kind-fleet-alpha`
31+
- `fleet-beta` accessible via context `kind-fleet-beta`
32+
33+
### 2. Run the Example
34+
35+
Start the multicluster operator:
36+
37+
```bash
38+
go run ./main.go
39+
```
40+
41+
The operator will automatically discover the Kind clusters and connect to them.
42+
43+
### 3. Observe Cross-Cluster Operations
44+
45+
In separate terminals, monitor events across both clusters to see the multicluster operations in action:
46+
47+
```bash
48+
# Terminal 1: Monitor fleet-alpha cluster
49+
kubectl get events -A --context kind-fleet-alpha --watch
50+
51+
# Terminal 2: Monitor fleet-beta cluster
52+
kubectl get events -A --context kind-fleet-beta --watch
53+
```
54+
55+
## How It Works
56+
57+
1. The Kind provider automatically discovers Kind clusters by:
58+
- Scanning for Kind cluster using `"sigs.k8s.io/kind/pkg/cluster"`
59+
- Connecting to clusters that match the Kind naming pattern (`fleet-*`)
60+
2. For each discovered cluster, it engages multicluster-runtime.
61+
3. Your controllers can then operate across all discovered clusters
62+
63+
## Cleanup
64+
65+
To clean up the Kind clusters when you're done:
66+
67+
```bash
68+
kind delete cluster --name fleet-alpha
69+
kind delete cluster --name fleet-beta
70+
```

examples/kind/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ func main() {
7272
return reconcile.Result{}, err
7373
}
7474

75+
cl.GetEventRecorderFor("kind-multicluster-configmaps").Event(
76+
cm,
77+
corev1.EventTypeNormal,
78+
"ConfigMapFound",
79+
"ConfigMap found in cluster "+req.ClusterName,
80+
)
81+
7582
log.Info("ConfigMap found", "namespace", cm.Namespace, "name", cm.Name, "cluster", req.ClusterName)
7683

7784
return ctrl.Result{}, nil

0 commit comments

Comments
 (0)