# CLI reference

`kite` runs on your workstation. `kite-agent` runs as root on a Linux node.
`kite-control` is the self-hosted control plane, which runs under systemd on
your own servers.

| Commands                                              | Section                                                            |
| ----------------------------------------------------- | ------------------------------------------------------------------ |
| `--server`, `--token`, `--deployment`, `--kubeconfig` | [Choose a cluster](#choose-a-cluster)                              |
| `kite login`, `kite logout`, `kite whoami`            | [Sign in](#sign-in)                                                |
| `kite kubeconfig`, `kite get-token`                   | [Write a kubeconfig](#write-a-kubeconfig)                          |
| `kite status`                                         | [See what needs attention](#see-what-needs-attention)              |
| `kite access`                                         | [Ask for access](#ask-for-access)                                  |
| `kite local`                                          | [Run a local cluster](#run-a-local-cluster)                        |
| `kite signing-key`                                    | [Manage cluster signing keys](#manage-cluster-signing-keys)        |
| `kite node add`                                       | [Join a host](#join-a-host)                                        |
| `kite node update`                                    | [Update nodes](#update-nodes)                                      |
| `kite node list`                                      | [Update nodes](#update-nodes)                                      |
| `kite deploy`                                         | [Deploy a cluster](#deploy-a-cluster)                              |
| `kite deploy --host`                                  | [Deploy to your own hosts](#deploy-to-your-own-hosts)              |
| `kite nodepool connect`, `kite nodepool verify`       | [Connect a cloud account](#connect-a-cloud-account-for-node-pools) |
| `kite-agent`                                          | [Administer a Linux node](#administer-a-linux-node)                |
| `-o json`, exit codes                                 | [Output for programs](#output-for-programs)                        |

## Install

```bash
curl -fsSL https://get.runkite.io | sh
```

To install another release, or to another directory, set one of these
variables:

| Variable           | Effect                                                                  | Default        |
| ------------------ | ----------------------------------------------------------------------- | -------------- |
| `KITE_CHANNEL`     | The channel to install from: `stable` or `edge`                         | `stable`       |
| `KITE_VERSION`     | A specific release, such as `0.2175.0`, to install instead of a channel | none           |
| `KITE_INSTALL_DIR` | The directory to install `kite` to                                      | `~/.local/bin` |

`edge` is the newest release from main. `kite version` prints the CLI's release
and its commit.

## Choose a cluster

`kite login <url>` saves the cluster's address, and later commands use it.
These options override the saved cluster for one command:

| Option                                     | Effect                                                                                                                                  |
| ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
| `--server <url>` or `KITE_SERVER`          | Use this cluster instead of the saved one.                                                                                              |
| `--token <token>` or `KITE_TOKEN`          | Use this credential instead of the saved one.                                                                                           |
| `--deployment <name>` or `KITE_DEPLOYMENT` | Use the address and admin token from `~/.kite/deployments/<name>/deploy.env`, and trust the `ca.crt` in that directory if there is one. |
| `--kubeconfig <file>`                      | Use the server, token and certificate authority from the file's current context. `kite-control kubeconfig` prints such a file.          |
| `--debug` or `KITE_DEBUG`                  | Print each request and response to stderr.                                                                                              |

A command takes the cluster's address and credential from the first of these
that is set:

1. `--server` and `--token`, each for its own value.
2. `--kubeconfig`.
3. `--deployment`.
4. `KITE_DEPLOYMENT`.
5. `KITE_SERVER` and `KITE_TOKEN`.
6. The sign-in that `kite login` saved.

:::note
Pass either `--deployment` or `--kubeconfig`, not both. `kite login`,
`kite get-token` and `kite kubeconfig` ignore both of them.
:::

:::note
`kite signing-key` and `kite node update` require the admin token. Pass it
with `--token`, or pass `--deployment` or a `--kubeconfig` that contains the
admin token. For every other command, sign in with `kite login`.
:::

| Error                | Fix                                                                                               |
| -------------------- | ------------------------------------------------------------------------------------------------- |
| `no cluster is set.` | Run `kite login <url>`, or pass `--server <url>`, `--deployment <name>` or `--kubeconfig <file>`. |
| `401`                | Sign in again, or pass the admin token with `--token`.                                            |

## Sign in

| Command                                   | Result                                                                                                                    |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `kite login <url>`                        | Signs in through the browser, saves the credential, and adds a kubectl context for the cluster and selects it.            |
| `kite login <url> --age 30m`              | Sets how long the token stays valid: `900`, `30m`, `8h`.                                                                  |
| `kite login <url> --kubeconfig-file <f>`  | Adds the context to `<f>` instead of the first file in `KUBECONFIG`, or `~/.kube/config`.                                 |
| `kite login <url> --no-kubeconfig`        | Changes no kubeconfig.                                                                                                    |
| `kite login <url> --ca-hash sha256:<hex>` | Trusts the cluster's own certificate authority when its SHA-256 matches. `kite deploy --host` prints the command.         |
| `kite logout [<url>]`                     | Revokes the credential if the provider allows it, deletes it from this machine, and removes the context that login added. |
| `kite logout [<url>] --keep-kubeconfig`   | Leaves the context in the kubeconfig.                                                                                     |
| `kite whoami`                             | Prints the username and groups that the cluster passes to RBAC, and a binding to send an admin if you have no access yet. |

A cluster deployed with `kite deploy --host` has its own certificate
authority, which `kite login` does not trust without `--ca-hash`. With the
hash, `kite login` reads the authority from the cluster's TLS handshake,
refuses it unless its hash matches, and saves it with your sign-in. The
kubeconfig context trusts it too.

`kite login` and `kite whoami` say that you have no access when you may do
nothing in the `default` namespace or across the cluster. A role bound in
another namespace alone still counts as no access.

`--age` applies only to a cluster behind Cloudflare Access. There a token stays
valid for an hour unless you set `--age`, and for 12 hours at most. With an
OIDC provider, the provider sets how long its
tokens stay valid, so `kite login` ignores `--age`. See
[Sign in to a cluster](/docs/sign-in/).

## Write a kubeconfig

`kite login` adds the cluster's context to your kubeconfig. To manage your
kubeconfig files yourself, sign in with `--no-kubeconfig` and use
`kite kubeconfig`, which prints a kubeconfig for the saved cluster. Save it to
its own file, and add that file to `KUBECONFIG`. `--name` sets the name of the cluster
and of the context. By default, that name is the cluster's host and port. The
kubeconfig runs `kite get-token` to get a credential. `kite get-token` renews
the credential and never opens a browser.

:::caution
Do not append the output to another kubeconfig file, because the combined
file loses the entries of one of the two.
:::

## See what needs attention

`kite status` prints the cluster's nodes, its agent rollout and its pods, then
each item that needs attention, with the command that fixes it:

```text
Nodes          2 of 3 ready, 1 agent behind
Agent rollout  paused: the update of node-7 failed, automatic
Pods           5 running, 1 pending, 1 failed

2 items need attention:

OBJECT            REASON          AGE  FIX
Node/node-7       UpdateFailed    2h   kite node update node-7
Ingress/shop/web  NoIngressClass  -    kubectl get ingressclass, then set spec.ingressClassName to one of them
```

It reads the cluster's ClusterSummary, so it needs the ClusterRole
`kite:summary-reader`, which `cluster-admin` includes. Each item lasts as long
as its problem does, not the hour that an Event lasts. `-o json` prints the
whole summary, each item's message included. See
[Read the cluster summary](/docs/reference/resources/#read-the-cluster-summary)
for every reason and its fix.

## Ask for access

| Command                                                                         | Result                                                                                                           |
| ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| `kite access request --role <clusterrole> [--namespace <ns>] [--reason <text>]` | Asks for a ClusterRole in one namespace, or across the cluster with no `--namespace`. Prints the request's name. |
| `kite access show <request>`                                                    | Shows a request, and whether it was decided and by whom.                                                         |
| `kite access list`                                                              | Lists every request, pending ones first. Takes an approver's access.                                             |
| `kite access approve <request>`                                                 | Creates the binding the request asks for, with your own access, then records the approval.                       |
| `kite access decline <request>`                                                 | Records that the request is declined.                                                                            |

Anyone signed in may make a request and read it back by name. See
[Ask for access with a request](/docs/sign-in/#ask-for-access-with-a-request).

## Run a local cluster

`kite local` runs a cluster in Docker on your workstation. Docker must be
running. The [quickstart](/docs/quickstart/) walks through it.

| Command                             | Result                                                                                                                                                                                                              |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `kite local up`                     | Starts the control plane and one node, and writes `~/.kite/local/kubeconfig`.                                                                                                                                       |
| `kite local up --nodes <n>`         | Runs `n` nodes. An `n` smaller than the number of nodes does not remove any.                                                                                                                                        |
| `kite local up --port <port>`       | Publishes the control plane on this port when `up` creates it. The default is `6443`, and `0` picks a free port. A control plane that `up` replaces keeps its port, and `up` refuses a `--port` that names another. |
| `kite local up --release <version>` | Runs a specific release, such as `0.2162.0`, instead of the CLI's own.                                                                                                                                              |
| `kite local up --update-kubeconfig` | Adds a `kite-local` context to your default kubeconfig and selects it.                                                                                                                                              |
| `kite local up --oidc <file>`       | Trusts the OIDC issuer that the file sets. See [OIDC issuer](#oidc-issuer).                                                                                                                                         |
| `kite local status`                 | Shows the control plane's address and release, and whether each node is `Ready`.                                                                                                                                    |
| `kite local logs [control\|node-N]` | Prints the control plane's log, or the node's install log, which `up` keeps off the terminal, and its agent's journal.                                                                                              |
| `kite local load <image>...`        | Copies images from your local Docker into every node, so pods can use them without a registry.                                                                                                                      |
| `kite local down`                   | Stops the control plane and the nodes, and keeps their state.                                                                                                                                                       |
| `kite local delete`                 | Removes the containers, their volumes, and `~/.kite/local`.                                                                                                                                                         |

:::note
On a cluster that runs another release, `up --release` moves the control plane
and every node to the release, and keeps their state. It returns once every
node is `Ready` on the release's agent.
:::

You can run `up` again at any time. It starts what is stopped and joins the
nodes that are missing.

| File                        | Contents                                                                                         |
| --------------------------- | ------------------------------------------------------------------------------------------------ |
| `~/.kite/local/kubeconfig`  | The kubeconfig that `up` writes. It trusts `ca.crt`, so clients that check certificates connect. |
| `~/.kite/local/secrets.env` | The cluster's tokens.                                                                            |
| `~/.kite/local/ca.crt`      | The certificate authority that signs the cluster's certificate.                                  |

To pull Kite's images from another registry, set `KITE_REGISTRY`, and copy each
image there with all of its platforms, because `up` pulls each image by the
digest in the release's signed manifest.

:::tip
A pod refers to a loaded image by the name you built it with, such as
`app:dev`. Tag the image with something other than `latest`, or set
`imagePullPolicy: IfNotPresent`, because otherwise the node tries to pull it
from a registry. Run `load` again after each build, and after `up` adds a
node.
:::

### Named clusters

Add `--name <name>` to any `kite local` command to work with a separate
cluster. Each named cluster has its own:

- containers, network and volumes, named `kite-local.<name>.*`
- kubeconfig context, `kite-local.<name>`
- state, in `~/.kite/local.<name>`

A name is up to 40 characters long and uses lowercase letters, digits and `-`.
It starts with a letter and ends with a letter or a digit.

For a test suite that starts its own cluster, use a unique name and `--port 0`,
so that runs don't collide with your cluster or with each other:

```sh
kite local up --name test-1 --port 0
kite local load --name test-1 app:dev

kite local delete --name test-1
```

### OIDC issuer

`--oidc <file>` makes the cluster accept tokens that an OIDC issuer signs. The
file contains `KITE_OIDC_` lines, as `deploy.env` does:

```sh
KITE_OIDC_ISSUER=https://issuer.example.com
KITE_OIDC_AUDIENCE=https://127.0.0.1:7443
KITE_OIDC_USERNAME_CLAIM=sub
KITE_OIDC_PREFIX=app:
KITE_OIDC_JWKS={"keys":[{"kty":"EC","crv":"P-256","alg":"ES256","x":"…","y":"…"}]}
```

```sh
kite local up --port 7443 --oidc oidc.env
```

```text
==> fetching release 0.4208.0
==> replacing the control plane to apply the OIDC settings
==> waiting for the control plane on https://127.0.0.1:7443
==> waiting for the nodes to report Ready
```

The file must set `KITE_OIDC_ISSUER` and `KITE_OIDC_AUDIENCE`, and `up` refuses
any name that is not an OIDC setting. With `KITE_OIDC_JWKS`, the cluster checks
each token against those keys and fetches nothing from the issuer. An empty
value is set, so `KITE_OIDC_PREFIX=` gives usernames with no prefix.
[Identity and access](/docs/identity/#usernames-and-groups) lists the other
settings.

The cluster keeps the settings in `~/.kite/local/oidc.env`, so a later `up`
without `--oidc` keeps them, and so does a move to another release. When the
settings change, `up` replaces the control plane and keeps the cluster's state.
To remove the settings, pass an empty file.

`up` publishes a control plane that it replaces on `--port`, or on a new free
port with `--port 0`. If `KITE_OIDC_AUDIENCE` contains the cluster's address,
choose a port and pass the same `--port` each time.

## Manage cluster signing keys

These commands require the admin token. Pass it with `--token` or
`KITE_TOKEN`.

| Command                                 | Result                                                                                                           |
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| `kite signing-key list`                 | Prints the active and retained public keys.                                                                      |
| `kite signing-key rotate`               | Replaces the active signing key. Each node connects again for a credential that the new key signs.               |
| `kite signing-key retire <kid>`         | Removes the public key with this key ID. Refuses the active key, and a key that still signs a node's credential. |
| `kite signing-key retire <kid> --force` | Removes the key at once, as for a key that leaked. Each node whose credential it signs must join again.          |

See [Rotate the signing key](/docs/configure/#rotate-the-signing-key).

## Join a host

`kite node add <target>` installs the agent on a host, joins the host to the
cluster, and waits for the node to be `Ready`. The host must be able to open
outbound HTTPS connections to the cluster. You need permission to create
Secrets in `kube-system`.

| Target                     | How `kite` connects                                                                                            |
| -------------------------- | -------------------------------------------------------------------------------------------------------------- |
| A running Docker container | `docker exec` as root                                                                                          |
| A Lima VM                  | `limactl shell` with `sudo`                                                                                    |
| `user@host`                | `ssh`. As `root@host` it runs the script directly. As any other user it runs the script with `sudo -n`.        |
| `--via "<command>"`        | Your command. It must read a script on stdin and run it as root, such as `gcloud compute ssh vm -- sudo bash`. |
| None                       | Prints the lines to run on the host                                                                            |

| Option              | Effect                                                                                                                                                                                | Default         |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
| `--name <node>`     | The node's name.                                                                                                                                                                      | the host's name |
| `--address <url>`   | The address the host uses to connect to the cluster.                                                                                                                                  |                 |
| `--ttl <duration>`  | How long the token stays valid: `30m`, `1h`, `2d`.                                                                                                                                    | `1h`            |
| `--uses <n>`        | How many hosts can join with the token.                                                                                                                                               | `1`             |
| `--wait <duration>` | How long to wait for `Ready`. `0s` returns once the host joins.                                                                                                                       | `5m`            |
| `--runtime <name>`  | A sandboxed runtime to install, `gvisor` or `kata`. The node gets the label `runtime.kiteplane.dev/<name>=true`. Repeat the option for more than one. Requires a `--wait` above `0s`. |                 |
| `--skip-checks`     | Installs even if the host fails its checks: the OS, CPU, nftables, memory, and whether it reaches the cluster.                                                                        |                 |

:::caution
With no target, the printed lines put the token on the host's command line.
Run them only on a host that no other user can log in to.
:::

For a cluster on your workstation, `kite node add` tells a container to
connect to `host.docker.internal`, and a Lima VM to connect to
`host.lima.internal`, on the cluster's port.

## Update nodes

`kite node update` updates nodes to the agent that the cluster serves. It
requires the admin token, except with `--host` or `--via`.

| Command                                   | Result                                                                                                                                                                |
| ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `kite node list`                          | Shows each node: whether it is `Ready` and since when, the agent it runs, the agent the cluster serves, and the pool that added it, or `-` for a host someone joined. |
| `kite node drain <node>`                  | Marks the node unschedulable and evicts each of its pods but a DaemonSet's, through the eviction API. `--timeout` sets how long it waits for them, 5m by default.     |
| `kite node remove <node> --host <target>` | Drains the node, runs `kite-agent leave` on its host, and deletes the Node. `--via "<command>"` reaches the host as for `node add`.                                   |
| `kite node remove <node> --gone`          | For a host that no longer exists: deletes its pods at once and the Node, without a drain.                                                                             |
| `kite node update`                        | Shows whether automatic updates are on, the agent that the cluster serves, any update in progress, and each node that is behind, with its reason and what to run.     |
| `kite node update <node>...`              | Updates each node in turn and waits for it to be `Ready`.                                                                                                             |
| `kite node update --all`                  | Updates every node that runs an older agent, one at a time.                                                                                                           |
| `kite node update --automatic on\|off`    | Turns automatic updates on or off.                                                                                                                                    |
| `kite node update --host <target>...`     | Runs the update on each host. It connects to a host the same way `node add` does.                                                                                     |
| `kite node update --via "<command>"`      | The same, through a command that runs a script as root.                                                                                                               |

| Option                 | Effect                                                    | Default |
| ---------------------- | --------------------------------------------------------- | ------- |
| `--no-wait`            | Return once the cluster accepts the request.              |         |
| `--timeout <duration>` | How long to wait.                                         | `30m`   |
| `--keep-going`         | With `--host`, continue to the next host after a failure. |         |

[Upgrade a node](/docs/manage-nodes/#upgrade-a-node) says when to run the update on the
host.

## Deploy a cluster

`kite deploy` deploys a cluster to your Cloudflare account. With `--host`, it
deploys to your own servers instead, as
[Deploy to your own hosts](#deploy-to-your-own-hosts) describes. By default, it
deploys the same release as the CLI.
[Configure a deployment](/docs/configure/) explains each setting.

The deployment's name is the value of `--name`, or else `KITE_WORKER`, or
else `kite-control`. Its settings are in
`~/.kite/deployments/<name>/deploy.env`, and each deploy writes a kubeconfig to
the same directory.

| Command                        | Result                                                                                                                                                                                            |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `kite deploy init`             | Asks for the address, sign-in, admin and fixed settings, writes `deploy.env`, creates credentials, and deploys after one confirmation.                                                            |
| `kite deploy`                  | Shows the plan and asks you to approve it. Then it creates everything and runs `bind`.                                                                                                            |
| `kite deploy credentials`      | Creates the deploy token, and the R2 key and bucket for an audit log.                                                                                                                             |
| `kite deploy control`          | Uploads the control plane, and routes the hostname or the `workers.dev` address to it.                                                                                                            |
| `kite deploy secrets`          | Sets the credentials as secrets on the Worker.                                                                                                                                                    |
| `kite deploy dns`              | Creates the proxied DNS record for `KITE_HOSTNAME`.                                                                                                                                               |
| `kite deploy access`           | Puts Cloudflare Access in front of the sign-in paths.                                                                                                                                             |
| `kite deploy audit`            | Creates the Logpush job for the audit log.                                                                                                                                                        |
| `kite deploy bind`             | Binds each email in `KITE_ACCESS_ALLOW` to `KITE_ACCESS_ROLE`, and `KITE_ADMIN_GROUP` to `cluster-admin`.                                                                                         |
| `kite deploy wait`             | Waits until the control plane serves the agent of its release.                                                                                                                                    |
| `kite deploy destroy`          | Deletes the NodePools and their machines, then the Worker, its Durable Objects and the audit job. Deletes the tokens if the deploy token can manage API tokens.                                   |
| `kite deploy move --to <name>` | Moves the cluster to the deployment `<name>` through the cluster's copy. The target is on Cloudflare, or on a server with `--host`. Between Workers, it routes `KITE_HOSTNAME` to the new Worker. |

:::danger
`kite deploy destroy` deletes the cluster's Durable Objects and the state in
them. It asks you to type the deployment's name first, unless you pass
`--yes`.
:::

| Option                                      | Effect                                                                                                                                                     |
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--dry-run`, `-n`                           | Show what would change, and change nothing.                                                                                                                |
| `--yes`, `-y`                               | Make the changes without asking.                                                                                                                           |
| `--update-kubeconfig`                       | Also add the cluster's context to your default kubeconfig, and select it.                                                                                  |
| `--channel <name>` or `--release <version>` | Deploy a release other than the CLI's own: the release on a channel, `stable` or `edge`, or a specific version.                                            |
| `--source <dir>`                            | Build the Kite checkout at `<dir>` and deploy it. For a deploy to hosts, Kite copies the build to each host over its connection. Requires `docker buildx`. |
| `--bucket`                                  | With `destroy`, also delete the audit bucket.                                                                                                              |
| `--keep-machines`                           | With `destroy`, leave the NodePools and their machines running. Nothing deletes the machines afterwards.                                                   |

[Cloudflare tokens](/docs/configure/#cloudflare-tokens) says which tokens a deploy
uses and how to create them.

### Deploy to your own hosts

`kite deploy --host <target>` installs kite-control on a Linux host with
systemd, and serves the cluster from that host. kite-control runs the whole
control plane as one process. It can also run as a Raft group of 3 or 5
servers, which `kite deploy` does not set up.
[Deploy to your own servers](/docs/deploy-servers/) walks through it. The
target is a running Docker container, a Lima VM, or an ssh destination, as for `kite node add`. `--via "<command>"` connects to a host
through your command, which must read a script on stdin and run it as root.

| Command                       | Result                                                                                                         |
| ----------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `kite deploy --host <target>` | Installs kite-control, and writes a kubeconfig that trusts the cluster's own certificate authority.            |
| `kite deploy`                 | Installs the release on every host. The host that serves the cluster is last.                                  |
| `kite deploy wait`            | Shows which host serves the cluster.                                                                           |
| `kite deploy destroy`         | Removes kite-control and the cluster's data from every host. Keeps the database or the copy, and `deploy.env`. |

`--address` or `KITE_ADDRESS` sets the address that clients and nodes use,
`https://<name>[:<port>]`, and kite-control listens on its port. The default is
the ssh target's host, on port 443.

When neither `KITE_DATABASE` nor `KITE_COPY` is set, `kite deploy destroy`
first deletes the NodePools and their machines, as it does on Cloudflare.

To add a standby, run `kite deploy --host` again with another host. All hosts
use the same settings, and a second host requires `KITE_DATABASE` or
`KITE_COPY`. Point `--address` at a name that sends connections to every host,
such as a load balancer's. A serving host that cannot renew its lease for the
whole length of a lease stops, so that it never serves at the same time as the
standby that takes over.
[Add a second server](/docs/deploy-servers/#add-a-second-server) says how
the hosts share the lease and when a standby takes over.

#### Shared state

| Setting                                                  | Meaning                                                                                                          | Default |
| -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ------- |
| `KITE_DATABASE`                                          | The Postgres database that keeps the cluster, `postgres://<user>@<host>/<database>`. Its lease lasts 15 seconds. | none    |
| `KITE_DATABASE_PASSWORD`                                 | The database's password. `KITE_DATABASE` cannot contain it.                                                      | none    |
| `KITE_COPY`                                              | The S3 or R2 bucket that keeps a copy of the cluster, `s3://<bucket>/<prefix>`.                                  | none    |
| `KITE_COPY_ACCESS_KEY_ID`, `KITE_COPY_SECRET_ACCESS_KEY` | The access key that writes the copy.                                                                             | none    |
| `KITE_COPY_REGION`, `KITE_COPY_ENDPOINT_URL`             | The bucket's region, and its endpoint for R2 or another S3 service.                                              | none    |
| `KITE_COPY_LEASE`                                        | Seconds a standby waits after the serving host stops renewing the lease. At least `3`.                           | `30`    |
| `KITE_COPY_SYNC`                                         | `1` acknowledges a write only once the copy contains it.                                                         | off     |
| `KITE_COPY_SPACING_MS`                                   | Milliseconds between the starts of two uploads. At least `100`. Longer sends fewer billed requests.              | `250`   |

[Control plane costs](/docs/cost/#self-hosted) gives what the lease and the uploads
cost on S3 and R2.

#### Snapshots

| Setting                                                                                            | Meaning                                                                               |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| `KITE_SNAPSHOTS`                                                                                   | The S3 or R2 bucket that nodes upload sandbox snapshots to, `s3://<bucket>/<prefix>`. |
| `KITE_SNAPSHOTS_ACCESS_KEY_ID`, `KITE_SNAPSHOTS_SECRET_ACCESS_KEY`, `KITE_SNAPSHOTS_SESSION_TOKEN` | The access key that signs snapshot URLs, and lists and deletes snapshots.             |
| `KITE_SNAPSHOTS_REGION`, `KITE_SNAPSHOTS_ENDPOINT_URL`                                             | The bucket's region, and its endpoint for R2 or another S3 service.                   |

#### Join a node to your own hosts

To join a node, run `kite node add --deployment <name> <target>`. The command
and the node both trust the cluster's own certificate authority. If you
installed the control plane on the server with
`curl -fsSL https://get.runkite.io/control | sh`, save the file that
`kite-control kubeconfig` prints and pass it with `--kubeconfig` instead. To
set that control plane's address, set `KITE_ADDRESS` before `sh`. It works as `--address` does for `kite deploy`.

## Connect a cloud account for node pools

| Command                                    | Result                                                                                                                            |
| ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
| `kite nodepool connect gcp --project <id>` | Prints the `gcloud` commands that connect a Google Cloud project.                                                                 |
| `kite nodepool connect aws`                | Prints the `aws` commands that connect an AWS account.                                                                            |
| `kite nodepool connect digitalocean`       | Prints the token scopes and Kubernetes steps for DigitalOcean.                                                                    |
| `kite nodepool verify <nodeclass>`         | Tests the cloud credential and reports the first failed check. Needs `get` on the NodeClass and `create` on `nodeclasses/verify`. |

`connect` prints commands and runs none of them. Every `connect` form takes
`--cluster <name>`, the cluster name. The cloud resources carry it as a label,
so deployments that share an account keep their resources apart.

:::note
`connect gcp` and `connect aws` read the cluster name from the cluster, and
refuse a `--cluster` or `KITE_CLUSTER` that differs from it, so leave both
out. When the cluster reports no name, and always for `connect digitalocean`,
which does not contact the cluster, the name is `--cluster`, then
`KITE_CLUSTER`, then `kite`.
:::

### GCP

| `kite nodepool connect gcp` option | Default         |
| ---------------------------------- | --------------- |
| `--project <id>`                   | none, required  |
| `--zone <zone>`                    | `us-central1-a` |
| `--pool <id>`                      | `kite`          |
| `--provider-id <id>`               | `kite`          |
| `--service-account <name>`         | `kite-node`     |

### AWS

| `kite nodepool connect aws` option | Default         |
| ---------------------------------- | --------------- |
| `--region <region>`                | `us-east-1`     |
| `--role <name>`                    | `kite-nodepool` |
| `--instance-profile <name>`        | `kite-node`     |
| `--class <name>`                   | `ec2`           |

### DigitalOcean

| `kite nodepool connect digitalocean` option | Default        |
| ------------------------------------------- | -------------- |
| `--region <slug>`                           | `nyc3`         |
| `--secret <name>`                           | `digitalocean` |
| `--namespace <namespace>`                   | `kube-system`  |
| `--class <name>`                            | `droplet`      |

See the [node pools guide](/docs/set-up-node-pools/).

## Administer a Linux node

Run these on the host, with `sudo`. See [Manage nodes](/docs/manage-nodes/).

| Command                                                                 | Result                                                                                             |
| ----------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `kite-agent join --cluster <wss-url>/connect --token <bootstrap-token>` | Joins the host to a cluster and starts the agent.                                                  |
| `kite-agent update`                                                     | Downloads the agent that the cluster serves, and restarts the service if it changed.               |
| `kite-agent status`                                                     | Shows the node, the cluster, whether the host can reach it, the agent's state, and its version.    |
| `kite-agent logs [n] [--no-follow]`                                     | Prints the journal's last `n` lines, 50 by default, then follows it unless you pass `--no-follow`. |
| `kite-agent stop` / `kite-agent start`                                  | Stops or starts the agent. The host stays joined to its cluster.                                   |
| `kite-agent leave`                                                      | Stops and disables the agent, and removes the host's enrollment.                                   |

| `kite-agent join` option                                                                                   | Effect                                                                                                                   | Default                |
| ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ---------------------- |
| `--cluster <wss-url>/connect`                                                                              | The cluster to join: a `wss://` URL whose path ends in `/connect`. `ws://` works only for a cluster on the same machine. | none, required         |
| `--token <token>`                                                                                          | The bootstrap token.                                                                                                     | `KITE_BOOTSTRAP_TOKEN` |
| `--name <node>`                                                                                            | The Kubernetes Node name.                                                                                                | the host's name        |
| `--machine`, `--driver`, `--host <name>`                                                                   | Labels that record where the host came from, for the system that creates hosts.                                          | none                   |
| `--register-with-taints <key=value:effect,...>`                                                            | Taints the node has when it first registers.                                                                             | none                   |
| `--max-pods <n>`                                                                                           | How many pods the node accepts.                                                                                          | the cluster's default  |
| `--kube-reserved <cpu=100m,memory=256Mi>`                                                                  | The CPU, memory or ephemeral storage that the node keeps out of its allocatable.                                         | the cluster's default  |
| `--shutdown-grace-period`, `--shutdown-grace-period-critical-pods`                                         | See [Machine shutdown](/docs/reference/node-agent/#machine-shutdown).                                                    | see that table         |
| `--network-endpoint`, `--network-public-endpoint`, `--network-port`, `--network-mtu`, `--network-key-file` | See [WireGuard settings](/docs/reference/node-agent/#wireguard-settings).                                                | see that table         |

To point a joined host at a new cluster address, run
`kite-agent join --cluster <wss-url>/connect --token <bootstrap-token>` with a
new token. The saved token is for the address the host joined, so the agent
never sends it to another one. The agent keeps its other settings:

| Setting                                               | Kept when                                           |
| ----------------------------------------------------- | --------------------------------------------------- |
| `--network-key-file`                                  | The cluster address and the node name stay the same |
| `NODE_EXTRA_CA_CERTS`, `NODE_TLS_REJECT_UNAUTHORIZED` | The cluster address stays the same                  |
| Every other setting                                   | Always                                              |

For a new address that needs `NODE_EXTRA_CA_CERTS` or
`NODE_TLS_REJECT_UNAUTHORIZED`, set them again in the join's environment.

If a join fails, run `kite-agent status` to check whether the host can reach
the cluster's address, then read `kite-agent logs`.

## Output for programs

`-o json`, or `--output json`, prints a command's result as one JSON document
on stdout. Progress and warnings stay on stderr. These commands print JSON:
`kite version`, `kite whoami`, `kite status`, `kite access`, `kite signing-key`
and `kite local status`.
Another command refuses `-o json` with a usage error.

```bash
kite local status -o json
```

```json
{
  "apiVersion": "cli.kiteplane.dev/v1alpha1",
  "control": {
    "address": null,
    "container": "exited",
    "image": "registry.bayview.dev/apps/kite/local-control:f66dc87a63a860e8431d009b66188d96e2fa1f5f",
    "release": "0.4248.0"
  },
  "exists": true,
  "kind": "LocalCluster",
  "kubeconfig": "/Users/you/.kite/local/kubeconfig",
  "name": "kite-local",
  "nodes": [{ "container": "exited", "name": "node-1", "ready": "Unknown" }]
}
```

With `-o json`, a failure prints an error document on stderr:

```json
{
  "apiVersion": "cli.kiteplane.dev/v1alpha1",
  "error": {
    "code": "UsageError",
    "message": "kite node add does not print JSON yet. Run it without -o json."
  },
  "kind": "Error"
}
```

A change that removes or renames a field changes `apiVersion`.

| Exit code | Meaning                                 | `error.code`   |
| --------- | --------------------------------------- | -------------- |
| 0         | The command succeeded.                  |                |
| 1         | The command failed.                     | `Failed`       |
| 2         | The command line is wrong.              | `UsageError`   |
| 3         | A check failed before anything changed. | `CheckFailed`  |
| 4         | You are not signed in, or not allowed.  | `Unauthorized` |
| 5         | A wait ran out of time.                 | `TimedOut`     |

## Next

- [Configure a deployment](/docs/configure/)
- [Manage nodes](/docs/manage-nodes/)
- [Sign in to a cluster](/docs/sign-in/)
