140 lines
6.5 KiB
Markdown
140 lines
6.5 KiB
Markdown
# Jeannie Remote API
|
|
|
|
The private remote-execution API exposes the public Jeannie command surface.
|
|
The local Jeannie remote client submits a command to a Jeannie API running on
|
|
Debian. The Debian process executes the existing Jeannie entrypoint; command
|
|
logic is not duplicated in the API.
|
|
|
|
## Run locally
|
|
|
|
Start the server from the Debian checkout:
|
|
|
|
JEANNIE_SERVER_ADDR=127.0.0.1:8787
|
|
JEANNIE_SERVER_TOKEN='replace-with-a-secret'
|
|
JEANNIE_SERVER_REPO_ROOT=/path/to/my-homelab-configs
|
|
./scripts/jeannie-server
|
|
|
|
From a client with network access:
|
|
|
|
JEANNIE_REMOTE_URL=http://debian:8787
|
|
JEANNIE_REMOTE_TOKEN='replace-with-a-secret'
|
|
./jeannie remote status
|
|
|
|
Scoped status and doctor commands are available through the same API:
|
|
|
|
./jeannie remote status cluster
|
|
./jeannie remote doctor rpi
|
|
./jeannie remote doctor gitea-runner --details
|
|
|
|
The remote process is noninteractive. If a doctor identifies a supported
|
|
mitigation, it prints the proposed command for review instead of waiting for
|
|
interactive approval or applying it through the report.
|
|
|
|
`GET /v1/commands` returns the complete remotely enabled command list. Internal
|
|
`__up-task` and recursive `remote` dispatch are excluded. This API therefore
|
|
has the same authority as the bearer token and should remain private; commands
|
|
such as `nuke`, `rebuild-cluster`, and `stop-cluster` are available remotely.
|
|
Execution state is stored in memory and command output is returned through
|
|
GET /v1/executions/{id}. It is not a public edge service and does not accept
|
|
arbitrary shell commands.
|
|
|
|
The API includes `ai-lab`, `gateway-lab`, `secrets-lab`, `progressive-lab`,
|
|
and `goose-graph`. For example, `./jeannie remote ai-lab suite 3` runs the
|
|
suite on Debian. AI lab installation and suite commands have a two-hour limit;
|
|
other commands retain the 30-minute limit. The output arrives when the
|
|
execution finishes, rather than streaming live. The API and Temporal worker
|
|
must both be updated for the extended Temporal activity limit.
|
|
|
|
Remote AI lab installation needs non-interactive sudo for the API service user
|
|
when system packages must be installed. The lab fails with an explanatory error
|
|
if it cannot get it; a user can run the install from a Debian terminal instead.
|
|
`goose-graph update` and `context` are available remotely. Its `learn` and
|
|
`propose` modes require an interactive terminal and are rejected by the API.
|
|
|
|
`cluster-runtime check` and `cluster-transition k3s-to-native [--yes]` are
|
|
allowlisted as well. The transition runs on Debian, archives the accidental
|
|
laptop K3s state, prepares verified registry storage on the declared ARM host,
|
|
and then deploys cluster/platform/apps. It preserves the old data and refuses
|
|
identity mismatches. Redeploy the API binary after updating its allowlist.
|
|
|
|
`cluster-transition k3s-runtime-to-ssd [--yes]` uses the same command boundary
|
|
to move the enrolled native K3s runtime to its declared mounted data disk. The
|
|
transition is journaled and preserves a verified rollback copy.
|
|
|
|
The authenticated `GET /metrics` endpoint exposes Prometheus-compatible HTTP
|
|
request counters, request duration totals, and authentication-failure counts.
|
|
It is served by the Debian API process, so metrics remain available while
|
|
Kubernetes is stopped; Prometheus may scrape it when the cluster is healthy.
|
|
Run the platform pipeline with `JEANNIE_SERVER_TOKEN` set to enable the
|
|
authenticated `jeannie-api` scrape job in kube-prometheus-stack.
|
|
|
|
## Edge API gateway
|
|
|
|
The canonical public route publishes the Debian API directly through the OCI
|
|
edge proxy at `api.lab2025.duckdns.org`. The backend remains the Debian host
|
|
at `192.168.100.73:8787`; Kubernetes does not run a second Jeannie server and
|
|
is not required for API availability.
|
|
|
|
The edge gateway applies a per-client rate limit of 2 requests per second with
|
|
no burst, forwards the bearer token to Debian, and uses 35-second
|
|
proxy read/write timeouts. The Jeannie API remains responsible for bearer
|
|
authentication and command allowlisting. Read-only retries are not enabled at
|
|
the edge; `POST /v1/execute` is never retried so a command cannot be submitted
|
|
twice by a proxy.
|
|
|
|
The Kubernetes `jeannie-api` route may remain available for internal testing,
|
|
but it is not the availability-critical path. Traefik continues to expose
|
|
Kubernetes request metrics, while the edge proxy records the canonical API
|
|
traffic in its access logs.
|
|
|
|
The Temporal UI is bound to `127.0.0.1:8233` by default because Debian uses
|
|
port 8088 for the provisioning service. Override it during deployment with
|
|
`JEANNIE_TEMPORAL_UI_PORT` if needed.
|
|
|
|
For a LAN test after the edge/DNS certificate is available, use the host's
|
|
LAN address or a local DNS override. Direct backend testing remains:
|
|
|
|
curl -H 'Authorization: Bearer replace-with-a-secret' \
|
|
http://192.168.100.73:8787/v1/health
|
|
|
|
Through the canonical gateway, use the API hostname and the OCI edge address.
|
|
For a controlled test without changing DNS, use `curl --resolve` with the
|
|
edge public IP.
|
|
|
|
### Operational cluster selection
|
|
|
|
The remote client uses Bash and Python's standard library; it does not load
|
|
local inventory, kubeconfigs, or PyYAML. Cluster resolution happens on Debian.
|
|
|
|
CLI diagnostics, remote API/Temporal jobs, and the self-heal webhook share the
|
|
inventory profile resolver. Persist the intended enrolled cluster on Debian:
|
|
|
|
```bash
|
|
./jeannie cluster-profile select k3s
|
|
./jeannie cluster-context check
|
|
```
|
|
|
|
The selection is stored in `~/.local/share/homelab/active-cluster.json` under the
|
|
execution user's state directory. API and service commands read it for each
|
|
operation and replace stale inherited kubeconfig/runtime variables. One operation
|
|
keeps its selected profile throughout execution. Local interactive commands may
|
|
override it using `LAB_CLUSTER_PROFILE`; successful cluster startup, platform,
|
|
and apps runs remember that selection. Selecting a profile does not switch the
|
|
running runtime; runtime exclusivity and pinned identity checks still apply.
|
|
|
|
The same selection command is available through the API allowlist:
|
|
|
|
```bash
|
|
./jeannie remote cluster-profile select k3s
|
|
./jeannie remote status
|
|
./jeannie remote doctor-cluster
|
|
```
|
|
|
|
`status` and doctor reports include profile, runtime, kubeconfig, and enrolled
|
|
namespace UID. Healing refuses reports from a different cluster incarnation.
|
|
After updating this code, redeploy `./jeannie platform monitoring` and reinstall
|
|
`./jeannie self-heal install-service --apply` to activate matching alert identity
|
|
labels and the updated webhook. Rebuild/redeploy the API once with
|
|
`./jeannie deploy-api` to update both Go execution paths. After that, changing
|
|
the saved selection requires no API or Temporal restart.
|