Skip to content

Commit e46d1d7

Browse files
authored
docs: bootstrap quick guide + wide findability pass (#21)
Add get-started/bootstrap for custom setup until ready (VM + agent + bootstrap with zero failures), keep the readiness protocol as the deep dive, and make the rest of the docs easier to land on: - descriptive titles and search keywords across guides/explain/MCP/reference - "If you only need…" shortcode pointing short paths at get-started - search ranks titles/keywords higher and surfaces section chips - relative in-tree links (no more hardcoded /docs/0.2.2/ on main) - publish updated tree to 0.4.0; stub bootstrap pages on 0.2.2/0.3.0 so nav works
1 parent 8cc0605 commit e46d1d7

100 files changed

Lines changed: 1581 additions & 380 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: "Bootstrap until ready (custom setup)"
3+
description: "Guest readiness / bootstrap wait is documented for grain v0.4.0+."
4+
section: get-started
5+
---
6+
7+
The **readiness protocol** and `--wait bootstrap` flow shipped in **grain v0.4.0**.
8+
9+
Switch the docs version to **[v0.4.0](/docs/0.4.0/get-started/bootstrap/)** or **[main](/docs/main/get-started/bootstrap/)** for the walkthrough (cloud-init sample, `grain status` progress, and what “ready” means).
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: "Bootstrap until ready (custom setup)"
3+
description: "Guest readiness / bootstrap wait is documented for grain v0.4.0+."
4+
section: get-started
5+
---
6+
7+
The **readiness protocol** and `--wait bootstrap` flow shipped in **grain v0.4.0**.
8+
9+
Switch the docs version to **[v0.4.0](/docs/0.4.0/get-started/bootstrap/)** or **[main](/docs/main/get-started/bootstrap/)** for the walkthrough (cloud-init sample, `grain status` progress, and what “ready” means).

docs/content/docs/0.4.0/explain/agent-vs-ssh.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
---
2-
title: Agent vs SSH
2+
title: "Agent vs SSH (when each path is used)"
33
description: When grain uses the guest agent, when it falls back to SSH, and why both exist.
44
section: explain
5+
keywords:
6+
- agent
7+
- SSH
8+
- grain-agent
9+
- wait modes
10+
- transport
11+
- vsock
512
---
613

14+
{{< only-need href="guides/agent/" >}}
15+
Practical agent CLI/API how-to — this page is the decision model.
16+
{{< /only-need >}}
17+
718
## Roles
819

920
| Path | Strengths | Weaknesses |
@@ -42,4 +53,4 @@ Host → agent:
4253
- **Day-to-day automation:** agent (`x`, `cp`, `fs`, API exec)
4354
- **Debugging a broken agent:** `grain sh --ssh` and `grain logs`
4455
- **Images:** prefer `grain-ubuntu` so agent is already present
45-
- **Security-sensitive tokens:** prefer [egress proxy](/docs/0.4.0/guides/proxy/) over writing secrets into the guest when possible
56+
- **Security-sensitive tokens:** prefer [egress proxy](../guides/proxy/) over writing secrets into the guest when possible

docs/content/docs/0.4.0/explain/architecture.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
---
2-
title: Architecture
2+
title: "Architecture (daemon, hypervisor, guest agent)"
33
description: How the grain daemon, hypervisor, guest agent, and CLI fit together.
44
section: explain
5+
keywords:
6+
- architecture
7+
- daemon
8+
- hypervisor
9+
- qemu
510
---
611

12+
{{< only-need href="get-started/concepts/" >}}
13+
Names and mental model without the full system diagram.
14+
{{< /only-need >}}
15+
716
## Big picture
817

918
```text
@@ -58,4 +67,4 @@ SSH is excellent for interactive login and bootstrap. The agent is better for:
5867
- File and filesystem operations without scp edge cases
5968
- Readiness probes (`/health`) independent of shell profiles
6069

61-
See [Agent vs SSH](/docs/0.4.0/explain/agent-vs-ssh/).
70+
See [Agent vs SSH](../agent-vs-ssh/).

docs/content/docs/0.4.0/explain/images-and-boot.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
---
2-
title: Images and boot
2+
title: "Images and boot (golden vs cloud)"
33
description: Why base images matter, how golden boots differ from cloud images, and how to think about speed.
44
section: explain
5+
keywords:
6+
- images
7+
- boot
8+
- golden
9+
- grain-ubuntu
10+
- cloud-init
11+
- bench
12+
- bake
513
---
614

15+
{{< only-need href="guides/images/" >}}
16+
Pull, import, bake, and day-to-day image commands live in the Images guide.
17+
{{< /only-need >}}
18+
719
## Catalog at a glance
820

921
| ID | Role |
@@ -44,4 +56,4 @@ just build && just agent-linux
4456
# or CI: ./scripts/ci-bake-golden.sh
4557
```
4658

47-
See [Images guide](/docs/0.4.0/guides/images/).
59+
See [Images guide](../guides/images/).

docs/content/docs/0.4.0/explain/parity.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
---
2-
title: "Product surface"
2+
title: "Product surface (what’s done / experimental)"
33
description: "What grain implements for local Linux microVM sandboxes."
44
section: explain
5+
keywords:
6+
- parity
7+
- product surface
8+
- status
9+
- roadmap
10+
- features
11+
- experimental
512
---
613

14+
{{< only-need href="get-started/quickstart/" >}}
15+
Use the product first — this page is a capability checklist.
16+
{{< /only-need >}}
17+
718
grain’s local microVM product surface as of the v0.2 line.
819

920
## Complete for local sandboxes

docs/content/docs/0.4.0/explain/readiness.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
---
2-
title: Readiness protocol
3-
description: Contract for custom images and bootstrap authors so grain can report progress and only mark a sandbox ready when you say so.
2+
title: "Readiness protocol (custom images & bootstrap)"
3+
description: "Full contract: guest readiness files, agent health fields, wait=bootstrap, and when a sandbox is considered ready."
44
section: explain
5+
keywords:
6+
- readiness
7+
- bootstrap
8+
- wait bootstrap
9+
- userdata_ran
10+
- custom image
511
---
612

13+
{{< only-need href="get-started/bootstrap/" >}}
14+
Paste cloud-init, run `grain new --wait bootstrap`, and watch `grain status` — without reading the full contract first.
15+
{{< /only-need >}}
16+
717
Custom images and long first-boot setup need a **shared contract** with grain: how to report *what is happening*, when the sandbox is **done**, and when it **failed**—so `grain new`, create streams, `grain health`, and `grain status` stay accurate.
818

9-
This page is that contract. **Sandbox recipe files** (declarative create + bootstrap steps) are a later layer that *implements* this protocol; stock goldens already satisfy a compatible subset without changes.
19+
**Ready means:** the VM is up, the guest agent is healthy, and bootstrap completed with **zero failures** (`state=ready`). Failure or timeout does **not** report ready.
20+
21+
This page is the full contract. Stock goldens already satisfy a compatible subset without custom files. **Sandbox recipe files** (declarative create + bootstrap steps) are a later layer that *implements* this protocol.
1022

1123
## Goals
1224

@@ -179,7 +191,7 @@ Use **`--wait bootstrap`** only when your image or userdata implements this prot
179191

180192
## See also
181193

182-
- [Guest agent](/docs/0.4.0/guides/agent/)
183-
- [Profiles and presets](/docs/0.4.0/guides/profiles/)
184-
- [Images and golden boots](/docs/0.4.0/guides/images/)
185-
- [CLI](/docs/0.4.0/reference/cli/)
194+
- [Guest agent](../guides/agent/)
195+
- [Profiles and presets](../guides/profiles/)
196+
- [Images and golden boots](../guides/images/)
197+
- [CLI](../reference/cli/)

docs/content/docs/0.4.0/explain/security.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
---
2-
title: Security model
2+
title: "Security model (trust, proxy, secrets)"
33
description: What grain isolates, what it trusts, and how proxy and secrets fit.
44
section: explain
5+
keywords:
6+
- security
7+
- isolation
8+
- trust
9+
- API token
10+
- secrets
11+
- proxy
12+
- multi-tenant
513
---
614

15+
{{< only-need href="guides/remote-host/" >}}
16+
Team/shared host setup (token, bind, firewall) is covered in Remote sandbox host.
17+
{{< /only-need >}}
18+
719
## What grain gives you
820

921
- **Hardware virtualization boundary** between host and guest (QEMU/HVF or Firecracker/KVM)
@@ -49,7 +61,7 @@ Running grain on a team machine so developers create sandboxes remotely is a sup
4961
- Remote CLI: `GRAIN_API` / `--api` + `GRAIN_TOKEN`
5062
- Resource caps; published ports stay on host loopback
5163

52-
Full guide: [Remote sandbox host](/docs/0.4.0/guides/remote-host/).
64+
Full guide: [Remote sandbox host](../guides/remote-host/).
5365

5466
## Images
5567

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
---
2-
title: Get Started
2+
title: Get started
3+
description: "Install grain, open a first sandbox, or run custom bootstrap until ready."
34
section: get-started
45
---
6+
7+
Short paths into grain:
8+
9+
| Guide | When to use it |
10+
|-------|----------------|
11+
| [Quick start](quickstart/) | Install → config → shell in a few minutes |
12+
| [Install](install/) | Platforms, install options, QEMU |
13+
| [First sandbox](first-sandbox/) | Interactive demo + guided real create |
14+
| [Bootstrap until ready](bootstrap/) | Custom apt/scripts before create reports ready |
15+
| [Core concepts](concepts/) | Daemon, images, agent, ephemeral vs persistent |
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
title: "Bootstrap until ready (custom setup)"
3+
description: "Run packages or a setup script before grain says the sandbox is ready — with status you can watch."
4+
section: get-started
5+
keywords:
6+
- bootstrap
7+
- readiness
8+
- userdata
9+
- apt
10+
- setup script
11+
- wait bootstrap
12+
- custom image
13+
---
14+
15+
**Goal:** create a VM, run your install/setup steps, and only get a shell (or next command) when those steps finished **with zero failures**.
16+
17+
Stock `grain-ubuntu` is already “ready” when the agent is up. This page is for **custom** first-boot work (apt, scripts, image authors).
18+
19+
Deep reference: [Readiness protocol](../explain/readiness/).
20+
21+
---
22+
23+
## 1. What “ready” means here
24+
25+
A sandbox is ready when:
26+
27+
1. The **VM is up** and the **guest agent** is healthy, and
28+
2. Your **bootstrap** finished successfully (`state=ready`), with **no failed steps**.
29+
30+
If bootstrap fails, create errors and the VM is **left running** so you can inspect logs and fix.
31+
32+
---
33+
34+
## 2. Minimal path (cloud-init)
35+
36+
Save this as `bootstrap.yaml` on the **host**:
37+
38+
```yaml
39+
#cloud-config
40+
runcmd:
41+
- |
42+
set -euo pipefail
43+
dir=/var/lib/grain/readiness
44+
mkdir -p "$dir" /var/lib/grain
45+
46+
echo running >"$dir/state"
47+
echo packages >"$dir/phase"
48+
echo "installing git" >"$dir/message"
49+
50+
export DEBIAN_FRONTEND=noninteractive
51+
apt-get update -qq
52+
apt-get install -y -qq git
53+
54+
echo ready >"$dir/state"
55+
echo my-stack >"$dir/ready_name"
56+
date -u +"%Y-%m-%dT%H:%M:%SZ" >"$dir/updated_at"
57+
touch /var/lib/grain/userdata-ran
58+
```
59+
60+
Create and **wait for bootstrap**:
61+
62+
```bash
63+
grain up
64+
grain image pull grain-ubuntu # or your custom image
65+
grain new --userdata-file ./bootstrap.yaml --wait bootstrap -n lab
66+
```
67+
68+
While it runs you should see create progress mention bootstrap / your `message`. When it returns successfully, bootstrap completed with no failures.
69+
70+
```bash
71+
grain status lab
72+
grain health lab
73+
grain sh lab
74+
```
75+
76+
---
77+
78+
## 3. Report progress from a script
79+
80+
Inside the guest (or in runcmd), use the same files — or copy [scripts/grain-ready-report.sh](https://github.com/cxdy/grain/blob/main/scripts/grain-ready-report.sh) into the image:
81+
82+
```bash
83+
grain-ready-report running packages "apt-get install …"
84+
# … work …
85+
grain-ready-report ready
86+
# on error:
87+
# grain-ready-report failed "" "setup.sh exit 1"
88+
```
89+
90+
Files live under `/var/lib/grain/readiness/` (`state`, `phase`, `message`, `error`, …).
91+
92+
---
93+
94+
## 4. Watch status
95+
96+
```bash
97+
grain status lab
98+
# lab status=running … readiness=running phase=packages "installing git"
99+
100+
grain health lab # full JSON including readiness
101+
```
102+
103+
---
104+
105+
## 5. Common failures
106+
107+
| Symptom | Check |
108+
|---------|--------|
109+
| Create hangs on bootstrap | Guest never wrote `state=ready` — look at `grain logs -f lab` |
110+
| Create errors, VM still there | Bootstrap wrote `state=failed` or timed out — `grain status` / logs, then `grain rm lab` |
111+
| Stock image, no custom setup | Use default wait (`agent` for goldens); you don’t need this guide |
112+
113+
---
114+
115+
## Next
116+
117+
- Full contract (states, wait modes, agent API): [Readiness protocol](../explain/readiness/)
118+
- Named create defaults: [Profiles & presets](../guides/profiles/)
119+
- Baking faster images later: [Images](../guides/images/)

0 commit comments

Comments
 (0)