You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user-guide/environment-variables.md
+69-14Lines changed: 69 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,56 @@ Grove automatically injects environment variables into every container and init
20
20
-**Coordination**: Understanding your role in a distributed system
21
21
-**Configuration**: Self-configuring based on your position in the hierarchy
22
22
23
-
**Key insight:** Pod discovery in Grove is **index-based**, not name-based. While Kubernetes assigns each pod a name with a random suffix (e.g., `my-service-0-frontend-abc12`), you never need to know these suffixes for service discovery. Instead, Grove's environment variables let you construct deterministic addresses using the PodClique name and pod index (e.g., `my-service-0-frontend-0.<headless-service>`).
23
+
However, before we get to the environment variables it is important to first make a distinction between a Pod's Name and its Hostname.
24
+
25
+
## Understanding Pod Names vs. Hostnames in Kubernetes
26
+
27
+
A common source of confusion is the difference between a pod's **name** and its **hostname**. Understanding this distinction is essential for using Grove's environment variables correctly.
28
+
29
+
### Pod Name (Kubernetes Resource Identifier)
30
+
31
+
The **pod name** is the unique identifier for the Pod resource in Kubernetes (stored in `metadata.name`). When Grove creates pods, it uses Kubernetes' `generateName` feature, which appends a random 5-character suffix to ensure uniqueness:
32
+
33
+
```
34
+
<pclq-name>-<random-suffix>
35
+
Example: env-demo-standalone-0-frontend-abc12
36
+
```
37
+
38
+
This name is what you see when running `kubectl get pods`. However, you **cannot use this name for DNS-based service discovery** because the random suffix is unpredictable.
39
+
40
+
### Hostname (DNS-Resolvable Identity)
41
+
42
+
The **hostname** is a separate field (`spec.hostname`) that Grove explicitly sets on each pod. Unlike the pod name, the hostname follows a **deterministic pattern**:
43
+
44
+
```
45
+
<pclq-name>-<pod-index>
46
+
Example: env-demo-standalone-0-frontend-0
47
+
```
48
+
49
+
Grove also sets the pod's **subdomain** (`spec.subdomain`) to match the headless service name. Grove automatically creates a headless service for each PodCliqueSet replica, so you don't need to create one yourself. In Kubernetes, when a pod has both `hostname` and `subdomain` set, and a matching headless service exists, the pod becomes DNS-resolvable at:
| DNS resolvable? | ❌ No | ✅ Yes (with headless service) |
68
+
| Use case |`kubectl` commands, logs | Service discovery, pod-to-pod communication |
69
+
70
+
**The environment variables Grove provides (`GROVE_PCLQ_NAME`, `GROVE_PCLQ_POD_INDEX`, `GROVE_HEADLESS_SERVICE`) give you the building blocks to construct the hostname-based FQDN, not the pod name.** This is why pod discovery in Grove is deterministic and doesn't require knowledge of random suffixes.
71
+
72
+
With this explained we can now get into the environment variables Grove provides.
My FQDN: env-demo-standalone-0-frontend-0.env-demo-standalone-0.default.svc.cluster.local
151
209
152
210
Sleeping...
153
211
```
154
212
155
213
**Key Observations:**
156
-
- The pod name (`env-demo-standalone-0-frontend-abc12`) follows the pattern `<pcs-name>-<pcs-index>-<pclq-name>-<suffix>`
214
+
- The **pod name** (`env-demo-standalone-0-frontend-abc12`) has a random suffix—this is the Kubernetes resource identifier, not used for DNS
215
+
- The **hostname** (constructed as `$GROVE_PCLQ_NAME-$GROVE_PCLQ_POD_INDEX`) is deterministic—this is what you use for service discovery
157
216
-`GROVE_PCLQ_NAME` contains the fully qualified PodClique name without the random suffix
158
217
-`GROVE_PCLQ_POD_INDEX` tells us this is the first pod (index 0) in the PodClique
159
-
-`GROVE_HEADLESS_SERVICE` provides the FQDN for the headless service serving all pods in this PodCliqueSet replica
218
+
-`GROVE_HEADLESS_SERVICE` provides the FQDN for the headless service, so the full DNS address is: `$GROVE_PCLQ_NAME-$GROVE_PCLQ_POD_INDEX.$GROVE_HEADLESS_SERVICE`
For pods in a PodCliqueScalingGroup, Grove exposes additional variables that identify the PCSG replica and its composition. This allows components to understand which *logical unit (super-pod)* they belong to and how many peers are expected.
448
507
449
508
5.**Designed for Distributed Systems**
450
-
Grove’s environment variables are intentionally low-level and composable. They are meant to support a wide range of distributed system patterns—leader election, sharding, rendezvous, collective communication—without imposing a fixed discovery or coordination model.
451
-
452
-
453
-
454
-
509
+
Grove’s environment variables are intentionally low-level and composable. They are meant to support a wide range of distributed system patterns—leader election, sharding, rendezvous, collective communication—without imposing a fixed discovery or coordination model.
Copy file name to clipboardExpand all lines: docs/user-guide/pod-naming.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Pod Naming Scheme
2
2
3
-
This guide explains Grove's hierarchical pod naming scheme and best practices for naming your resources. **Grove's naming convention is designed to be self-documenting**: when you run `kubectl get pods`, the pod names immediately tell you which PodCliqueSet, PodClique, and (if applicable) PodCliqueScalingGroup each pod belongs to, reflecting the complete hierarchy of your system.
3
+
This guide explains Grove's hierarchical pod naming scheme and best practices for naming your resources. **Grove's naming convention is designed to be self-documenting**: when you run `kubectl get pods`, the pod names immediately tell you which PodCliqueSet, PodCliqueScalingGroup (if applicable), and PodClique each pod belongs to, reflecting the complete hierarchy of your system.
0 commit comments