Connect a cluster

Register a cluster, install the operator with a one-time join token, and prepare the namespaces Wardn deploys into.

A cluster joins Wardn through the operator, one small Deployment in the namespace wardn-system. The operator dials out to the control plane's gateway over mutual TLS and keeps that connection open. Nothing needs to reach into the cluster: it needs only outbound HTTPS to the gateway. How it works explains the control plane, the gateway and the operator; this page is the how-to.

Before you start you need a running Wardn, the address of its gateway (ask whoever runs Wardn, or see The gateway), a kubeconfig that can create namespaces, cluster roles and deployments in the cluster, and the cluster:register permission to register a new cluster.

Connect it

Connecting is two steps: register the cluster in Wardn, then install the operator with a join token. The web app and the CLI do the same thing; the CLI does both steps in one command.

Register the cluster

Open Clusters and choose Connect a cluster. Under Details fill in:

FieldWhat it is for
NameHow people and the API name the cluster.
EnvironmentThe environment to put the cluster in, or None yet. A cluster in an environment has that environment's tier.
TierShown only while the environment is None yet: Production, Staging or Development. Only production clusters count as production for billing, and agent sandboxes are never allowed on them.
LabelsKey and value pairs. Environments and guardrails select clusters by label.

Cloud and region are not asked for. The operator reads them from the nodes' labels once it connects, and you can edit them in the cluster's Settings; a value you type is never replaced by a later reading.

Choose Create cluster. The cluster is now registered and waiting for its operator.

Choose what the operator may read

Under What it needs, Permissions sets how much of the cluster the operator can see:

  • Cluster-wide: the operator reads every namespace, and can make namespaces for pull request previews.
  • Only listed namespaces: one namespace per line, each of which must exist. The operator gets read rights in those namespaces only and makes no previews.

Install the operator

Install the operator shows the command to run against the cluster, for the Wardn CLI, kubectl, Helm or Terraform. Run it with a kubeconfig for the cluster.

Install with Helm

The wardn-operator chart renders the same objects as wardn cluster connect --dry-run (a test compares the two on every change), so it suits Helm and GitOps installs. Install it in wardn-system, which is the namespace the operator's defaults name:

helm install wardn-operator oci://ghcr.io/future-pirate-king/charts/wardn-operator \
  --namespace wardn-system --create-namespace \
  --set gatewayUrl=https://gateway.wardn.example \
  --set clusterId=<cluster id> \
  --set joinToken=<join token>

Make the join token with Or install by hand; it works once and expires in an hour. To keep it out of your values, store it in a Secret and set existingSecret (and existingSecretKey, join-token by default) instead of joinToken.

ValueWhat it does
gatewayUrlThe address of Wardn's gateway. Required.
joinToken, existingSecretThe join token, or the Secret that holds it. One is required.
clusterIdWritten on the Deployment as the annotation wardn.dev/cluster-id, for whoever reads the cluster.
imageThe operator image. Empty runs the release that matches the chart.
namespacesLimits what the operator may read to these namespaces, like --namespaces.
disableCapabilitiesCapabilities to leave out: apply, detect-drift, run-tests, exec.
gatewayCA, snapshotKeys, commandKeysPEM bundles: the gateway's CA, and the keys snapshots and commands must be signed with.
resourcesThe operator's requests and limits.

To install by hand instead, Or install by hand makes a one-time join token, shown once, and gives the kubectl command that stores it in the Secret wardn-operator-join in wardn-system. Apply the manifests from wardn cluster connect --dry-run after it.

Wait for it

Waiting for the cluster follows four steps as they happen: Cluster registered, Join token, Operator joined and First report. When nodes and the Kubernetes version appear, choose Open cluster.

wardn cluster connect flags

FlagDefaultMeaning
--createoffRegister a new cluster first. Needs --name.
--nameThe new cluster's name.
--cluster-idConnect a cluster that is already registered.
--tierdevelopmentproduction, staging or development, for a new cluster in no environment. A cluster in an environment has that environment's tier.
--environmentThe id of the environment to put a new cluster in.
--cloud, --regionemptyOptional. Leave them out and the operator reads them from the nodes.
--gateway-url$WARDN_GATEWAY_URLWhere the operator dials. Required.
--gateway-ca-fileA PEM file with the CA that signed the gateway's certificate, installed as a ConfigMap. Only for a certificate from a private CA other than Wardn's: the join token already pins Wardn's own CA.
--namespacesthe whole clusterLimit the operator to these namespaces. It gets Roles there instead of cluster-wide read rights, and makes no previews.
--no-cutoveroffDo not let the operator change or remove Argo CD Applications, Flux Kustomizations and Flux HelmReleases. See The cutover role.
--imageghcr.io/future-pirate-king/operator:<CLI version>The operator image.
--kubeconfig, --context$KUBECONFIG, current contextWhich cluster to install into.
--dry-runoffPrint the manifests and change nothing.
--allow-insecure-gatewayoffLet the operator use an http:// gateway URL. Local development only.

The join token

A join token is how a new operator proves it may join this cluster and no other.

  • It is shown once, works once, and is valid for an hour. Wardn keeps only a hash of it.
  • Making a new token ends the cluster's earlier unused ones. If the first one expires, run wardn cluster connect --cluster-id <id> again, or make another in the web app, or call POST /api/v1/clusters/{clusterId}/join-tokens (cluster:manage).
  • The operator trades the token for a client certificate and keeps that identity in a Secret in wardn-system. From then on it reconnects by itself, and the token is no longer needed.
  • The token carries a pin of Wardn's certificate authority. That is how the operator trusts a gateway certificate that Wardn generated, without you distributing a CA file.
  • An operator that joins a cluster that already has an identity replaces the old one.

What gets installed

Everything goes in wardn-system, apart from the cluster roles. Nothing is a CRD: there are no Wardn custom resources to write by hand.

ObjectWhy
Namespace wardn-systemWhere the operator runs.
A service account for the operatorThe operator's own identity in the cluster.
Cluster-wide get, list and watch on nodes, namespaces, pods, services, persistent volume claims, events, Deployments, StatefulSets, DaemonSets, Jobs, CronJobs and IngressesTo report inventory and health, and to notice drift. With --namespaces, these are Roles in the listed namespaces, and nodes and namespaces stay readable cluster-wide.
get and impersonate on service accounts named wardn-deployerThe operator applies each deployment as the wardn-deployer account of that deployment's namespace, never as itself, and reads that one account to tell a namespace nobody prepared. The rule lists that one name, so the operator cannot act as any other service account (a controller's, say, or one with broader rights). It has no other write access to your workloads.
create and delete on namespaces, create on service accounts and role bindings, and bind on the ClusterRoles wardn-preview-deployer and admin onlyTo make and remove the namespace of a pull request preview, and to prepare a deployment's namespace when the cluster's switch is on. The operator hands out no other role, and the binding is inside one namespace. Left out with --namespaces.
The ClusterRole wardn-preview-deployerWhat a preview's service account may do in its own namespace: workloads, config, networking and RBAC objects, like the built-in admin role without pod exec or port-forward. Nothing cluster-scoped.
The ClusterRole wardn-operator-cutoverwatch, patch and delete on Argo CD Applications, Flux Kustomizations and Flux HelmReleases, and nothing else. With --namespaces, a Role in each listed namespace instead. Left out with --no-cutover. See The cutover role.
A Role in wardn-systemTo keep the operator's identity Secret and the ConfigMaps where it remembers what it applied, so a restart neither prunes what it forgot nor reports false drift.
The join token, in a SecretRead once, at the first connection.
The operator DeploymentOne replica, a read-only root file system and no added capabilities. The old operator stops before a new one starts.

The cutover role

When Wardn takes over an app that Argo CD or Flux deploys, the operator has to stop the tool first: turn off an Application's auto-sync or suspend a Kustomization or HelmRelease, remove the tool's finalizers, delete the tool's object while leaving what it deployed in place, and watch the object in case the tool or a person puts it back. For that, the install adds a second ClusterRole, wardn-operator-cutover, bound to the operator's service account. It grants watch, patch and delete on applications in argoproj.io, on kustomizations in kustomize.toolkit.fluxcd.io and on helmreleases in helm.toolkit.fluxcd.io. It grants nothing on ApplicationSets, which the operator can only read, nothing on Secrets, HelmCharts or Helm's release records, and no create, update or wildcard rules.

The operator uses it only during a cutover that a person started, or that a request approved by your guardrails started. It touches one object at a time, and only the fields a cutover needs. Kubernetes RBAC cannot limit which fields of an object may be patched, so that limit is in the operator's code, not in the role.

A ValidatingAdmissionPolicy could narrow patch at the API server as well: for the operator's service account, reject an update of an Application, Kustomization or HelmRelease that changes anything other than the cutover's own wardn.dev/* annotations, the auto-sync or suspend settings, the tool's finalizers (removal only) and its refresh annotations, and a delete without orphaning. Wardn does not ship such a policy yet; you can add one yourself.

Being able to change Argo CD Applications is equivalent to cluster-admin through Argo CD. Argo CD applies whatever an Application points at, with its own, usually broad, permissions. Treat this role as that level of access, and leave it out if you do not want to grant it:

wardn cluster connect --cluster-id <id> --no-cutover

Without the role, Wardn still scans and observes Argo CD and Flux, but a cutover cannot run. A cluster connected before this role existed does not have it: run wardn cluster connect --cluster-id <id> again, without --no-cutover, to add it. Running connect again with --no-cutover does not remove a role that is already there; wardn cluster uninstall removes the cluster-wide role along with the rest.

Let Wardn deploy into a namespace

The operator applies a deployment as the service account wardn-deployer in the deployment's namespace. That account has to exist, and its RBAC decides what Wardn can touch there.

Let Wardn prepare it

Prepare namespace in the cluster's Settings (and in the first deployment's form) lets Wardn make the namespace, the wardn-deployer account and a RoleBinding to the built-in admin ClusterRole before it applies, on the first apply and every one after. It is on by default for development and staging clusters and off for production, until you choose; change it whenever you like, and the change is recorded in Activity. A namespace that already exists is left as it is, apart from the account and its binding. Wardn never deletes a namespace it prepared.

Clusters connected before this existed start with it off. Turning it on needs the operator's newer permissions (bind on admin): re-run wardn cluster connect or helm upgrade first. An older operator that cannot bind still applies when the namespace and account already exist; otherwise the deployment fails with deployment.namespace_prepare_forbidden.

With it off, you prepare the namespace. A deployment whose namespace or account is missing fails with deployment.namespace_not_prepared and the commands below.

Prepare it yourself

Binding the account to the built-in admin ClusterRole with a RoleBinding is the usual choice:

kubectl create namespace shop
kubectl -n shop create serviceaccount wardn-deployer
kubectl -n shop create rolebinding wardn-deployer --clusterrole=admin --serviceaccount=shop:wardn-deployer

You can bind a narrower role instead. An object the account may not create fails the apply with the cluster's own error, which the deployment shows.

The operator checks every snapshot before it applies anything, and refuses the whole snapshot, with nothing applied, when it holds:

  • an object in a namespace other than the deployment's;
  • a cluster-scoped object, such as a Namespace, CustomResourceDefinition or ClusterRole (create those yourself, once, outside Wardn);
  • an object that Argo CD or Flux already manages. Two controllers never own one object: remove it from the other tool first.

An object that names no namespace is put in the deployment's namespace. The namespaces kube-system and wardn-system are never managed.

Which namespaces Wardn may manage

A cluster's settings say which namespaces deployments may use: all namespaces apart from the ones Wardn never manages, or only a listed set. People with cluster:manage change them on the cluster's settings, or with PUT /api/v1/clusters/{clusterId}/settings. A connected operator picks up the change.

The cluster's Deployments tab also lists namespaces that hold pods but that no deployment accounts for. Adopting one creates a deployment for it that only observes, so you can see what Wardn would change before it changes anything. See Deployment settings.

What crosses the network

DirectionWhat
Operator to gatewayInventory (nodes, node pools, pods, the Kubernetes version), health of what Wardn applied, drift, results of applies and jobs, secret reference fingerprints, and pod events that feed the cluster's timeline.
Gateway to operatorCommands signed by the control plane, such as "apply this snapshot", and settings changes such as the managed namespaces. The operator checks the signature before it acts.
NeverYour kubeconfig, secret values, or any inbound connection to the cluster.

Check that it is connected

The operator keeps one stream open to the gateway and sends a heartbeat on it. A cluster is shown as disconnected when it has no stream, or has sent no heartbeat for two minutes.

Open Clusters. A connected cluster shows its nodes and its Kubernetes version once the first report has arrived. Open the cluster for its inventory, its Deployments tab and its timeline.

If it does not connect

What you seeWhy, and what to do
The operator Pod restarts, or its log shows it cannot reach the gateway.The cluster has no outbound route to the gateway address you passed as --gateway-url. Test it from a Pod in the cluster. The gateway speaks mutual TLS on its own port (8443 in the charts), so a proxy or load balancer in front must pass TCP through and not terminate TLS.
The log shows a certificate error for the gateway.The name in --gateway-url is not one of the names the gateway certificate covers. A generated certificate covers gateway.hosts of the chart; add the name there, or use the name that is listed. See The gateway.
The log shows the join token being refused.A token works once and for an hour, and a newer token ends the older unused ones. Make a new one with wardn cluster connect --cluster-id <id>.
The cluster was connected and is now Disconnected.An operator that stays offline longer than its stream token lasts (six hours) may need a new join token. Shorter outages heal by themselves; see Failures and offline clusters.
wardn cluster connect fails before it installs anything.The kubeconfig cannot create a namespace and cluster roles, or the token behind WARDN_TOKEN lacks cluster:register or cluster:manage.

Operators do not upgrade themselves: upgrade them together with the control plane, in the order Upgrading gives.

CPU and memory usage

The cluster card, the cluster's overview and its nodes list show how much CPU and memory the nodes use, as a percent of what they can allocate; hover a bar for the figures. The operator reads usage from the Kubernetes metrics API (metrics.k8s.io), which metrics-server serves. DigitalOcean installs it by default; kind and many bare clusters do not. Without it the bars show a dash, never zero, with the hint "Install metrics-server to see usage". The operator's ClusterRole grants get and list on nodes in metrics.k8s.io; an operator installed before this rule existed shows the same dash until its manifests are applied again.

Labels and where the cluster goes next

Only production clusters count as production for billing, and agent sandboxes are never allowed on them. Labels are how environments and guardrails find the cluster: an environment selects the clusters whose labels match, so label a cluster region=eu or team=payments once and it joins the right environments without further steps.

Disconnect and remove

wardn cluster disconnect --cluster-id <id>   # revoke the cluster's credentials; a live operator is cut off within seconds
wardn cluster uninstall --context prod-eu-1  # delete the operator's manifests; workloads are left alone

A disconnected cluster keeps its inventory and history, and the gateway refuses its operator until it is reconnected (POST /api/v1/clusters/{clusterId}/reconnect). Reconnecting needs a new join token.

Next

Related: wardn cluster, The gateway, Security model.

On this page