Environments and many clusters

Group clusters into environments by label, set a deploy window, and run one deployment on every cluster of an environment.

An environment is a named group of clusters, such as dev, staging or prod. It answers the question "where does this change land?" for everything that comes later: a pipeline has one stage per environment, a guardrail can apply to every environment of a class, and a deployment can target an environment instead of one cluster so it runs on all of them. The model is explained in Environments.

Before you start, connect at least one cluster. Creating an environment takes environment:create, which Owners and Admins hold. Whoever creates an environment becomes its owner.

What an environment holds

FieldMeaning
NameUp to 48 characters, shown everywhere the environment appears.
DescriptionOptional, up to 500 characters.
ClassA free-form label, up to 40 characters, that says what kind of environment this is. The web app suggests production, staging, development and qa.
OrderIts place in lists, lowest first. A new environment goes last.
SelectorCluster labels. A cluster that has no environment and carries every label of the selector joins this environment.
ClustersThe clusters in it. A cluster belongs to exactly one environment, or to none.
OwnersThe people who manage it and decide who may act on it.

The class matters more than it looks. Wardn reads it in two places:

  • The built-in guardrail Protected branch for production applies to every environment whose class is production (compared without regard to case). See Guardrails.
  • Guardrails, freezes and pipeline presets can select environments by class, so one rule covers every production environment you add later.

A cluster in an environment has that environment's tier: production for the production class, development for development, staging for any other class. The cluster's settings show it read-only, and it follows when the cluster moves or the class changes. A cluster in no environment keeps a tier of its own, which you can set. The tier decides, for example, whether opening a terminal needs a reason, and a cluster that becomes production stops hosting agent sandboxes until the warning is acknowledged again.

The environment's screens

Open an environment from Environments in the sidebar. Its tabs are Clusters, Deployments, Guardrails (every guardrail that reaches it, see Guardrails), Pipelines (the pipelines that have a stage here, see Pipelines) and Settings.

Create an environment

Open Environments in the sidebar and choose New environment.

Give it a Name, an optional Description and a Class, then choose Create environment. The app opens the new environment.

Open its Settings tab to add a selector under Clusters (Add label), set a Default deploy window, or add Notifications. Choose Save. Changes are recorded in Activity.

Put clusters in an environment

There are two ways a cluster joins an environment.

By assigning it. On the Environments screen, the section Clusters not in an environment lists every cluster without one, each with an Assign to an environment menu. Assigning needs cluster:manage on the cluster. Through the API, set environmentId in PUT /clusters/{id}.

By label. Give the environment a selector, and give clusters labels. Wardn runs the label rule:

  • when you save an environment's selector, over every cluster that has no environment;
  • when a cluster is registered or its labels change, for that cluster.

The rule only ever places a cluster that has no environment. It never moves a cluster out of one environment into another, so changing a selector cannot silently move production clusters. A selector matches when the cluster carries every one of its labels with the same value. An empty selector matches nothing, and an archived environment is never chosen.

When several environments select the same cluster, the one listed first wins: lowest order, then name, then id.

Labels are key=value pairs. A key is 1 to 63 letters, digits, dots, dashes, underscores or slashes; a value is up to 63 of the same, without slashes. You can edit a cluster's labels on the environment's Clusters tab, where each row has a New label field.

A cluster that is in no environment can still be the target of a deployment. Only guardrails scoped to the whole organization apply to it, and pipelines cannot reach it, because a stage runs in an environment.

One deployment on many clusters

A deployment normally targets one cluster. Target an environment instead and Wardn applies the same snapshot to every cluster in it. This replaces copying the same app definition once per cluster.

api -X POST "$WARDN_API_URL/api/v1/deployments" -d '{
  "name": "checkout-prod",
  "apps": [{"appId": "'"$APP_ID"'"}],
  "targetKind": "environment",
  "environmentId": "'"$ENVIRONMENT_ID"'",
  "namespace": "checkout",
  "arrival": "branch",
  "branch": "main"
}'

How it behaves:

  • One snapshot, many applies. When a snapshot is delivered, Wardn queues one apply for each cluster the environment holds at that moment. Each cluster's operator applies it on its own. An apply queued for an offline cluster waits for it for a limited time; see Failures and offline clusters.
  • State per cluster. GET /deployments/{id}/state has a clusters list with the sync and health of each cluster. The deployment's own state is their roll-up: applied when every cluster has applied, health the worst of theirs.
  • A cluster that joins later. A newly placed cluster gets the deployment with the next apply. To apply the current snapshot there now, use Sync on the deployment (POST /deployments/{id}/sync, needs deployment:sync).
  • Drift, restore and rollback work per cluster. A drift revert is queued only for the clusters that reported drift; a restore is queued for every cluster. See Drift and Restore and rollback.

The recipe for one app on every cluster puts this together with labels.

Deploy windows

A deploy window says on which days and between which hours changes should land in an environment, in its time zone. Set it on the environment's Settings tab under Default deploy window: switch on Limit deployments, tick the Days, set the Hours and the Time zone.

Prop

Type

api -X PUT "$WARDN_API_URL/api/v1/environments/$ENVIRONMENT_ID/settings" -d '{
  "deployWindow": {"days": ["mon","tue","wed","thu"], "start": "09:00", "end": "16:00", "timeZone": "Europe/Berlin"},
  "notificationTargets": []
}'

A window does not cross midnight, and an environment has one window. If you need an overnight slot, describe the hours you want to keep clear with a freeze instead. Set deployWindow to null to allow changes at any time.

The environment's window is stored, shown, and drawn on the release calendar. It does not stop an apply that starts outside it. To keep changes out at set times, use a freeze, which a guardrail enforces, or a window rule on the environment's pipeline stage, which holds a snapshot that arrives outside its days and hours.

Notifications

Under Notifications you can list up to 20 places where changes in the environment should be announced: a Slack channel, an email address, or an https webhook without a user name or password. They are stored as configuration. Nothing is delivered to them yet.

Who can see an environment

Someone who can read the environment (its owners, people granted it, and the Owner) sees all of it. Someone who can read only a deployment that runs there gets a limited view: the environment's name and the deployments of theirs in it, under Your deployments here. Its clusters, guardrails and settings stay hidden. See Who sees what.

Archive an environment

On the Settings tab, the Danger zone has Archive. An environment that still holds clusters cannot be archived: move them out first. After archiving, pipelines and guardrails that name it stop matching it, and its settings cannot be changed. Restore brings it back, and clusters can join it again. Its history stays in Activity.

Permissions

ActionPermission
See an environmentenvironment:read
Create oneenvironment:create (Owner, Admin)
Change details, selector, window, notifications, archiveenvironment:manage (its owners)
Assign a cluster, edit a cluster's labelscluster:manage on the cluster
Create a deployment on itdeployment:manage

Next

On this page