Skip to content

Commit b36d1ba

Browse files
authored
Merge pull request #3807 from olamilekan000/update-doc-on-how-to-start-shard
add how to run a Shard to the docs
2 parents 3955bb2 + 50c08e2 commit b36d1ba

File tree

3 files changed

+64
-7
lines changed

3 files changed

+64
-7
lines changed

docs/content/concepts/sharding/shards.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
---
22
description: >
3-
Horizontal Scaling of kcp through sharding
3+
Horizontal Scaling of kcp through sharding
44
---
55

66
# Shards
77

8+
To learn how to run a sharded environment for development, see [Running a Sharded Environment](../../developers/running-sharded.md).
9+
810
Every kcp shard is hosting a set of logical clusters. A logical cluster is
9-
identified by a globally unique identifier called a *cluster name*. A shard
11+
identified by a globally unique identifier called a **cluster name**. A shard
1012
serves the logical clusters under `/clusters/<cluster-name>`.
1113

1214
A set of known shards comprises a kcp installation.
@@ -30,7 +32,7 @@ Logical clusters are defined through the existence of a `LogicalCluster` object
3032
"in themselves", similar to a `.` directory defining the existence of a directory
3133
in Unix.
3234

33-
Every logical cluster name `name` is a *logical cluster path*. Every logical
35+
Every logical cluster name `name` is a **logical cluster path**. Every logical
3436
cluster is reachable through `/cluster/<path>` for every of their paths.
3537

3638
A `Workspace` in `tenancy.kcp.io/v1alpha1` of name `name` references a logical
@@ -40,21 +42,21 @@ can be reached via a path `path:name`.
4042

4143
## Canonical Paths
4244

43-
The longest path a logical cluster is reachable under is called the *canonical
44-
path*. By default, all canonical paths start with `root`, i.e. they start in
45+
The longest path a logical cluster is reachable under is called the **canonical
46+
path**. By default, all canonical paths start with `root`, i.e. they start in
4547
root logical cluster.
4648

4749
The logical cluster object annotated with `kcp.io/path: <canonical-path>`.
4850

4951
Additional subtrees of the workspace path hierarchy can be defined by creating
50-
logical clusters with `kcp.io/path` annotation *not* starting in `root`. E.g.
52+
logical clusters with `kcp.io/path` annotation _not_ starting in `root`. E.g.
5153
a home workspace hierarchy could start at `home:<user-name>`. There is no need
5254
for the parent (`home` in this case) to exist.
5355

5456
## Front Proxy
5557

5658
A front-proxy is aware of all logical clusters, their shard they live on,
57-
their canonical paths and all `Workspaces`s. Non canonical paths can be
59+
their canonical paths and all `Workspaces`. Non canonical paths can be
5860
reconstructed from the canonical path prefixes and the workspace names.
5961

6062
Requests to `/cluster/<path>` are forwarded to the shard via inverse proxying.

docs/content/developers/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
This chapter covers developing controllers against kcp and hacking on kcp itself.
44

5+
- [Running a Sharded Environment](running-sharded.md)
6+
57
{% include "partials/section-overview.html" %}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Running a Sharded Environment
2+
3+
This guide explains how to run a sharded kcp environment locally for development and testing purposes.
4+
5+
## Using `sharded-test-server`
6+
7+
The easiest way to stand up a sharded environment is using the `sharded-test-server` tool. This tool automates the creation of a root shard, additional shards, a front proxy, and all necessary certificates.
8+
9+
### Prerequisites
10+
11+
build the tool before running it:
12+
13+
```bash
14+
make build WHAT=./cmd/sharded-test-server
15+
```
16+
17+
### Running the Server
18+
19+
To start a cluster with 2 shards (Shard-0/Root and Shard-1):
20+
21+
```bash
22+
./bin/sharded-test-server --number-of-shards=2
23+
```
24+
25+
This command will launch:
26+
27+
- **Shard-0 (Root):** Hosting the root logical cluster and core APIs.
28+
- **Shard-1:** A secondary shard joined to the root.
29+
- **Front Proxy:** Handles routing requests to the appropriate shard.
30+
31+
### Accessing the Cluster
32+
33+
The tool generates several kubeconfig files in the current directory (or the path specified by `--work-dir-path`):
34+
35+
- `.kcp/admin.kubeconfig`: **Primary Admin Access.** connects via the front-proxy. Use this for most operations.
36+
- `.kcp-0/admin.kubeconfig`: Direct access to Shard-0 (Root).
37+
- `.kcp-1/admin.kubeconfig`: Direct access to Shard-1.
38+
39+
### Verification
40+
41+
To verify that your shards are running and registered, query the `Shard` resources from the root shard:
42+
43+
```bash
44+
KUBECONFIG=.kcp/admin.kubeconfig kubectl get shards
45+
```
46+
47+
You should see both `root` (shard-0) and `shard-1` listed.
48+
49+
```
50+
NAME REGION URL EXTERNAL URL AGE
51+
root us-east-2 https://127.0.0.1:6444 https://127.0.0.1:6443 111s
52+
shard-1 us-east-1 https://127.0.0.1:6445 https://127.0.0.1:6443 95s
53+
```

0 commit comments

Comments
 (0)