Operations Lens¶
Maturity: preview
The operations lens is under active development. Its REST API and UI may change between minor releases. See the Roadmap for every feature’s status.
The operations lens answers three questions about a deployment:
What does this release declare?
What is actually running in the cluster?
How do I reach a service safely from my machine?
It works from a deployment session archive and an explicitly selected kubeconfig. It is available as a Python API, as JSON CLI commands, and as a small local web UI with a REST API.
Where it runs¶
The lens runs on the operator’s own machine, not inside the cluster.
It serves on loopback only (
127.0.0.1); binding to another address is refused.It uses the kubeconfig and context you pass explicitly and never falls back to ambient credentials.
--contextis required on every command that takes--kubeconfig: the file’scurrent-contextis never used, neither by the lens nor by thekubectlprocesses it starts (they always get--context).The kubeconfig goes through the same checks as
piceli release: proxies,insecure-skip-tls-verify, non-https servers and legacyauth-providerusers are refused (target-refused,auth-provider-refused). A context whose user runs an exec credential plugin (GKE, EKS, AKS, OIDC) needs--allow-exec, optionally with--exec-sha256 sha256:…; see Connect to managed clusters (GKE, EKS, AKS). For commands that runkubectl(forward-run,logs-run,forwards apply, the UI’s pods and logs) the plugin is resolved and pinned first, butkubectlruns it with your environment.Refusals print
{"state": "refused", "reason": …, "code": …}and exit2.Port forwards are
kubectl port-forwardprocesses it starts and supervises itself. They bind to loopback, and it never adopts or kills processes it did not start.Cluster credentials never leave your machine, and workloads in the cluster cannot reach the lens.
Reconcile a session with the cluster¶
piceli observe status \
--archive ./session.archive.json \
--kubeconfig ./my-cluster.kubeconfig --context my-cluster
The JSON report classifies every object:
Classification |
Meaning |
|---|---|
Declared |
Part of the session archive and present in the cluster. |
Missing |
Declared by the archive but not found in the cluster. |
Undeclared |
Present in the namespace but not part of the archive. This is information only; Piceli never adopts or deletes such objects automatically. |
Unknown |
Could not be inspected (for example a transient API error). Never treated as absent. |
Logs¶
# Print the exact kubectl argv without running it
piceli observe logs-command --namespace my-app --target deployment/api --tail 200 \
--kubeconfig ./my-cluster.kubeconfig --context my-cluster
# Run it in the foreground
piceli observe logs-run --namespace my-app --target deployment/api --tail 200 \
--kubeconfig ./my-cluster.kubeconfig --context my-cluster
Saved port forwards¶
Forward preferences are stored per local user as non-secret JSON with owner-only
permissions (default ~/.config/piceli/observe.json, or --preferences PATH).
piceli observe forward-save --user "$USER" --name api \
--namespace my-app --target service/api \
--local-port 18080 --remote-port 8080 \
--kubeconfig ~/.kube/config --context my-cluster
piceli observe forward-list --user "$USER"
piceli observe forward-run --user "$USER" --name api \
--kubeconfig ./my-cluster.kubeconfig --context my-cluster
--kubeconfig and --context on forward-save scope the preference to
that cluster and context: Piceli stores the context name and a digest of the
context’s API server URL (never the kubeconfig path). A saved forward is only
ever started automatically by a dashboard for the same cluster, context and
namespace, and only when you ask for it (see below). A preference saved
without them is unscoped: forward-list shows it and forward-run runs it,
but no dashboard restores it.
Web UI and REST API¶
piceli observe serve --archive ./session.archive.json \
--kubeconfig ./my-cluster.kubeconfig --context my-cluster \
--user "$USER" --port 9876 --ui-config ./piceli-ui.toml
The dashboard after deploying the shop example (Deploy an app from source), served with
piceli access examples/shop/app.py:pipeline --dashboard 9876: the model’s
forwards as one-click shortcuts, the active release, and each declared
object compared with the cluster (ReplicaSets and Pods of a managed
Deployment are shown as derived).¶
Open http://127.0.0.1:9876/. --user names whose saved forwards the
dashboard manages; forwards you add in the dashboard are saved for this
cluster, context and namespace. --namespace defaults to the archive’s
namespace when the archive has exactly one. The page refreshes every few
seconds.
Saved forwards are never started implicitly. piceli observe serve and
piceli operator serve start them only with --restore-forwards, and then
only the ones saved for the same cluster (API server digest), context and
namespace as the command. Forwards saved for another cluster or namespace, or
without a scope, are left alone, and the command says how many it skipped:
piceli operator serve --kubeconfig ./kind.kubeconfig --context kind-shop \
--namespace shop --preferences ./observe.json --restore-forwards
piceli: restored 1 saved forward(s): web
piceli: left 2 saved forward(s) alone: saved for another cluster, context or namespace, or without a scope
Without --preferences, the default file for --user (default $USER) is
used, but only read when you pass --restore-forwards or save a forward from
the dashboard. GET /v1/preferences lists only this user’s forwards for this
cluster, context and namespace (none from piceli access --dashboard, which
has no saved forwards). Access forwards declared in the model are different:
they are part of the app, so operator serve --access TARGET starts them (see
Reach your services from your laptop).
The same data is available as JSON:
Endpoint |
Purpose |
|---|---|
|
Liveness |
|
Declared vs. live inventory |
|
Saved and running forwards, with connection health |
|
Configured shortcuts, with connection health |
|
Pods and bounded log tails |
|
Manage forwards |
Every /v1/* request, GET included, needs either the per-process token
embedded in the page (X-Piceli-Local-Token header) or a bearer token for a user
in the operator user store. Bearer users with the viewer role are read-only. The
server only answers requests whose Host is 127.0.0.1, localhost or [::1]
on its own port, and it rejects cross-origin requests. This protects against DNS
rebinding. Responses carry a strict Content-Security-Policy. Error bodies contain
fixed error codes only; details go to the server log.
Interactive elements carry stable data-testid attributes, so the UI can be
driven by browser automation and AI agents.
Dashboard configuration¶
Without configuration the dashboard shows no shortcuts and groups live workloads
by their app.kubernetes.io/component label (falling back to app). An app
declared with the typed model can supply the shortcuts itself
(app.access.forward, see Reach your services from your laptop): run piceli access TARGET --dashboard PORT, or pass --access TARGET to operator serve; the TOML file
below then only adds badges, tiers or extra shortcuts. To add
one-click shortcuts, topology tiers and header badges, pass a TOML file with
--ui-config (or set PICELI__UI_CONFIG) on observe serve or operator serve:
topology_subtitle = "My application tiers"
[[shortcuts]]
id = "web"
label = "Web UI"
target = "service/web" # service/<name>, deployment/<name> or pod/<name>
local_port = 3000
remote_port = 3000
path = "/login" # optional: path opened by the "Open" link
[[tiers]]
name = "Application"
components = ["web", { name = "worker", role = "Task worker" }]
[inventory]
# extra labels that mark live objects as managed by this application
managed_labels = { "app.kubernetes.io/part-of" = "my-app" }
revision_label = "my-app/revision"
A shortcut uses its own namespace if set, otherwise the namespace being served.
Unknown keys are rejected, so typos fail fast. A complete example lives in
examples/ui-config.toml.
Access profiles and connection health¶
A running kubectl port-forward process is not proof that its connection
works: when the upstream pod goes away, the process can stay alive while it
resets every connection. The supervisor therefore probes each forward it owns
and restarts one whose probe keeps failing.
An access profile is the same TOML file as --ui-config. Each shortcut may add
a health probe and a restart policy:
[[shortcuts]]
id = "api"
label = "HTTP API"
target = "service/api"
namespace = "my-app" # optional; otherwise --namespace
local_port = 18080
remote_port = 8000
required = true # false: skip it when the local port is taken
[shortcuts.health]
type = "http" # "tcp" (default) or "http"
path = "/healthz"
expect_status = [200, 399]
interval = 5.0 # seconds between probes
timeout = 2.0
failure_threshold = 3 # consecutive failures before a restart
startup_grace = 3.0 # failures right after a (re)start don't count
[shortcuts.restart]
backoff_initial = 1.0 # doubles per consecutive restart ...
backoff_max = 30.0 # ... up to this cap
max_restarts = 10 # then the forward is marked failed
A
tcpprobe connects to the loopback port and watches the connection for a moment (settle, 0.3 s by default). A forward whose upstream is gone accepts the connection and then closes or resets it, which counts as a failure.An
httpprobe sendsGET pathand expects a status withinexpect_status. The olderhealth_path = "/x"key still works: it is an HTTP probe that accepts any status below 500. Use eitherhealth_pathor[shortcuts.health], not both.max_restartscounts consecutive restarts without a healthy probe in between. After that the forward stays stopped with statefaileduntil you start it again.Probes only contact
127.0.0.1. They never send credentials.
Start and supervise every declared forward in the foreground:
piceli observe forwards apply --profile ./access.toml \
--kubeconfig ./my-cluster.kubeconfig --context my-cluster --namespace my-app
Before it starts anything, apply runs a port-conflict preflight. If another
process already serves a required shortcut’s local port, it prints
{"state": "rejected", "reason": "forward-port-conflict", "message": "…", "ok": false, "preflight": {…}} on stdout and exits with code 2 without
starting any forward (before 0.4.0 this object went to stderr, without
state/reason). An optional
shortcut (required = false) on an occupied port is listed as external and
skipped. While running, it prints one JSON line per status change and stops
every forward it owns on Ctrl-C, SIGTERM or SIGHUP. Use --only ID
(repeatable) to supervise a subset.
To check the declared endpoints once and print JSON, run
piceli observe forwards status --profile ./access.toml. It probes loopback
only and exits with code 1 if a required forward is unhealthy
("state": "failed", "reason": "forward-unhealthy"; otherwise
"state": "healthy").
Every observe and operator command prints machine JSON on stdout and human
text on stderr. A rejection prints {"state": "rejected", "reason": "<code>", "message": "…"} on stdout and exits 2, for example invalid-session-archive,
invalid-access-profile, unknown-shortcut, local-port-in-use,
no-saved-forwards, unknown-forward, invalid-log-request or
kubeconfig-rejected (piceli explain <code> for each). Before 0.4.0 some
of these were usage errors or tracebacks.
To get the dashboard with the same forwards, pass the profile as --ui-config
and add --start-shortcuts to observe serve.
Each forward’s status (/v1/forwards, /v1/shortcuts, and the dashboard) has
these fields:
Field |
Meaning |
|---|---|
|
Process state: |
|
Connection health: |
|
Restarts since the forward was added |
|
Probe failures since the last healthy probe |
|
Last failure reason and last probe time (UTC) |
|
The effective probe settings |
|
On a |
A local port that another process already serves is reported as conflict,
with the owning process in owner and in the error text. The supervisor never
kills that process and never spawns a forward on the port. A conflict is final
(state failed) until the forward is started again explicitly: the supervisor
does not wait for the port to free up and then silently take it back, so two
dashboards (or a dashboard and piceli access) never trade a declared port
behind your back.
The broader operator features (releases, promotion, backups) are described in Operator Workflow.