Environments and state
Use this page to select an environment and a cluster, understand how state files layer and add an environment of your own. It also explains what each state key controls. To create your first state file, follow Write your state file in the Shared K8s quick start.
Environments
An environment is a named Helmfile profile selected with -e. A state file
supplies settings for one installation, such as its namespace and image. Helmfile
combines these inputs and maps them to chart values, the settings each chart
accepts. A release is one named installation of a chart; this stack contains several
releases. The stack reference lists them.
An environment is required. Running without -e fails. The module supplies two example
environments, local and dev. You can reuse dev with your own state file or declare
your own environment, such as staging
(Add your own environment). The supplied examples have these
defaults:
Every environment other than local requires authentication and rejects the development
settings that local allows.
-e local ignores your current kubectl context. It pins the Helmfile kubeContext, which
its presync gates also use, to kind-remediation-orchestrator, because it installs an
unauthenticated NRO and a cluster-wide operator. Only --kube-context or the
HELMFILE_KUBE_CONTEXT environment variable overrides the pin. A shell prepared for dev
with HELMFILE_KUBE_CONTEXT set would send the local stack to that cluster, so unset the
variable before you run -e local. Select the cluster covers the
other environments and the commands the pin does not reach.
Set the NRO namespace through the top-level state key namespace and the operator
namespace through cnpg.operatorNamespace. The stack rejects Helmfile’s --namespace and
HELMFILE_NAMESPACE overrides, because they would override both namespaces and break
namespace-dependent wiring.
Select the cluster
Plain kubectl and helm commands use the current context of your kubeconfig. For dev
and any environment declared without a kubeContext, Helmfile and its presync gates use
the current kubectl context too, unless you set an override. Helmfile accepts
--kube-context NAME or HELMFILE_KUBE_CONTEXT. When no Helmfile context is set, the
presync gates honor Helm’s HELM_KUBECONTEXT.
The guides select the context once with kubectl config use-context and clear both
variables, so Helmfile, Helm and kubectl target the same cluster:
use-context updates the selected kubeconfig file. Other terminals using that file also
switch to the selected cluster. The change is not limited to this shell. To use a
different existing kubeconfig file, export KUBECONFIG=/path/to/config before selecting
the context. Export it in every other terminal you use as well, including one running a
port-forward. Helm and the presync gates both read KUBECONFIG. Native Helmfile’s
--kubeconfig reaches only Helm. The gates still inherit KUBECONFIG and inspect the
cluster it selects.
The local pin does not change your current context, so plain kubectl and helm
commands still need the target cluster selected as the current context. To run local
on another local cluster, such as k3d or minikube, pass its context explicitly on every
Helmfile command
(Use another local cluster).
Where to keep your state file
Keep your state file outside version control, wherever you manage deployment
configuration, and pass its path
with --state-values-file. The examples use an external location,
"$HOME/.config/remediation-orchestrator/dev.yaml". Helmfile resolves a relative
--state-values-file from the selected helmfile/ directory, not from your shell, so
pass a quoted absolute path. For a file relative to your current directory, write
"$PWD/config/dev.yaml". To run from any directory, or to return after an image build,
name the Helm module root once while you are in it:
These are ordinary shell variables. Helmfile does not discover them.
To keep the file in the checkout, use helmfile/state-values/<name>.local.yaml, which Git
ignores. Pass it as --state-values-file state-values/<name>.local.yaml, which resolves
from helmfile/.
With directory-form -f ./helmfile, Helmfile loads every YAML file directly in
helmfile/ as a Helmfile, so never save operator YAML directly in that directory. The
state-values/ directory and other subdirectories are not scanned.
State layers
The layers merge in this order, and a later layer wins. Maps merge key by key, and lists replace. To find which layer sets a value, read the table from the bottom up:
A passthrough is a state map for chart-specific settings, such as
remediation-orchestrator.ingress. It supplies chart values rather than adding a state
layer. Each passthrough is its release’s last chart-values layer, applied after the
values the stack derives from state, and it rejects the keys the stack wires
(Tune the charts through passthroughs).
For the NRO chart, values apply in this order: the chart’s base values, the values
derived from state, then the remediation-orchestrator passthrough.
Add your own environment
local and dev are supplied examples, and dev does not have to be the permanent name
of your environment. Each additional installation, such as staging, needs its own state
file. The choice is which environment profile that state file builds on:
- Reuse
-e devwhen the supplied shared-cluster profile fits and only the installation’s own values differ. This needs no change to the checkout. Each Helmfile command must use the installation’s state file and Kubernetes context. - Declare a named environment when you want to select the installation by its own
-ename, keep profile defaults in its own environment file, or pin it to one kube context. This edits your copy of the Helm module, which you then maintain.
Reuse dev with its own state file
Each installation can use -e dev with its own state file. Copy the example to
"$HOME/.config/remediation-orchestrator/staging.yaml" and fill it in as in
Write your state file. Use this
installation’s namespace, publicUrl, Temporal namespace and other values, and set
environmentId: staging. The state file applies after environments/dev.yaml, so its
environmentId overrides the profile’s value:
This approach needs no change to the checkout. Repeat --kube-context staging-cluster
and the same state file on every Helmfile command for this installation. Plain kubectl
and helm do not read Helmfile’s context flag. Pass kubectl --context staging-cluster
and helm --kube-context staging-cluster to them, or first select the context with
kubectl config use-context staging-cluster and clear Helm’s override with
unset HELM_KUBECONTEXT.
Declare a named environment
A named environment lets you select the installation with -e staging. It can carry its
own profile defaults and an optional kube context pin. Helmfile recognizes only the
environments that helmfile/helmfile.yaml.gotmpl declares. Adding
environments/staging.yaml alone does not register the environment, and -e with an
undeclared name fails. Helmfile then reports
no releases found that matches specified selector() and environment(<name>).
-
Declare the environment next to
localanddevin theenvironments:block ofhelmfile/helmfile.yaml.gotmpl. Keepingenvironments/dev.yamlin the chain keeps the shared-cluster profile as its base: -
Create
helmfile/environments/staging.yamlwith the profile’s own values, at least:Keep installation-specific values and Secret names in the state file, not the profile.
-
Write the state file as in Write your state file, outside
helmfile/, and pass it as a quoted absolute path: -
Select the target cluster for plain
kubectlandhelm, even if you declared akubeContextpin. That pin affects Helmfile and its presync gates, not those commands. For the example pin above:Without a pin, select the intended context in the same way (Select the cluster). Then deploy and verify as in Render, deploy and verify, with
-e stagingand this state file on every Helmfile command.
Every environment other than local gets the shared-cluster checks. Authentication is
required, development.allowUnauthenticated and development.allowInsecureHttp are
rejected, and every REPLACE_ME placeholder must be replaced. The checks follow the
environment name given to -e, so setting environmentId: local in state does not relax
them. Running without -e still fails. The declaration changes your copy of the Helm
module, so keep it under your own version control and carry it across updates.
State keys
dev, the supplied shared-cluster example, fails without a state file, and so does an
environment you declare on the same base. Create one from
helmfile/state-values/dev.example.yaml
by following Write your state file,
and keep it outside helmfile/ (Where to keep your state file).
Before rendering releases, Helmfile validates the core state against
helmfile/state.schema.json. Unknown core keys and
values of the wrong type fail. Chart-specific values, such as the detailed auth,
config and passthrough keys, are checked when each chart renders. An NRO chart value
written at the top level instead of under remediation-orchestrator counts as an
unknown key.
A shared deployment, whether it uses dev or your own environment, sets or decides these
keys:
defaults.yaml defines every other core key
with its default and a comment, including the upstream image mirrors, the deadlines and
the bootstrap rerun token. Two maps are the exception: the auth keys other than mode
and the config keys other than toml. Both pass to the NRO chart in full and use its
defaults (values.yaml). The chart
checks them on template, diff and sync. The five passthroughs are described in
Tune the charts through passthroughs.
Tune the charts through passthroughs
Five state keys, called passthroughs, reach chart values directly. Each map is the last values layer of its release. Maps merge, and lists replace. The stack protects the keys it wires itself. Setting one fails, and the message names the state key that sets it or says why the value is fixed.
Each passthrough rejects these wired keys:
remediation-orchestrator: the values the stack sets from top-level state, which areimage,imagePullSecrets,environmentId,publicUrl,auth,development,config,telemetry,database.existingSecret,database.connectionStringKey,temporal.address,temporal.namespaceandtemporal.auth. Alsodatabase.migrateOnStartup, because the bootstrap Job is the only migrator, and the reservedextensions.fullnameOverride,database.poolMaxConnections,temporal.uiUrl,temporal.uiandtemporal.uiProxypass through.cnpg.values: names, namespace, image,config.clusterWide, the webhook Service name,webhook.mutating.create,webhook.validating.create,crds.create.postgresql.values: names, namespace, image, instances, storage, pull Secrets,initdb, mode, recovery.temporal.values: names, images,web.enabled,server.replicaCount,server.config.persistence.numHistoryShards,defaultStoreandvisibilityStore, the connection fields,sql.createDatabase,sql.manageSchema,cassandraandelasticsearchunderserver.config.persistence.datastores.<default|visibility>, TLS (server.tls,server.config.tls), ports, pull Secrets,server.enabled,server.config.namespaces.create,schema.useHelmHooks,schema.enabled,schema.activeDeadlineSeconds, andadmintools.additionalEnventries namedSQL_PLUGIN,SQL_HOST,SQL_PORT,SQL_DATABASE,SQL_USERorSQL_PASSWORD.telemetry.values: names, namespace,imageandglobal.imageRegistry, pull Secrets, OTLP receiver and port,alternateConfig,mode,service.enabled,command.
The authoritative list of protected NRO passthrough keys is validate.nroOwned in
_validate.tpl; that check reports every hit at once. The
list for the upstream charts is passthrough.protected in
_passthrough.tpl. Setting any parent of a
protected upstream path to null or a scalar also fails. cnpg.values.imagePullSecrets
is allowed because the top-level imagePullSecrets does not reach the operator’s
namespace.
No key anywhere in temporal.values may start with helm.sh/ or meta.helm.sh/. The
stack owns hook ordering, delete policies, resource retention and release ownership, and
chart 1.7.0 writes schema.jobAnnotations after its own hook annotations. The checks do
not inspect manifest strings in extraObjects. Store tuning such as maxConns,
maxIdleConns, maxConnLifetime, connectAttributes and tls stays open under
server.config.persistence.datastores.<store>.sql. Keep credentials out of
connectAttributes, because the chart renders it into the server ConfigMap.
Passthroughs carry the same trust as the Helmfile itself. The protections catch an
accidental override of a key the stack wires. One indirect channel is guarded:
temporal.values.admintools.additionalEnv may not name the six SQL_* variables that
point the schema hook at nro-temporal-db
(Temporal schema migration). The others stay
open, such as other additionalEnv entries, additionalInitContainers or extraObjects
manifests, and remain the operator’s responsibility.
These open keys reach a setting that a protected key guards, and no check catches them. Leave them unset:
- A nonzero
temporal.values.server.<service>.replicaCountsets that service’s replica count in place oftemporal.replicas. temporal.values.server.frontend.enabled: falseremoves thenro-temporal-frontendDeployment and Service that NRO and bootstrap dial.telemetry.values.configMap.create: falseremoves the collector’s generated configuration, and withconfigMap.existingNamebeside it the collector reads that ConfigMap instead. The protectedalternateConfigguards the same configuration.cnpg.values.config.data.WATCH_NAMESPACEwritesWATCH_NAMESPACEinto the operator’s configuration ConfigMap, which theconfig.clusterWidecheck does not inspect.
Helmfile’s own --set and --values flags take a different path. They pass chart values
directly to every release the command selects, after the passthrough. Neither the state
checks nor the protected paths see them: -l name=nro-db --set fullnameOverride=x
renames the cluster that NRO and bootstrap look for. Reserve them for one-off operator
experiments, and keep every lasting change in state.
Configure the NRO chart’s optional Ingress, HTTPRoute, ServiceMonitor,
PodDisruptionBudget and Temporal UI proxy through the NRO passthrough. When
temporal.web and remediation-orchestrator.temporal.uiProxy.enabled are both true,
Helmfile sets TEMPORAL_UI_PUBLIC_PATH=/temporal on the managed UI and points the proxy
at nro-temporal-web. To target a different UI, set
remediation-orchestrator.temporal.ui.service. Lists replace rather than merge, so in that
configuration a temporal.values.web.additionalEnv list must keep
{name: TEMPORAL_UI_PUBLIC_PATH, value: /temporal}, or the render fails. The check passes
when any entry matches, even if another entry sets a different value, so list the
variable once.
Typical uses of the upstream passthroughs:
For example, to give both database clusters more resources:
Check each change with template before sync, because the upstream chart, not this
stack, validates these values. The chart links in the table open the versions that
helmfile/locks/upstream.lock.json pins.
To pull the Temporal and collector images from a mirror, set upstreamImages.* in your
state file; defaults.yaml documents each key.
The CNPG operator and PostgreSQL images are cnpg.expectedImage and postgresql.image,
and the helm test image is remediation-orchestrator.tests.image.
Next steps
- Apply a state change: render and sync as in Render, deploy and verify.
- Change how users sign in: Authentication and access.
- Use PostgreSQL, Temporal or a collector you already run: Databases, Temporal, and telemetry.