> ## Documentation Index
> Fetch the complete documentation index at: https://aivision.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Read the relevant procedure and prerequisites before suggesting commands. Cite the section and give an observable check. Treat sample data as illustrative. Report product actions and results only when verified in the user's environment.

# Kubernetes deployment

> Configure, deploy and verify the platform on an existing Linux Kubernetes cluster without a Skill.

This page describes a manual flow using the `aiv` CLI directly. You do not need to install a Skill or clone the source. The recommended [aivision-deploy Skill](https://github.com/ob-labs/ai-vision-skills/tree/main/skills/aivision-deploy) can also guide deployment; explicitly choose Kubernetes and provide the target context.

If you do not have a cluster and want to try the platform, start with [manual Docker deployment](https://aivision.mintlify.site/en/deployment/docker.md). For an existing cluster, follow the steps below. **The current Kubernetes flow supports only OceanBase CE managed by OB Operator; neither bundled nor external seekdb is supported.** To use lightweight seekdb, choose [Docker deployment](https://aivision.mintlify.site/en/deployment/docker.md).

Compare [deployment choices and shared roles](https://aivision.mintlify.site/en/deployment/overview.md) before selecting this path. Fixed Kubernetes resources deploy the same applications with their own initialization and readiness gates. Helm is planned but unavailable; generic `aiv generate --target kubernetes` does not provide this product lifecycle.

## 1. Check the cluster and clients

Prepare `kubectl` and complete [CLI installation](https://aivision.mintlify.site/en/guides/install-cli.md), including a fixed installation, persistent PATH and verification in a new terminal. You need Kubernetes 1.33–1.36, administrator access, a usable StorageClass, and network access to GHCR and dependency image registries. Creating a local kind cluster separately requires Docker. First choose the target with `kubectl config get-contexts`, then replace `YOUR_CONTEXT` below before running cluster checks.

A nominal **4 CPU / 16 Gi** cluster is an evaluation scheduling floor, not measured production sizing. Preflight requires at least **3.4 CPU / 14 Gi free by Pod requests**, including **2 CPU / 10 Gi on one untainted Linux node**. PVC requests total **130 Gi**; provision at least **140 Gi** of backing disk. These figures exclude some controller and system overhead and do not allow every configured limit to burst simultaneously. Preflight cannot prove the storage provisioner's physical free space. See the [resource contract](https://github.com/ob-labs/ai-vision-ob/blob/main/deploy/kubernetes/lifecycle.md#resource-baseline).

Use matching images and a CLI that include backend `/api/v1/ready`, diagnosis `/internal/readyz` and organization handoff, gateway native `/app/collector healthcheck --ready`, data-backend `/api/v1/ready`, and the matching shutdown fixes. A source merge, old downloaded CLI or rolling `dev` tag does not establish image compatibility. Data-backend readiness executes telemetry-store `SELECT 1` with a one-second deadline; local health remains separate. See [image requirements](https://aivision.mintlify.site/en/deployment/overview.md#use-matching-deployment-material-and-images) and [liveness versus readiness](https://aivision.mintlify.site/en/deployment/overview.md#health-readiness).

```bash theme={null}
aiv --version
kubectl version --client
kubectl config get-contexts
kubectl config current-context
kubectl --context YOUR_CONTEXT get nodes
kubectl --context YOUR_CONTEXT get storageclass
```

Select the actual target context before running cluster checks. Replace `YOUR_CONTEXT` and `YOUR_REACHABLE_NODE_IP` below; do not reuse a local kind example's context name for another cluster.

## 2. Choose the public endpoint and configuration first

Run these steps on a management machine with access to the target cluster. Create and enter a fixed deployment directory, then run subsequent commands there. For an existing deployment, enter its original directory and edit the original file.

```bash theme={null}
mkdir -p "$HOME/aivision-kubernetes"
cd "$HOME/aivision-kubernetes"
```

In a text editor, save the following as `aivision.kubernetes.vars.yaml` in that directory and replace the node IP. This example uses an HTTP NodePort on a directly reachable cluster node:

```yaml theme={null}
FRONTEND_IMAGE: "YOUR_VERIFIED_FRONTEND_IMAGE"
BACKEND_IMAGE: "YOUR_VERIFIED_BACKEND_IMAGE"
DIAGNOSIS_IMAGE: "YOUR_VERIFIED_DIAGNOSIS_IMAGE"
INGEST_GATEWAY_IMAGE: "YOUR_VERIFIED_INGEST_GATEWAY_IMAGE"
DATA_BACKEND_IMAGE: "YOUR_VERIFIED_DATA_BACKEND_IMAGE"
AIVISION_RELEASE_MANIFEST_BASE64: ""
IMAGE_PULL: "Always"
PUBLIC_HOST: "YOUR_REACHABLE_NODE_IP"
PUBLIC_PORT: "30080"
```

Set `PUBLIC_HOST` to a node IP reachable by both browsers and Agents. `30080` is the managed ingress controller's default HTTP NodePort. If a load balancer sits in front, use the host and port that clients actually access. Keep `127.0.0.1:5174` only when the ingress endpoint is already mapped to that local port.

Replace all five image placeholders with matching verified full image references. For a released installation, obtain the images and `AIVISION_RELEASE_MANIFEST_BASE64` from the same verified versioned Release as the CLI. Source candidates can leave release metadata empty, which may show an unknown installed product version in About. Do not infer image capability from a tag or change only `IMAGE_TAG` while retaining old individual references.

Use only variables supported by the current Kubernetes target; do not reuse the Docker variables file. **The current fixed Kubernetes flow does not support external OceanBase CE or seekdb and cannot set `AIVISION_NATIVE_TRACE_HISTORY_START`. Use Docker if you need native Langfuse v1 history reads.** SDK ingestion and v1 reads are separate capabilities.

## 3. Run preflight checks and deploy

These steps use the dedicated namespace `aivision`; keep the original namespace for an existing deployment. Run the preflight checks and deployment with the same parameters:

```bash theme={null}
aiv gauge --target kubernetes --context YOUR_CONTEXT \
  --namespace aivision --vars-file ./aivision.kubernetes.vars.yaml
aiv cast --target kubernetes --context YOUR_CONTEXT \
  --namespace aivision --vars-file ./aivision.kubernetes.vars.yaml
```

The CLI checks the cluster, storage, ingress and dependencies, deploys the required resources, waits for readiness, and initializes the databases and internal integrations. If images require authentication, enter a GHCR username and PAT with `read:packages` when prompted. A local `docker login` does not mean the cluster has image-pull credentials. Use `IMAGE_PULL_SECRET` to select an existing image Secret in the application namespace. If all images are public, you can set `IMAGE_AUTH: "anonymous"`.

Preflight checks do not save the supplied parameters, so pass the same configuration to `cast`. Failed deployments retain resources. Fix the problem and retry the original `cast`; automatic rollback is not guaranteed. The current fixed flow provides only `gauge`, `cast`, `status` and `logs`. Do not apply Docker `destroy` or `redeploy` commands to it.

The first `cast` generates application and database credentials in cluster Secrets such as `aivision-secrets`; later deployments reuse them. Do not supply Docker password variables. If the original Secret is missing or inconsistent, restore it before retrying; deleting the database or generating replacement passwords is not a recovery step.

The five application Deployments use one replica and `Recreate`, so updates have a maintenance window. Extra replicas, rolling application updates and HA are outside this fixed profile; the data backend requires a single SQLite metastore writer. Repeat `cast` with the original context, namespace and configuration, preserving Secrets, organization identity and PVC/PV bindings. Existing database-image or StorageClass changes are rejected. Readiness is not a scale or capacity test, and deleting Pods or PVCs is not an update procedure.

## 4. Verify the actual target cluster

After deployment, open a new management terminal, confirm direct access to `aiv`, then inspect the original target cluster:

```bash theme={null}
command -v aiv
aiv --version
aiv status --target kubernetes --context YOUR_CONTEXT --namespace aivision
aiv logs --target kubernetes --context YOUR_CONTEXT --namespace aivision -n 80 backend
kubectl --context YOUR_CONTEXT -n aivision get pods,svc,ingress,pvc
```

Keep `--target kubernetes` and the same context/namespace on every subsequent `aiv` operation. A bare `aiv status` checks the default Docker deployment.

Confirm that Pods are ready, PVCs are bound, ingress matches the intended address, and `cast` prints `Deployment ready.`. There should be no persistent restarts or startup errors. Check the configured public endpoint from an actual client machine:

```bash theme={null}
curl -sS -o /dev/null -w '%{http_code}\n' http://YOUR_REACHABLE_NODE_IP:30080
```

Expect Web HTTP `200` and a sign-in page in the browser. Then follow the [first Agent tutorial](https://aivision.mintlify.site/en/web-quickstart.md) or [SDK tutorial](https://aivision.mintlify.site/en/integrations/langfuse.md) to send an identifiable new record. A reachable page does not establish that clients can report telemetry; OTLP still requires valid reporting credentials.

Read the new Trace back with authentication and, after an update, read a Trace retained from before it. Temporary SQL failure should remove affected Pods from Ready endpoints while their local liveness remains successful; a failed readiness check alone does not restart a Pod. Healthy probes and a completed bootstrap Job remain [different evidence from authenticated product acceptance](https://aivision.mintlify.site/en/deployment/overview.md#health-readiness).

On first use, choose Register on the sign-in page and create an AI Vision account with your own email, name and chosen password. You can also register through the [CLI quickstart](https://aivision.mintlify.site/en/quickstart.md). OceanBase and SigNoz passwords in deployment configuration are internal service credentials, not AI Vision Web sign-in credentials. Sign in directly with an existing account; if registration is disabled, ask the operator for an account.

## Shared ingress and routing

[![Kubernetes shared ingress architecture](https://mintcdn.com/aivision/IXZvq4am8qG0NjqT/assets/architecture/kubernetes.en.light.svg?fit=max\&auto=format\&n=IXZvq4am8qG0NjqT\&q=85\&s=58ed2c6378489006d1ac9f0e7254d583)](https://aivision.mintlify.site/assets/architecture/kubernetes.en.light.svg)

[![Kubernetes shared ingress architecture](https://mintcdn.com/aivision/IXZvq4am8qG0NjqT/assets/architecture/kubernetes.en.dark.svg?fit=max\&auto=format\&n=IXZvq4am8qG0NjqT\&q=85\&s=3ae5ff13cb6fb00d3bb2f54cdd06b9c5)](https://aivision.mintlify.site/assets/architecture/kubernetes.en.dark.svg)

Web and OTLP HTTP share ingress while internal services remain separate

The default flow installs managed Traefik; an existing Ingress Controller can also be used. Web and OTLP HTTP share the public host and port:

| Path | Destination |
| - | - |
| `/v1/traces`, `/v1/logs`, `/v1/metrics` (exact match) | `antcollector-gw:4318`, which continues to validate reporting tokens. |
| All other paths | `aivision-fe:5174`, serving static pages. |
| `/api/` and `/openapi/` through the frontend | Nginx proxies to `aivision-be:8001`. |

OTLP gRPC remains internal to the cluster and is not exposed through HTTP ingress. Application Services use ClusterIP; the managed controller uses NodePort.

## Use existing ingress or HTTPS

To reuse a controller, add `INGRESS_CONTROLLER: "existing"` and its `INGRESS_CLASS` to the variables file, with the public host and port it actually provides. The CLI creates application routes; the cluster administrator configures the controller's address and forwarding.

HTTPS requires a DNS hostname, a client-trusted certificate, and a `kubernetes.io/tls` Secret in the application namespace. Add `PUBLIC_SCHEME: "https"`, `PUBLIC_PORT: "443"` and `INGRESS_TLS_SECRET: "YOUR_SECRET_NAME"`, and confirm that the controller actually exposes HTTPS. It must preserve Host and overwrite client-supplied `X-Forwarded-Proto`. Managed ingress does not automatically issue certificates or create HTTP-to-HTTPS redirects.

After changes, run `cast` again with the same configuration and verify. Keep the deployment directory and CLI local state (under `~/.aivision/deploy/kubernetes/` by default) for subsequent management. Database data is stored in cluster persistent volumes; a backup must include more than the local configuration.

## Common deployment problems

| Symptom | Next check |
| - | - |
| Pod Pending / PVC unbound | Check schedulable resources, StorageClass and actual storage capacity. |
| ImagePullBackOff | Check cluster networking, image tags and pull credentials in the namespace. |
| Deployment ready but the address is unreachable | Distinguish NodePort, port mapping and load balancing; check the public host and port from the client. |
| Status shows another environment | Specify the Kubernetes target, context and namespace. |
| v1 reads report missing history configuration | The current fixed flow cannot inject this variable; passing a Docker variables file does not resolve it. |

Match each PVC's `VOLUME` to the same name in the PV list and check its `RECLAIM POLICY`:

```bash theme={null}
kubectl --context YOUR_CONTEXT -n aivision get pvc
kubectl --context YOUR_CONTEXT get pv
```

Before removal, have the cluster administrator confirm retained data and backups, and inspect the reclaim policy of the PVs bound to the PVCs. Deleting a namespace or PVC can delete underlying storage with a `Delete` policy; this is not a data-preserving stop. Check ownership of the dedicated IngressClass and shared dependencies before removing resources used by other applications. See [Kubernetes volume reclaim policies](https://kubernetes.io/docs/tasks/administer-cluster/change-pv-reclaim-policy/).

This page covers existing clusters. The deployment operator manages cluster creation, backups and removal. [Local kind and full maintenance instructions](https://github.com/ob-labs/ai-vision-ob/blob/main/docs/deployment/en/kubernetes.md) remain in the repository's technical guide.

## Native query maintenance and emergency recovery

On matching builds, migrations, projection maintenance and Trace/Session query acceleration run automatically. Older released images may not contain this behavior. The normal backend entrypoint supervises the API and maintenance worker; bootstrap remains a separate one-shot task.

Use the role keys in the original Kubernetes vars file: `BACKEND_QUERY_MODE: "auto"` (use `"raw"` to bypass projections while preserving filters) and `DATA_BACKEND_PROJECTION_MAINTENANCE_ENABLED: "true"` (use `"false"` to durably suspend derived maintenance and serving). They map to application environment variables `AIVISION_QUERY_MODE` and `SIGNOZ_AIVISION_PROJECTION_MAINTENANCE_ENABLED`; the aliases represent the same two controls. Role keys take precedence over legacy keys in the same configuration layer. Templates already contain role defaults, so edit those entries rather than appending only a legacy key.

Rerun the original `aiv cast --target kubernetes` command with the same context, namespace and vars file. This changes application workloads, not the database image or retained volumes. Use compatible CLI, templates and images from the matching source revision. Fixed Kubernetes templates are maintained under canonical [`deploy/kubernetes/base/`](https://github.com/ob-labs/ai-vision-ob/tree/main/deploy/kubernetes/base); after changing source inputs, run `make assets` in `aivision-cli/` to regenerate embedded assets before rebuilding the CLI.

After repairing the cause, restore maintenance to `true` on all writers and apply through the original CLI. Explicit resume requires both the existing SigNoz admin credential and deployment-internal ingest key; ordinary organization read access cannot reset shared state. Obtain the single-line `SIGNOZ_INGEST_INTERNAL_KEY` through your cluster's existing Secret procedure and export it only in the authorized operator shell. Replace the context and namespace below. Send the key on stdin to a one-shot recovery process, keeping its value out of arguments, Pod environment and logs:

```bash theme={null}
test -n "${SIGNOZ_INGEST_INTERNAL_KEY:-}" &&
printf '%s\n' "$SIGNOZ_INGEST_INTERNAL_KEY" |
  kubectl --context YOUR_CONTEXT --namespace YOUR_NAMESPACE \
    exec -i deployment/aivision-be -c be -- /bin/sh -c \
    'IFS= read -r SIGNOZ_INGEST_INTERNAL_KEY || exit 1; export SIGNOZ_INGEST_INTERNAL_KEY; cd /app && exec /app/.venv/bin/python manage.py maintain_trace_read_model --resume-maintenance --once'
```

The physical Deployment/container names remain `aivision-be` / `be`; role selectors do not rename them. This command does not restart bootstrap Jobs or serving processes; the key exists only in recovery. A normal restart cannot clear shared suspension. Rebuilding retains raw Spans. Verify fixed queries and complete results, then restore `BACKEND_QUERY_MODE` to `auto` and reapply through the original CLI. See [query operation and recovery](https://github.com/ob-labs/ai-vision-ob/blob/main/docs/deployment/en/trace-read-model.md). These steps do not establish actual cluster rollout validation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.