> This page is for Remediation Orchestrator.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/remediation-orchestrator/llms.txt.

# Local K8s

This guide installs the whole stack on a Kubernetes cluster on your machine, with
authentication disabled. At the end, NRO, PostgreSQL, Temporal and the telemetry
collector run in the `remediation-orchestrator` namespace, and you can open the NRO web
UI at http://localhost:6787.

The commands use kind, which runs local Kubernetes nodes in Docker containers and is the
cluster tool the supplied `local` environment targets. To use k3d, minikube or another
local cluster instead, read
[Use another local cluster](#use-another-local-cluster) before you run the kind commands.

The `local` environment disables authentication and installs CloudNativePG (CNPG), the
cluster-wide operator that manages the PostgreSQL databases. Use it only on an isolated,
disposable cluster. For a cluster other people use, follow [Shared K8s](/remediation-orchestrator/deployment/helm/quick-start/shared-k8s).

## Before you start

You need a checkout containing this Helm module. If you do not have one, follow
[Get the checkout](/remediation-orchestrator/deployment/helm#get-the-checkout), then return to this guide from the
Helm module root.

You need these tools on `PATH`:

- Python 3.12 or later, Helm 3.19.4 or later (including Helm 4) and Helmfile 1.8.1.
- kubectl within one minor version of your cluster's API server.
- Docker, with its daemon running, and kind, for the supplied kind example.
- Bazel, the build tool used to create the NRO image, and the application source
  checkout's
  [build prerequisites](https://github.com/dsx-ai-factory/remediation-orchestrator/blob/1785e695a8bff76c910115b3c96398a5a59a7183/README.md#prerequisites).
  Skip them if you already have a compatible image.

`kind/config.yaml` pins no node image, so the cluster runs your kind release's default
Kubernetes version. The CNPG operator needs 1.29 or later
([support matrix](https://github.com/dsx-ai-factory/remediation-orchestrator/blob/1785e695a8bff76c910115b3c96398a5a59a7183/helm/docs/reference/tools.md#support-matrix)), so use a kind release whose
default meets it. After you create the cluster, `kubectl version` shows the server's
version.

[Tools and compatibility](https://github.com/dsx-ai-factory/remediation-orchestrator/blob/1785e695a8bff76c910115b3c96398a5a59a7183/helm/docs/reference/tools.md) explains how to install these tools with
checksum verification and lists the versions the tests cover.

Commands run in two directories. Helmfile commands run from the Helm module root, which
contains `helmfile/`. In a clone of
`https://github.com/dsx-ai-factory/remediation-orchestrator.git`, this is the `helm/`
directory. The image build runs from the application source root, which contains
`cmd/maestro/`; in a clone, this is the clone root. Each command block below names its
directory.

Helmfile uses your own Helm configuration and cache. The first preview downloads the
pinned upstream charts, and the first install pulls container images, so both need network
access.

## Build the NRO image

This module supplies no published NRO image, so you build one or use a compatible image
of your own. The `local` environment runs `remediation-orchestrator:local` from the kind
nodes and never pulls it. The commands below start from an image in Docker named
`maestro:latest`.

If you already have a compatible image, skip the build and tag it as `maestro:latest`,
for example with `docker pull` and `docker tag <your image> maestro:latest`.

A compatible image contains `/bin/maestro`, the UI assets and a `/bin/database-ready`
probe that accepts the `--timeout-seconds`, `--wait-seconds` and `--interval-seconds`
flags bootstrap passes. An image built before those flags existed fails at the bootstrap
`wait-postgres` init container.
[Validation messages](/remediation-orchestrator/deployment/helm/operations/troubleshooting#validation-messages) lists that
failure and its fix.

To build from source, first record the Helm module root so you can return to it. Then
change to the application source root, which is the parent directory in a public clone:

```sh
# Record the Helm module root while you are in it.
nro_helm_dir="$PWD"
# Change to the application source root, the directory holding cmd/maestro/.
cd "$nro_helm_dir/.."
```

Use the same shell session for the build and deployment steps, so `nro_helm_dir` remains
available when you return from the application source root.

From the application source root, build the image and load it into Docker:

```sh
# Build the image and load it into Docker as maestro:latest.
bazel run //cmd/maestro:maestro.image.local_load
# Print the loaded image's content-addressed ID.
docker image inspect --format '{{.Id}}' maestro:latest
```

The first build can take several minutes. Then return to the Helm module root for every
command that follows:

```sh
# Return to the Helm module root.
cd "$nro_helm_dir"
```

[Build and publish images](/remediation-orchestrator/deployment/images#build-the-nro-image) covers other
source layouts, the toolchain each host architecture needs and what the image contains.

## Preview without a cluster

From the Helm module root, list the releases and their installation order, then render
the manifests. These commands do not change any cluster, so you can check the setup
before you create anything. Continue to installation only if the render succeeds:

```sh
# List the releases the local environment declares.
helmfile -f ./helmfile -e local list
# Show the order in which the releases install.
helmfile -f ./helmfile -e local show-dag
# Render every manifest to a file without contacting a cluster.
helmfile -f ./helmfile -e local template > /tmp/remediation-orchestrator-local.yaml
```

A zero exit status means the render succeeded. The file then holds every manifest for
review.

## Create the cluster and install

From the Helm module root, create the cluster, load the image and install the stack.
These commands change your Docker images and create Kubernetes resources:

```sh
# Create the local kind cluster.
kind create cluster --name remediation-orchestrator --config kind/config.yaml
# Make the kind cluster the current context for kubectl and helm.
kubectl config use-context kind-remediation-orchestrator
# Clear overrides that would send Helmfile or Helm to another cluster.
unset HELMFILE_KUBE_CONTEXT HELM_KUBECONTEXT
# Give the built image the reference the local environment expects.
docker tag maestro:latest remediation-orchestrator:local
# Copy the image onto the kind nodes.
kind load docker-image remediation-orchestrator:local --name remediation-orchestrator
# Install the whole stack.
helmfile -f ./helmfile -e local sync
```

`sync` installs the releases in dependency order and waits for each one. A step that
cannot finish fails with a message after its deadline. `readiness.timeoutSeconds` sets
the Helm timeout and the presync gate deadline, 900 seconds by default. The bootstrap
Jobs have shorter deadlines of their own
([Deadlines and render checks](/remediation-orchestrator/deployment/helm/reference/bootstrap-chart#deadlines-and-render-checks)).
If `sync` fails, start with [Troubleshooting](/remediation-orchestrator/deployment/helm/operations/troubleshooting).

`use-context` makes the kind cluster the current context in your kubeconfig for the
`kubectl` and `helm` commands below. It also changes the cluster that other terminals
using that kubeconfig reach.

Helmfile selects its cluster separately. `-e local` pins it to
`kind-remediation-orchestrator`, whatever the current context is. Only `--kube-context`
or `HELMFILE_KUBE_CONTEXT` overrides that pin. A shell prepared for another cluster with
`HELMFILE_KUBE_CONTEXT` set would send the local stack there. The `unset` clears that
override, and Helm's, so neither tool reaches another cluster
([Select the cluster](/remediation-orchestrator/deployment/helm/configuration/environments#select-the-cluster)).

## Check and open NRO

When `sync` returns, check the pods and Jobs, then run the chart's health test:

```sh
# Show the stack's pods and initialization Jobs.
kubectl -n remediation-orchestrator get pods,jobs
# Run the chart's health test and print its output.
helm -n remediation-orchestrator test remediation-orchestrator --logs
```

Expect the NRO, PostgreSQL, Temporal and collector pods to be `Running` and ready. The
two initialization Jobs below should be complete, and their pods show `Completed`:

| Job | Release | Role |
| --- | --- | --- |
| `nro-bootstrap-migrate-<hash>` | `nro-bootstrap` | Applies NRO's database migrations. |
| `nro-bootstrap-temporal-<hash>` | `nro-bootstrap` | Prepares NRO's Temporal namespace and search attributes. |

A third Job, `nro-temporal-schema`, creates or updates the Temporal server's database
schemas as a Helm hook before the Temporal servers start. Helm deletes it on success, so a
successful sync does not list it. A failed one stays for inspection
([Temporal schema migration](/remediation-orchestrator/deployment/helm/configuration/services#temporal-schema-migration)).
Temporal pods can restart during the first install while the servers initialize. That is
expected, so a nonzero restart count alone is not a failure. If pods keep restarting, stay
unready or pending, or a Job fails, refer to
[Troubleshooting](/remediation-orchestrator/deployment/helm/operations/troubleshooting).

The Helm test requests NRO's `/status` and passes when PostgreSQL and Temporal checks
succeed.

Open the web UI:

```sh
# Forward the NRO web UI to http://localhost:6787.
kubectl -n remediation-orchestrator port-forward svc/remediation-orchestrator 6787:6787
```

The NRO port-forward keeps this terminal occupied. Open `http://localhost:6787` in a
browser to reach the NRO web UI.

The port-forward attaches to one NRO pod, even through `svc/remediation-orchestrator`.
It stops when that pod is replaced, for example after a rebuild or upgrade. Wait for the
new pod to become ready, then rerun the same port-forward command:

```sh
# Wait until the replacement NRO pod is ready.
kubectl -n remediation-orchestrator rollout status deployment/remediation-orchestrator
# Forward the NRO web UI to http://localhost:6787 again.
kubectl -n remediation-orchestrator port-forward svc/remediation-orchestrator 6787:6787
```

To open the Temporal UI, use a second terminal with the same kubeconfig. Run
`kubectl -n remediation-orchestrator port-forward svc/nro-temporal-web 8080:8080`, then
open http://localhost:8080/namespaces/default/, the base of NRO's workflow links.

The charts load no user scripts, but NRO starts its internal indexing workflows on its own.
The workflow list can show `script-indexer` and `temporal-workflow-indexer` runs before
you add a script. They use minute-based schedules by default. When the first runs appear
depends on startup and scheduling.

## Use another local port

If port 6787 is occupied, change both the NRO URL and the forwarded port, and keep the
`publicUrl` override on later syncs:

```sh
# Install the stack with NRO's public URL on port 16787.
helmfile -f ./helmfile -e local \
  --state-values-set publicUrl=http://localhost:16787 sync
# Forward local port 16787 to the NRO Service.
kubectl -n remediation-orchestrator port-forward svc/remediation-orchestrator 16787:6787
```

After the NRO pod is replaced, rerun this forward with `16787:6787` once the new pod is
ready. Restarting the forward needs no Helmfile sync.

## Use another local cluster

The `local` environment works on any local Kubernetes cluster that meets the
[support matrix](https://github.com/dsx-ai-factory/remediation-orchestrator/blob/1785e695a8bff76c910115b3c96398a5a59a7183/helm/docs/reference/tools.md#support-matrix) and can provision volumes through
a default StorageClass. The repository tests and the commands above use kind; the k3d and
minikube commands below follow those tools' own documentation and are examples, not
tested paths.

`-e local` pins Helmfile and its presync gates to the kube context
`kind-remediation-orchestrator` on purpose. The environment installs an unauthenticated
NRO and a cluster-wide operator, and the pin keeps them off a shared cluster that happens
to be your current context. Changing your current kubectl context does not move the pin.

Name the other cluster's context explicitly, with `--kube-context` or the
`HELMFILE_KUBE_CONTEXT` environment variable. When both are set, `--kube-context` wins.

Complete [Build the NRO image](#build-the-nro-image) and
[Preview without a cluster](#preview-without-a-cluster) as written. Then, from the Helm
module root, follow these steps instead of
[Create the cluster and install](#create-the-cluster-and-install):

1. Create the cluster with your tool, for example
   `k3d cluster create remediation-orchestrator` or `minikube start`. Then find its context
   name with `kubectl config get-contexts`. k3d names it `k3d-<cluster>` and minikube
   `minikube`. The commands below use `k3d-remediation-orchestrator`; substitute your
   context.
2. Make it the current context for the plain `kubectl` and `helm` commands, which do not
   read Helmfile's selection:

   ```sh
   # Make the local cluster the current context for kubectl and helm.
   kubectl config use-context k3d-remediation-orchestrator
   # Clear Helm's fallback context so it cannot disagree with the selection.
   unset HELM_KUBECONTEXT
   ```

3. Place the image on every node. The `local` environment sets
   `image.pullPolicy: Never`, so the nodes never pull `remediation-orchestrator:local`.
   Each node must already hold it. Tag the image, then use your tool's image import:

   ```sh
   # Give the built image the reference the local environment expects.
   docker tag maestro:latest remediation-orchestrator:local
   # k3d: import the image into the k3d cluster's nodes.
   k3d image import remediation-orchestrator:local --cluster remediation-orchestrator
   # minikube: load the image into the minikube node.
   minikube image load remediation-orchestrator:local
   ```

   To pull from a registry the cluster can reach instead, set the image in a state file
   passed with `--state-values-file`, including `image.pullPolicy: IfNotPresent`
   ([State layers](/remediation-orchestrator/deployment/helm/configuration/environments#state-layers)).

4. Run every Helmfile command for this cluster with the same override, including
   `status`, later `sync` runs and `destroy`:

   ```sh
   # Install the stack on the selected local cluster.
   helmfile -f ./helmfile -e local --kube-context k3d-remediation-orchestrator sync
   ```

   Or export the override once for this terminal, and unset it before you work with any
   other cluster:

   ```sh
   # Send every Helmfile command in this terminal to the local cluster.
   export HELMFILE_KUBE_CONTEXT=k3d-remediation-orchestrator
   helmfile -f ./helmfile -e local sync
   ```

5. Continue with [Check and open NRO](#check-and-open-nro); its `kubectl` and `helm`
   commands use the current context you selected in step 2.

The presync gates receive the Helmfile context but read kubeconfig through
`KUBECONFIG`. If the context lives in a kubeconfig file other than the default, export
`KUBECONFIG=/absolute/path/to/config` in every terminal you use, including one running a
port-forward. Native Helmfile's `--kubeconfig` reaches Helm only, not the gates.

The rebuild and removal commands in this guide and in
[Update and remove deployments](/remediation-orchestrator/deployment/helm/operations/maintenance) are written for kind. For
another local cluster, add the same context override to their Helmfile commands. Use
your tool's image import in place of `kind load`, and its cluster deletion in place of
`kind delete cluster`.

## Remove the local cluster

When you no longer need the disposable cluster, delete it. This deletes the cluster and
every database volume in it, so all NRO and Temporal data is lost:

```sh
# Delete the kind cluster and its storage.
kind delete cluster --name remediation-orchestrator
```

To keep the cluster and its services, or to remove only some releases,
follow [Remove the local deployment](/remediation-orchestrator/deployment/helm/operations/maintenance#remove-the-local-deployment).

## Next steps

- Run your first workflow:
  [Your First Script](/remediation-orchestrator/guides/first-scripts-checklist).
- Test the NRO chart's `examples/local.yaml` with plain Helm against the dependencies you
  installed:
  [Try the example on the local stack](/remediation-orchestrator/deployment/helm/reference/application-chart#try-the-example-on-the-local-stack).
- Rebuild after a code change, or remove releases:
  [Update and remove deployments](/remediation-orchestrator/deployment/helm/operations/maintenance#rebuild-and-redeploy).
- Something failed: [Troubleshooting](/remediation-orchestrator/deployment/helm/operations/troubleshooting).
- Deploy with authentication on a cluster other people use:
  [Shared K8s](/remediation-orchestrator/deployment/helm/quick-start/shared-k8s).