Skip to navigation

Update and remove deployments

View as MarkdownOpen in Claude

Use this page to change an installed stack: rebuild a local image, upgrade or roll back, rotate credentials, restore a database, deliver workflow scripts, preview changes or remove releases.

A release is one named chart installation, such as remediation-orchestrator or nro-db. The nro-bootstrap release runs Jobs that migrate NRO’s database and prepare Temporal before Helmfile installs or upgrades the application.

Before you change a deployment

On every command here, use the environment, ordered state files, cluster context and namespace the deployment was installed with:

  • Environment and state files. The shared examples use -e dev with --state-values-file "$HOME/.config/remediation-orchestrator/dev.yaml". Substitute your own environment name and state files, in the same order. The local examples use -e local, plus any state file or --state-values-set override you installed with, such as a changed publicUrl.

  • Cluster. Select the context and clear overrides as in Select the cluster, and confirm kubectl config current-context before each sync or destroy. For -e local on any cluster other than kind-remediation-orchestrator, including a kind cluster with another name, repeat its --kube-context override (Use another local cluster).

  • Namespace. Plain kubectl and helm commands for a shared installation use $nro_namespace. Set it to the exact namespace value in your state file:

    # The namespace your state file names; use your own.
    nro_namespace=remediation-orchestrator-dev

    The local stack uses remediation-orchestrator unless your state overrides namespace.

Run Helmfile commands from the Helm module root, the directory holding helmfile/.

Rebuild and redeploy

These steps update the local stack after a change to NRO. From the Helm module root, record its location before changing to the application source root. In a public clone, the application source root is its parent. For other layouts, use Build the NRO image.

# 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/.."

From the application source root, rebuild:

# Rebuild the image and load it into Docker as maestro:latest.
bazel run //cmd/maestro:maestro.image.local_load

Then return to the Helm module root. There you give the new image the local tag, load it onto the kind nodes, sync, and restart NRO. If your change adds database migrations, add --state-values-set-string bootstrap.runToken=<new value> to the sync command below, so the migration Job runs again (Rerun the bootstrap Jobs).

# Return to the Helm module root.
cd "$nro_helm_dir"
# Give the new image the reference the local environment expects.
docker tag maestro:latest remediation-orchestrator:local
# Copy the new image onto the kind nodes.
kind load docker-image remediation-orchestrator:local --name remediation-orchestrator
# Apply any chart or state changes.
helmfile -f ./helmfile -e local sync
# Restart NRO so its pods use the new image.
kubectl -n remediation-orchestrator rollout restart deploy/remediation-orchestrator

With pullPolicy: Never, the node uses whatever image kind load last placed under the local tag. Loading a new image under the same reference does not change the rendered pod or Job specs. If their other inputs are unchanged, sync leaves running pods and completed bootstrap Jobs in place. The restart picks up the new image.

For a kind cluster with another name, pass --name <cluster> to kind load. On another local cluster tool, use its image import in place of kind load. In both cases, add your context override to the sync.

Upgrade

To upgrade, first publish a new image tag or digest (Build and publish your image). Then update your state file and run the same sync command you installed with. Changed bootstrap Job specifications create new Jobs, and unchanged completed Jobs do not run again.

With the default Recreate strategy, every rollout stops all NRO pods before new ones start. NRO is therefore unavailable during each upgrade, configuration change or restart, whatever replicaCount is.

Bootstrap finishes before Helmfile upgrades the remediation-orchestrator release, so the old NRO can still be running during migrations. Recreate does not stop the old pods before bootstrap.

Render the upgraded state first. The render must succeed before you change anything in the cluster:

# Render the upgraded state for review; this must succeed first.
helmfile -f ./helmfile -e dev \
--state-values-file "$HOME/.config/remediation-orchestrator/dev.yaml" \
template > /tmp/remediation-orchestrator-dev.yaml

For an incompatible schema change, take a database backup and stop the old NRO pods before you sync. Managed clusters have no backups by default. Configure them first through postgresql.values.backups (Tune the charts through passthroughs), and read Restore a database for what a restore involves. Other upgrades skip this step. With remediation-orchestrator.workload.kind: StatefulSet, use statefulset/remediation-orchestrator in place of deploy/remediation-orchestrator throughout this procedure:

# Stop every NRO pod.
kubectl -n "$nro_namespace" scale deploy/remediation-orchestrator --replicas=0
# Wait until the old pods are gone.
kubectl -n "$nro_namespace" wait --for=delete pod \
-l app.kubernetes.io/instance=remediation-orchestrator,app.kubernetes.io/component=remediation-orchestrator \
--timeout=120s

Then apply the upgrade:

# Apply the upgrade.
helmfile -f ./helmfile -e dev \
--state-values-file "$HOME/.config/remediation-orchestrator/dev.yaml" sync

If you stopped NRO, it stays stopped while the bootstrap Jobs migrate the database. The upgrade of the remediation-orchestrator release then restores the chart’s replicaCount. Confirm that NRO is back with kubectl -n "$nro_namespace" rollout status deploy/remediation-orchestrator. State values cannot stop NRO for you, because the chart requires a replicaCount of at least 1.

After sync succeeds, repeat the checks for your installation type, keeping this installation’s namespace and context: Check and open NRO for a local installation, or Render, deploy and verify for a shared one. For an authenticated installation, also check browser sign-in and intended administrator access. The Helm health test does not exercise them.

The migration Job must finish within bootstrap.jobs.activeDeadlineSeconds (default 600 seconds), which also covers its wait-postgres wait. For a long migration, raise that key. Keep the top-level readiness.timeoutSeconds greater than it, so Helm waits for the Job. The state check enforces this.

Under Helmfile, a failed bootstrap pod is retried once (bootstrap.jobs.backoffLimit: 1), and the failed Job is kept for inspection. You can retry without changing the Job specification, for example after you fix a credential or other external condition. Pass a new token, as Rerun the bootstrap Jobs shows.

A Temporal upgrade reruns the schema hook before the servers roll, and a rollback does not revert the schema. The schema hook runs in the admin-tools image, so keep upstreamImages.temporalAdminTools on the same Temporal release as the server (Images).

The value of temporal.historyShards is fixed after Temporal initializes its database, so do not change it against retained Temporal data. Choose it before the first install (Known limits).

Roll back the NRO image

NRO starts against a newer database schema: at startup it rejects only a schema that is behind the binary. Whether the older code works with the newer schema depends on the migrations in between.

Do not roll back by setting the older image in state and running sync. The image is part of the migration Job’s name hash, so the change reruns the Job with the older binary. If the newer release added migrations, maestro migrate then fails because the database is ahead of the binary’s migrations, with current version N is outside the valid versions of 0 to M. Bootstrap fails, and Helmfile does not upgrade NRO.

To run an older image, roll back only the NRO release with Helm. This does not run bootstrap and does not reverse database migrations:

# List the release's revisions; choose the one that ran the older image.
helm -n "$nro_namespace" history remediation-orchestrator
# Set revision to the chosen revision number before running this command.
helm -n "$nro_namespace" rollback remediation-orchestrator "${revision:?Set revision to the chosen revision number}"

Do not run sync until your state names an image at least as new as the database schema. To return to the older schema, restore the database backup taken before the upgrade (Restore a database), then sync the older image.

Rerun the bootstrap Jobs

Completed bootstrap Jobs do not run again while their specification is unchanged. To run them again, for new database migrations or after you fix an external condition, pass a new bootstrap.runToken to sync. A different token changes the Job names and reruns the enabled bootstrap Jobs:

# Rerun the bootstrap Jobs under a new token.
helmfile -f ./helmfile -e dev \
--state-values-file "$HOME/.config/remediation-orchestrator/dev.yaml" \
--state-values-set-string bootstrap.runToken=retry-1 sync

For the local stack, add the same flag to the local sync command. Use a different value each time. The -string form keeps a number such as 2 a string, which the state schema requires.

Helmfile does not remember a token given on the command line. A later sync without it uses the token from your state files, or the empty default if none is set. Keep passing your latest token, or save it as bootstrap.runToken in an optional local state file passed with --state-values-file.

Rotate credentials

Update the Secret, then apply the step for the credential. With remediation-orchestrator.workload.kind: StatefulSet, use statefulset/remediation-orchestrator in place of deploy/remediation-orchestrator:

CredentialAfter you update the Secret
Database connection string (database.existingSecret), Dex client secret (auth.dex.existingSecret) or Temporal API key (temporal.auth.apiKey.existingSecret)NRO reads these as environment variables from secretKeyRef, so running pods keep the old value. Restart NRO with kubectl -n "$nro_namespace" rollout restart deploy/remediation-orchestrator
Temporal mTLS client certificate and key (temporal.auth.mtls.existingSecret)NRO reads the certificate and key files at each new TLS handshake, so it needs no restart after the mounted files hold the new pair
Temporal mTLS CA (temporal.auth.mtls.caKey)NRO reads the CA file once at startup. Restart NRO
A credential the bootstrap Jobs useCompleted Jobs do not run again. Rerun them with a new bootstrap.runToken (Rerun the bootstrap Jobs)

Restore a database

The stack has no way to bootstrap a managed database from a CNPG backup. postgresql.values rejects the CNPG chart’s mode and recovery keys, because that passthrough reaches both database clusters. To use restored NRO data, run the restored database outside the stack and switch to database.mode: external (Use existing backing services). For Temporal’s data, run the restored database and a Temporal server on it outside the stack, and switch to temporal.mode: external. The switch leaves the old managed release and its data in place.

Deploy workflow scripts

The charts do not load scripts. For an interactive first workflow, follow Your First Script. For ongoing delivery, deploy scripts through the script bundle API, normally with maestroctl scripts deploy from a script repository’s CI, as the script deployment guide describes. Map the deploying identity to the script-uploader role in each tenant it deploys to.

Optional diff and apply

diff compares releases against a cluster, and apply performs that comparison before syncing changes. Both need helm-diff in addition to Helmfile. This checkout does not pin helm-diff or install it for automated tests. Install a plugin version compatible with your selected Helm version and verify it before using these commands. Helm 4 requires a Helm-4-compatible plugin.

apply is supported for a healthy stack. After any failed release, recover with sync instead. The helm-diff plugin compares against the latest stored revision, including a failed one. So apply with unchanged values can skip a release whose pre-upgrade hook failed, such as nro-temporal after a failed schema hook.

After you install and verify the plugin, use the same environment, ordered state files and context as for sync. For example, from the Helm module root:

# Show what sync would change.
helmfile -f ./helmfile -e dev \
--state-values-file "$HOME/.config/remediation-orchestrator/dev.yaml" diff
# Sync only the releases that differ.
helmfile -f ./helmfile -e dev \
--state-values-file "$HOME/.config/remediation-orchestrator/dev.yaml" apply

For the local stack, helmfile -f ./helmfile -e local status lists the installed releases without the plugin.

Remove the local deployment

To remove the remediation-orchestrator release and the bootstrap Jobs while keeping the supporting services and data:

# Remove the NRO release.
helmfile -f ./helmfile -e local --selector component=remediation-orchestrator destroy
# Remove the bootstrap Jobs.
helmfile -f ./helmfile -e local --selector component=bootstrap destroy

component=bootstrap selects nro-bootstrap only (Components).

The following commands remove every release while keeping the cluster. First confirm that kubectl config current-context prints your local cluster’s context (kind-remediation-orchestrator for the supplied kind setup).

A full destroy removes the CNPG operator and the managed databases, and with them all NRO and Temporal data. Each CNPG Cluster owns its PersistentVolumeClaims, so Kubernetes deletes the claims when destroy removes the nro-db and nro-temporal-db releases. On kind, the default StorageClass then deletes the volumes as well:

# Remove every release and the database data, keeping the cluster.
helmfile -f ./helmfile -e local destroy
# List the database volume claims. Repeat until none remain.
kubectl -n remediation-orchestrator get pvc

The claims can still be listed when destroy returns. Kubernetes removes them shortly afterward, so repeat the second command until it reports no resources.

The remediation-orchestrator and cnpg-system namespaces and the CNPG CustomResourceDefinitions remain. A Temporal ServiceAccount created through temporal.values.serviceAccount.create, or a failed nro-temporal-schema Job, also remains (Clean up what destroy leaves).

To discard the whole disposable cluster instead, follow Remove the local cluster.

Uninstall

These commands remove a shared installation. Confirm the context and set nro_namespace as in Before you change a deployment.

To keep the databases and services, remove the remediation-orchestrator release and bootstrap:

# Remove the NRO release.
helmfile -f ./helmfile -e dev \
--state-values-file "$HOME/.config/remediation-orchestrator/dev.yaml" \
--selector component=remediation-orchestrator destroy
# Remove the bootstrap Jobs.
helmfile -f ./helmfile -e dev \
--state-values-file "$HOME/.config/remediation-orchestrator/dev.yaml" \
--selector component=bootstrap destroy

component=bootstrap selects nro-bootstrap only (Components).

To remove every release this Helmfile manages, run the command below. That includes the managed database clusters and, if this Helmfile installed it, the CloudNativePG operator.

The command deletes both managed databases and their data. Each CNPG Cluster owns its PersistentVolumeClaims, so removing the nro-db and nro-temporal-db releases deletes the claims, whether or not the operator stays installed. If you need the data, back up the databases first, or destroy only selected releases as above to keep it:

# Remove every release this Helmfile manages.
helmfile -f ./helmfile -e dev \
--state-values-file "$HOME/.config/remediation-orchestrator/dev.yaml" destroy

Clean up what destroy leaves

Some resources outlive destroy, and a shared CloudNativePG operator must stay while other installations use it. Review each item below before you delete anything.

The CloudNativePG operator. The operator serves the whole cluster, so other installations can use the one this Helmfile installed. Keep it while any of them still needs it. To do so, destroy with cnpg.install: false and no cnpg.values in the state. That omits the cnpg release and leaves the operator in place. Alternatively, destroy only selected releases. After nothing uses the operator, uninstall it with helm -n cnpg-system uninstall cnpg, substituting your cnpg.operatorNamespace.

The Temporal ServiceAccount. A ServiceAccount created with temporal.values.serviceAccount.create is a Helm hook, so it also stays after a full destroy (The Temporal ServiceAccount). Before you delete it, remove every workload that runs as it and review the RoleBindings and other references to it:

# Confirm that the current context is the deployment's cluster.
kubectl config current-context
# Delete the account; substitute your serviceAccount.name if you set one.
kubectl -n "$nro_namespace" delete serviceaccount nro-temporal

A failed schema Job. A failed schema Job, nro-temporal-schema, can also stay after a full destroy or a helm uninstall removes the nro-temporal release itself (Temporal schema migration). If you destroyed only the NRO or bootstrap releases, nro-temporal is still installed, so keep the Job.

Collect the failed Job’s diagnostics before you delete anything:

# Confirm that the current context is the deployment's cluster.
kubectl config current-context
# Confirm that nro-temporal is gone; this must report the release as not found.
helm -n "$nro_namespace" status nro-temporal
# Check whether the failed Job remains.
kubectl -n "$nro_namespace" get job/nro-temporal-schema --ignore-not-found
# Keep the failed Job's status, events and migration logs.
kubectl -n "$nro_namespace" describe job nro-temporal-schema
kubectl -n "$nro_namespace" logs job/nro-temporal-schema --all-containers --prefix
# Delete the Job.
kubectl -n "$nro_namespace" delete job nro-temporal-schema --ignore-not-found

External services and switched releases. External backing services are untouched. So is a release left in place by a mode switch. Remove such a release with helm uninstall.

Retained volumes. Whether the data outlives its claims depends on the StorageClass reclaim policy. With Delete, the usual default, the volumes are deleted with the claims. With Retain, each volume stays Released and keeps its data until you delete it:

# Confirm that no database volume claims remain.
kubectl -n "$nro_namespace" get pvc
# List volumes still bound to claims from this namespace.
kubectl get pv | grep " $nro_namespace/"

Delete a retained volume with kubectl delete pv <name> only when you intend to discard its data.

Next steps