wardn cluster
Connect a Kubernetes cluster to Wardn with connect, revoke its credentials with disconnect, and remove the operator with uninstall.
wardn cluster joins a cluster to your Wardn and, when you are done, takes it out again. It has three subcommands: connect installs the operator, uninstall removes it, and disconnect revokes the cluster's credentials in Wardn. Set up the CLI first (CLI); for the web app route and what the operator reports once it runs, read Connect a cluster.
The cluster never needs to accept a connection from Wardn. The operator you install dials out to the gateway over mutual TLS, so the only network rule is outbound access from the cluster to the gateway's address.
connect
wardn cluster connect (--create --name <name> | --cluster-id <id>) --gateway-url <url> [flags]It does three things, in order:
- With
--create, registers a new cluster in Wardn, and printsRegistered cluster <name> (<id>). - Makes a one-time join token through the API. The token is valid for an hour, is shown nowhere (the CLI never prints it) and is used once, when the operator first joins. Making a token ends the cluster's earlier unused ones.
- Installs the operator in the cluster your kubeconfig points at, with the token in a Secret, and prints
Installed the operator in namespace wardn-system. The join token expires at <time>.
Your kubeconfig is used for the install only. It is never stored, and never sent to Wardn. The install is a server-side apply, so running connect again changes only what differs.
Choose the cluster
Give exactly one of these:
| Flag | Use it when |
|---|---|
--create with --name | The cluster is not in Wardn yet. The command registers it first. |
--cluster-id | The cluster is registered already (from the web app, or an earlier run), and you are connecting, reconnecting or upgrading its operator. Find the id with wardn clusters. |
Using both, or neither, stops the command before it calls anything.
Flags
| Flag | Default | Meaning |
|---|---|---|
--gateway-url | $WARDN_GATEWAY_URL | Required. The address the operator dials, such as https://gateway.example.com:8443. It must be reachable from the cluster and its certificate must be valid for that name (The gateway). |
--create | false | Register a new cluster first. Needs --name. |
--cluster-id | none | Connect a cluster that is already registered. |
--name | none | The name of the new cluster. |
--tier | development | The tier of a new cluster that is in no environment: production, staging or development. A cluster in an environment has that environment's tier. Production clusters take stricter rules, such as a reason for every terminal session. |
--environment | none | The id of the environment to put the new cluster in. Without it, an environment whose selector matches the cluster's labels may place it. |
--cloud | empty | Optional. The operator reads the cloud from the nodes after it joins and fills it unless you set one. |
--region | empty | Optional. Read from the nodes the same way. |
--kubeconfig | $KUBECONFIG | The kubeconfig to install with. Empty uses the standard lookup (~/.kube/config). |
--context | the current context | The kubeconfig context to install into. |
--namespaces | none | Limit the operator to these namespaces, comma separated. See Limit the operator to some namespaces. |
--image | ghcr.io/future-pirate-king/operator:<CLI version> | The operator image. A CLI built without a version uses latest. |
--gateway-ca-file | none | A PEM file with the CA that signed the gateway's certificate, for a gateway certificate from a private CA other than Wardn's. Installed as a ConfigMap. |
--snapshot-keys-file | none | A PEM file of the public keys snapshots and commands must be signed with, from wardn snapshot-keys public. The operator then trusts the snapshot keys alone and refuses an unsigned snapshot, and trusts the command keys alone and runs each signed command once, whatever the server says. A file with no command key is refused unless --allow-unpinned-commands is given, since it would leave commands to the key the server announces. Upgrade the server first: a pinned operator of this release refuses commands from a server that does not sign them for its cluster. See Pin the key in the operator. Installed as a ConfigMap. |
--allow-unpinned-commands | false | Accept a --snapshot-keys-file that holds snapshot keys and no command key. Commands (exec, restarts, scales) then stay with the key the server announces. |
--disable-capabilities | none | Capabilities the operator never offers, so the server cannot turn them on: apply, detect-drift, run-tests, exec, logs. Restarts and scales ride on apply. For a cluster where the server is not trusted with a terminal in a pod, leave exec off here. |
--allow-insecure-gateway | false | Let the operator use an http:// gateway URL. Local development only: nothing is encrypted. |
--dry-run | false | Print the manifests and change nothing. Calls no API and no cluster. |
--api, --token | The global flags. connect needs the token, except with --dry-run. |
You need cluster:register to register a cluster and cluster:manage to make its join token (Roles and grants).
What it installs
Everything goes in the namespace wardn-system, which the command creates.
| Object | Name | Purpose |
|---|---|---|
| Namespace | wardn-system | Holds the operator. |
| ServiceAccount | wardn-operator | The operator's identity. |
| ClusterRole and ClusterRoleBinding | wardn-operator | Read-only get, list and watch on nodes, namespaces, pods, services, persistent volume claims, events, Deployments, StatefulSets, DaemonSets, Jobs, CronJobs and Ingresses; and impersonate on service accounts named wardn-deployer, and no other. It has no rule for Secrets or for writing to your workloads. |
| ClusterRole | wardn-preview-deployer | The one role the operator can hand to a pull request preview's namespace. Not created with --namespaces. |
| Role and RoleBinding | wardn-operator, in wardn-system | Lets the operator keep its identity Secret and its state ConfigMaps. |
| Secret | wardn-operator-join | The join token. After the operator has joined, it is not used again. |
| ConfigMap | wardn-gateway-ca | The CA from --gateway-ca-file. Only with that flag. |
| ConfigMap | wardn-snapshot-keys | The keys from --snapshot-keys-file. Only with that flag. |
| Deployment | wardn-operator | One replica, strategy Recreate, running non-root with a read-only filesystem and every capability dropped. Requests 50m CPU and 128 MiB, limit 256 MiB. |
The operator never applies your manifests as itself. It applies each deployment's objects as that deployment's own service account, through the impersonate rule, which names only the wardn-deployer account, so what a deployment can change is what its service account is allowed to change in Kubernetes. See How it works.
Examples
Register a production cluster and install the operator in one step:
export WARDN_API_URL=https://wardn.example.com
export WARDN_TOKEN=wrd_...
export WARDN_GATEWAY_URL=https://gateway.example.com:8443
wardn cluster connect --create --name prod-eu-1 --tier production \
--context prod-eu-1Registered cluster prod-eu-1 (6f0c2a1e-...)
Installed the operator in namespace wardn-system. The join token expires at 14:32 UTC.The cluster appears in the web app. When the operator has joined, it shows as online (wardn clusters shows the same).
Limit the operator to some namespaces
By default the operator can read the whole cluster. With --namespaces it gets a Role in each listed namespace instead of the cluster-wide read rule, so it sees nothing outside them:
wardn cluster connect --cluster-id 6f0c2a1e-... \
--gateway-url https://gateway.example.com:8443 \
--namespaces shop,paymentsNodes and namespaces stay readable cluster-wide, since a cluster's health comes from its nodes. The namespaces must already exist: the operator cannot create them. A scoped operator makes no pull request previews, because a preview needs a namespace of its own. Pass the same list every time you run connect again; leaving it out gives the operator cluster-wide read access.
A gateway with a private CA
Wardn's own certificate authority is pinned in the join token, so a gateway certificate that Wardn signed needs no CA file, and a certificate from a public CA is trusted through the system's roots. If the gateway presents a certificate from some other private CA, give the operator that CA:
wardn cluster connect --cluster-id 6f0c2a1e-... \
--gateway-url https://gateway.example.com:8443 \
--gateway-ca-file ./company-ca.pemErrors
| Message | Cause and fix |
|---|---|
give --cluster-id, or --create with --name | Neither mode was chosen. |
--cluster-id and --create cannot be used together | Choose one. |
--gateway-url is required | Pass the flag, or set WARDN_GATEWAY_URL. |
--token (or WARDN_TOKEN) is required to call the API | Set the token. |
create the cluster: wardn API error: ... | The API refused the registration, for example for a missing name or a missing cluster:register. The message and code say which. Nothing is installed. |
create a join token: ... operator.no_gateway | No gateway has started yet, so Wardn has no certificate authority to pin. Start the server with the gateway role (The gateway). |
kubeconfig: ... or kubernetes client: ... | The kubeconfig could not be read. With --create, the cluster is already registered by then: run again with --cluster-id. |
install the operator (the join token expires at ...; run again for a new one): ... | Kubernetes refused an object; the message after the colon says which and why. Fix that and run again; a new token is made. |
The exact API error text comes from the server. The code in the brackets is stable and is listed with each operation in the API.
disconnect
wardn cluster disconnect --cluster-id <id>Revokes the cluster's certificate, its stream tokens and its unused join tokens. A connected operator is cut off within seconds, and Wardn refuses it until you make a new join token and the operator joins again (wardn cluster connect --cluster-id <id>). The cluster, its history and its snapshots stay in Wardn. Nothing changes in the cluster itself: what the operator applied keeps running.
Use it when a cluster is lost or retired, or its credentials may have leaked.
| Flag | Default | Meaning |
|---|---|---|
--cluster-id | none | Required. The cluster to cut off. |
--api, --token | The global flags. The token is required. |
It prints Credentials revoked. and needs cluster:manage on the cluster. An unknown id comes back as the API's not found error.
uninstall
wardn cluster uninstall [--kubeconfig <file>] [--context <name>] [--dry-run]Deletes the objects connect made, in reverse order: the Deployment first and the namespace last. It deletes only those objects, so your workloads, in any other namespace, are not touched. It does not call Wardn and needs no token.
| Flag | Default | Meaning |
|---|---|---|
--kubeconfig | $KUBECONFIG | The kubeconfig to use. |
--context | the current context | The kubeconfig context. |
--dry-run | false | Print the manifests it would delete and change nothing. |
It prints Removed the operator and its namespace. Workloads in other namespaces were not touched. Run wardn cluster disconnect to revoke the cluster's credentials.
uninstall does not remove the Roles and RoleBindings that --namespaces made in the namespaces you listed. They are named wardn-operator and labelled app.kubernetes.io/managed-by=wardn-cli; delete them yourself when you remove a scoped operator.
To retire a cluster fully, run uninstall against it, then disconnect for it. The cluster stays listed in Wardn, offline, with its history.