Skip to content
Edit this page

Describe your platform with k8s-servant onboard

The agent is only as good as what it knows about your platform: what runs there, how traffic is kept in check, where monitoring lives and what is normal noise. Writing that down by hand takes a day. k8s-servant onboard scans the cluster once and writes a first draft of the knowledge files for you to review, so you start from facts with evidence instead of an empty page.

What it does and never does

  • Read-only. The scan runs only fixed kubectl get ... -o json and kubectl version -o json calls, plus read-only GET requests to Prometheus and Alertmanager (Alert history). The scan builds these calls itself, never from model or human text.
  • No Secrets. It never asks for Secrets, the same rule as the rest of the agent (security.md).
  • No files overwritten. If a file it would write already exists (settings.env included), it stops before the scan and names the file. --force overwrites, and replaces a symlink rather than writing through it.
  • Nothing unproven stated. A line in the draft is either a fact with its evidence, a fact a human confirmed, an answer from the team, or an open question. The scan never guesses.
  • stdout carries only the paths it wrote. Questions, notes and the closing summary go to stderr.

Run it from a laptop

Point kubectl at the cluster (the scan uses your current context and your own access) and run:

k8s-servant onboard

Not installed yet? uvx k8s-servant onboard runs it once without installing, and uv tool install k8s-servant (or pipx install k8s-servant) keeps it (getting-started.md).

The first question decides where facts go:

Is this cluster representative of your platform (its components, network design and
monitoring are the same on the other clusters)? [y/n]
  • Yes: components, service mesh, secret management, monitoring and network design go into the platform file (knowledge-values.yaml, the environment description). The Kubernetes version, node pools, counts, service URLs and noise stay in the cluster file.
  • No (and always with --no-input, or when stdin is not a terminal): everything goes into the cluster file, and no platform file is written.

Then it walks through what it is unsure of, one fact at a time:

Outbound pod traffic is denied by default in 3 namespaces, except DNS, 10.0.0.0/8
I read this as: outbound traffic is denied by default except DNS, 10.0.0.0/8. Correct?
[y]es / [n]o / [a]dd a note / [s]kip: y

y keeps the fact, n drops it, a replaces it with your own words, and s (or Enter) leaves it as an open question. After that it asks about what it cannot see at all (blind spots), each of which you can skip.

With a model configured, the model then writes a short overview (2 to 4 sentences) from the proven facts only. Without a model, or with --no-model, the draft is complete without it.

At the end it prints the files it wrote:

k8s-servant-onboard/knowledge-values.yaml
k8s-servant-onboard/my-cluster.yaml
k8s-servant-onboard/settings.env
File Holds Written
knowledge-values.yaml knowledge.environment: the platform description Only when the cluster is representative
<cluster>.yaml knowledge.clusterNotes, and appConfig with the suggested settings Always
settings.env The same suggested settings, as NAME=value lines for your shell Always

With --format markdown the knowledge goes to environment.md (only when representative) and cluster.md instead, for KNOWLEDGE_DIR; settings.env is the same in both formats.

Reviewing the draft

An excerpt of a real draft, from the test fixture of an AKS cluster, after answering y to the representative question, y to the egress question above and to the KubeCPUOvercommit question, and giving the maintenance window:

# Generated by `k8s-servant onboard` from cluster my-cluster on 2026-10-21 09:30 UTC.
# Review before use: check every line, answer each TODO(onboard), then commit.
knowledge:
  environment: |
    ## Components

    - Kyverno (policy engine) runs in namespace `kyverno` [CRD group kyverno.io; Deployment kyverno/kyverno-admission-controller (3 ready)]
    - TODO(onboard): Which components of the platform run outside the cluster (mesh servers, DNS, registries, databases)?

    ## Network

    - Outbound pod traffic is denied by default in 3 namespaces, except DNS, 10.0.0.0/8 [NetworkPolicy shop/default-deny-egress; NetworkPolicy payments/default-deny-egress]
    - TODO(onboard): All load balancers are internal. Is ingress internal only?

    ## What is normal here

    - Maintenance and node reboot windows: Sundays 02:00-04:00 UTC (from the team)

and from my-cluster.yaml:

knowledge:
  clusterNotes: |
    ## Platform

    - Kubernetes v1.31.2 [kubectl version]
    - Node pool `user`: 3 nodes, 3× Standard_D8s_v5 [3 nodes with label kubernetes.azure.com/agentpool=user]
appConfig:
  # Name shown in reports and Teams cards
  # TODO(onboard): Set the real cluster name.
  CLUSTER_NAME: "my-cluster"
  # Prometheus service found in namespace monitoring; checked: it answered through the API server proxy
  PROMETHEUS_URL: "http://kps-prometheus.monitoring.svc:9090"
  # Alerts left out of reports
  ALERTS_IGNORE_NAMES: "Watchdog,InfoInhibitor,KubeCPUOvercommit"

How to read it:

  • Evidence in brackets. Each scanned fact ends with the objects that prove it (at most two). A scanned fact without evidence is left out.
  • TODO(onboard): ... marks every open point: a fact the scan was unsure of, a question you skipped, a blind spot nobody answered. Find them all with grep -n "TODO(onboard)" k8s-servant-onboard/*. Answer each one (replace the line with a fact) or delete it.
  • (from the team) marks an answer you gave. A blind-spot answer is written as <label>: <your answer> (from the team), for example Maintenance and node reboot windows: Sundays 02:00-04:00 UTC (from the team). Your notes are kept word for word; the model never rewrites them.
  • Suggested settings come only from facts that were seen or that you confirmed. A setting from an unsure fact is a commented-out line with its question. The noise lists (ALERTS_IGNORE_NAMES, EVENTS_EXCLUDE_REASONS) get a value line only when you confirmed a name; the value is then today's list plus that name. Otherwise the setting stays a comment, so the draft never pins today's defaults.
  • The header says when and from which cluster the draft was made, and lists the inputs that could not be read (Not checked: ...).

Then use the files:

  • In the cluster: pass both to Helm, platform file first: -f knowledge-values.yaml -f my-cluster.yaml (deployment.md). Both the knowledge and the appConfig parts apply.
  • On a laptop: k8s-servant --values knowledge-values.yaml --values my-cluster.yaml ... loads only the knowledge part, because settings come only from environment variables (configuration.md). Load the settings from the settings.env the draft wrote next to it: set -a; source k8s-servant-onboard/settings.env; set +a.

Flags

Flag Meaning
--out DIR Folder for the draft. Default: k8s-servant-onboard
--format {values,markdown} values (default): Helm values files plus settings.env. markdown: environment.md, cluster.md and settings.env
--force Overwrite files that already exist, settings.env included (a symlink is replaced, never written through)
--no-input Ask nothing. Everything goes into the cluster file and every doubt stays a TODO(onboard): line
--no-model Do not ask the model for the overview. No model call, no tokens
--cluster-name NAME Cluster name for the draft and the file name. Default: CLUSTER_NAME, else my-cluster
--show Print the cluster values file from the last stored scan; no scan, no questions, no model. Takes no other option (in the cluster)

Exit codes: 0 when the files were written, 1 when a file already exists (any of the draft files, settings.env included), the cluster could not be read or the folder could not be written (and for --show without a stored scan), 2 when --show is combined with another option.

What it discovers

Topic What the scan reads off the cluster
Platform Kubernetes version; the managed service (AKS, EKS, GKE) from node labels, or a kind cluster; node pools with their node count and instance types
Components GitOps (Flux, Argo CD), policy engines (Kyverno, Gatekeeper), cert-manager, ingress and gateway controllers, autoscalers, backup and similar, from a list of well-known components (missed one?)
Service mesh Istio, Linkerd, Consul, Cilium's mesh, egress gateways
Secret management External Secrets Operator, the Secrets Store CSI driver and its providers, Sealed Secrets, the Vault injector (the tools only; never a Secret)
Monitoring Prometheus, Alertmanager, Grafana, Loki, log shippers, OpenTelemetry; the Prometheus and Alertmanager services to suggest as PROMETHEUS_URL and ALERTMANAGER_URL
Network The CNI; default-deny NetworkPolicies and their exceptions; Calico and Cilium cluster-wide policies; LoadBalancer services and whether they are internal-only; ingress classes; Gateway API gateways
Organisation How many namespaces belong to the platform and how many to applications, and the labels most application namespaces carry
What is normal here Alerts that fire most of the week, warning event reasons that dominate, containers that restart often but run, findings open for days. Always asked, never stated: the scan sees that something repeats, not whether it is meant to

A component counts as running only when its controller is ready and, where it has them, its CRDs or webhooks are installed. CRDs without a controller, a controller without its CRDs, or only a namespace with the right name become questions, never statements. An input that could not be read (for example forbidden by RBAC) costs only the facts that need it, and is named in the draft's header.

What it cannot see

Some things are outside the cluster, so the scan asks about them every time (each can be skipped):

  • how outbound traffic leaves the cluster (firewall, proxy, NAT gateway) and which destinations are allowed;
  • services reached through private endpoints or peered networks;
  • what sits in front of inbound traffic (WAF, application gateway, CDN);
  • maintenance and node reboot windows;
  • whether the cluster is stopped or recreated on a schedule;
  • platform components that run outside the cluster (mesh servers, DNS, registries, databases).

Alert history

To tell recurring noise from real incidents, the scan reads which alerts fired over the last 7 days (Prometheus) and which fire now (Alertmanager). It reaches them, in order:

  1. at PROMETHEUS_URL and ALERTMANAGER_URL when they are set. A configured URL that fails is named in the draft's header before the next way is tried;
  2. else through the API server's service proxy (kubectl get --raw .../proxy/..., a read-only GET with your own access), to a Prometheus or Alertmanager service found in a namespace where the catalog saw its controller running. A service in any other namespace is never queried. With several candidates the scan does not pick one: it asks which one to use;
  3. else noise comes from warning events and restarts only, and the draft's header says alert history could not be read.

The suggested PROMETHEUS_URL comment says whether the service answered through the proxy (checked) or not (not checked).

In the cluster

Re-scan before the morning report

In the pod, the scheduler runs the same scan before each morning report: no model, no questions, no tokens. It compares the facts with the last stored scan (kept in memory, under DATA_DIR) and adds a "Since the last scan" section to the report and its Teams card (reports.md). Nothing is changed for you: you copy what you agree with into your values files. SCAN_BEFORE_REPORT=false turns it off (configuration.md).

  • The first scan is a baseline, reported once as First scan recorded: 13 components, 2 node pools, not as a list of additions.
  • Noise is left out of the comparison, because it changes every day.
  • Each input is judged on its own. Facts from an input that failed this time (a forbidden list, a timeout) are kept from the last scan and never shown as removed. When a detector crashes, nothing is shown as removed either, until the next clean scan.
  • Failures are not repeated every day. An input that fails is listed once, when it starts failing ("Not checked this time: ..."). A crashed detector is a bug, so it is listed in every report while it lasts.
  • A scan that cannot read the cluster at all changes nothing in memory, the same rule as for health checks.
  • A manual k8s-servant report re-scans too, through the same code path as the scheduler. It stores the scan, so the changes it shows are not shown again by the next scheduled report.

Each change comes with what to do about it:

- Added: cert-manager (certificate manager) runs in namespace `cert-manager` — add the line "- cert-manager (certificate manager) runs in namespace `cert-manager`" to knowledge.environment
- Gone: Velero (backup) runs in namespace `velero` — remove it from knowledge.environment
- Changed: Node pool `user`: 2 nodes, 2× Standard_D8s_v5 → Node pool `user`: 3 nodes, 3× Standard_D8s_v5 — replace it in knowledge.clusterNotes

When the new fact comes with a suggested setting, the line also names it, ending in and appConfig.<KEY>: <value>:

- Added: Prometheus service in the cluster: http://kps-prometheus.monitoring.svc:9090 — add the line "- Prometheus service in the cluster: http://kps-prometheus.monitoring.svc:9090" to knowledge.clusterNotes and appConfig.PROMETHEUS_URL: http://kps-prometheus.monitoring.svc:9090

A change the scan is unsure of is shown as a question (Added (unsure): ...), never as a line to paste. "Added" lines for platform facts (components, service mesh, secret management, monitoring stack, network design) point at knowledge.environment, while --show puts every fact in clusterNotes: the stored scan does not know whether the cluster was representative. Paste each line where that fact lives in your files.

Taking the draft from the pod

kubectl -n k8s-servant exec deploy/k8s-servant -c agent -- k8s-servant onboard --show

prints the cluster values file built from the last stored scan, with every fact in clusterNotes (no platform file) and the suggested settings. It scans nothing, asks nothing and calls no model. The pod's filesystem is read-only, so use --show there rather than writing files; redirect the output on your side (... --show > my-cluster.yaml). The scan is stored before each morning report, and by a manual k8s-servant report in the pod; until one of them has run there is no stored scan yet, and --show says so.

What the pod cannot check

The chart's RBAC stays read-only and narrow on purpose. It does not grant ingress classes or the Calico and Cilium policy resources, and the pod cannot use the API server's service proxy. In the pod those inputs show as "Not checked", and alert history comes from the configured PROMETHEUS_URL and ALERTMANAGER_URL. That is expected: no new RBAC is needed. Run k8s-servant onboard from a laptop for the full picture.

The scan missed a component?

The scan recognises a fixed list of well-known components (Flux, Kyverno, Istio, cert-manager and similar). Vendor products and in-house tools are often not on it. That affects only the first draft: the agent still sees those components when it investigates, because it reads the cluster through its tools.

Add what the scan missed to the draft yourself, in your own words. The draft is your file, and the environment description is the right place for it:

knowledge:
  environment: |
    ...
    - ExternalDNS (namespace `external-dns`) manages DNS records for Services and Ingresses.

You can also answer [a]dd a note to any question during onboard. Recognising components without a fixed list is planned: #67.