nais apply

nais apply PATH [flags]

Apply Nais resource manifests (YAML) to a specific team and environment. Accepts a single file or a directory containing multiple manifests.

For a single file, repeat –mixin to merge multiple YAML files in the order provided. Later values win, but lists are concatenated without deduplication: the same environment variable name in two mixins produces two list entries, not an overwrite. Use –set to replace a list or update an existing entry.

Explicit –mixin flags disable automatic loading of <base>.<env>.yaml. Include the environment mixin explicitly if it should also be applied. The processing order is always base, mixins in the order provided, all –set overrides, then all –append operations, regardless of flag positions.

When a directory is given, mixin files (<base>.<env>.yaml) are auto-loaded and –set/–append/–mixin flags are disabled.

Options

--allow-ignored-fields
Warn instead of failing when a manifest contains fields that nais apply ignores (e.g. METADATA.NAMESPACE or METADATA.ANNOTATIONS).
--append
Append one YAML value to a list as KEY=VALUE (e.g. spec.env={name: LOG_LEVEL, value: debug}). Creates missing lists. Can be repeated; applied in order after all –set overrides.
--dry-run
Preview which resources would be applied without making any changes.
--mixin
YAML FILE deep-merged over the base manifest. Can be repeated; applied in order, with later values winning and lists concatenated. If omitted, an adjacent <base>.<env>.yaml is auto-loaded when present.
--set
Replace a field as KEY=VALUE using a dotted path with optional zero-based list indices (e.g. spec.env[0].value=debug). Values are parsed as YAML, including lists and maps. Can be repeated; applied in order.
--timeout
Maximum time to wait for resources to become ready when --WAIT is set. Examples: 30s, 5m, 10m.
--wait
Wait for applied resources to become ready before returning. Currently supported for APPLICATION resources; other kinds are skipped.

Inherited options

--config
Specify the PATH to the configuration file.
--confirm-login
Ask for confirmation before starting required login flows. Interactive terminals only.
-e, --environment
Select or filter by Nais ENVIRONMENT, for example dev-gcp or prod-gcp. Overrides the environment configured with nais defaults set environment.
--no-colors
Disable colors in the output.
-t, --team
Select the Nais TEAM that owns the resources. Overrides the team configured with nais defaults set team.
-v, --verbose
Set verbosity level. Use -v for verbose, -vv for debug, -vvv for trace.

Examples

# Merge multiple mixins in order; later values win and lists are concatenated.
$ nais apply app.yaml --environment dev-fss --team nais --mixin app.dev-fss.yaml --mixin app.q2.yaml

# Replace the environment variable list.
$ nais apply app.yaml --environment dev-gcp --team nais --set 'spec.env=[{name: LOG_LEVEL, value: debug}]'

# Update a field in an existing list element.
$ nais apply app.yaml --environment dev-gcp --team nais --set 'spec.env[0].value=debug'

# Append an environment variable without replacing existing entries.
$ nais apply app.yaml --environment dev-gcp --team nais --append 'spec.env={name: LOG_LEVEL, value: debug}'