# Manage nodes

A host opens a connection out to the control plane, so it needs no inbound
route. To have Kite create machines in GCP, AWS or DigitalOcean instead, see
[Set up a node pool](/docs/set-up-node-pools/).

## What you need

- The `kite` CLI. See [Install the CLI](/docs/quickstart/#install-the-cli).
- The cluster's admin token, or a `kite login` account that can create Secrets
  in `kube-system`.
- A Linux host, amd64 or arm64, with at least 512 MiB of memory. Pods can
  request all but 100m of CPU and 256Mi of memory. See
  [Reserve CPU and memory for the host](#reserve-cpu-and-memory-for-the-host).
- A root shell on the host, with systemd and apt.
- nftables 1.0.9 or later, as in Ubuntu 24.04 and Debian 13.

| Access                                                         | Direction               | For                                                                                                                                   |
| -------------------------------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| TCP 443 to the cluster                                         | Outbound                | The node's connection to the control plane                                                                                            |
| Your image registries, and containerd's sandbox image registry | Outbound                | Image pulls                                                                                                                           |
| UDP 51820                                                      | Open to the other nodes | Pods that connect to pods on those nodes. See [Pod ranges and peer reachability](/docs/networking/#pod-ranges-and-peer-reachability). |

For hosts in different networks or clouds, the cluster must allow public
endpoints, with `KITE_NETWORK_PUBLIC_ENDPOINTS=Allowed`. It is off by default.
See [Join nodes in different networks](/docs/configure/#join-nodes-in-different-networks).

Run one agent per host, because two agents on one host overwrite each other's
network configuration.

Debian 12 does not work: its nftables 1.0.6 refuses the rules that bind each
pod to its addresses, so the node does not become Ready.

:::note[A host without apt]
First install containerd, the CNI plugins `bridge`, `host-local`, `portmap`
and `loopback`, and the tools `ip`, `nft`, `wg`, `conntrack` and `modprobe`.
A kernel without WireGuard works too. See
[Kernels without WireGuard](/docs/reference/node-agent/#kernels-without-wireguard).
:::

## Join an existing host

:::caution[Adding a node can replace your containerd config]
`kite node add` requires `SystemdCgroup = true` in the runc options of
`/etc/containerd/config.toml`. If the file does not set it, `kite node add`
replaces the whole file with containerd's default config, sets it, and restarts
containerd. It keeps your file as `/etc/containerd/config.toml.kite-backup`,
and says so. A later run keeps that first copy.
:::

Before it installs anything, `kite node add` checks the host: its OS, CPU,
nftables, memory, and whether it reaches the cluster. A host that fails a check
gets nothing installed, and the command prints each failure with its fix and
deletes the join token it made. `--skip-checks` installs anyway. The check does
not test UDP 51820 between nodes, because a WireGuard port that drops packets
looks the same as one that is open; see [Configure WireGuard
transport](#configure-wireguard-transport).

```text
checking the host through ssh root@node-1
  FAIL  os         Debian GNU/Linux 12 (bookworm). Kite supports Ubuntu 24.04 and Debian 13, whose nftables it needs: use one of them.
  ok    cpu        x86_64
  ok    nftables   not installed: the install adds the distribution's
  ok    memory     3916 MiB
  ok    cluster    https://kite.example.com/healthz
kite: the host failed 1 check, so nothing was installed. Fix it, or pass --skip-checks to install anyway.
```

If the install fails, the command prints the last 20 lines the host printed.

Add the host. For a cluster that you deployed from this workstation,
`--deployment` reads the cluster's address and admin token from the
deployment's settings file:

```bash
kite node add --deployment kite-control root@node-1
```

For a self-hosted control plane, pass the kubeconfig that
`sudo kite-control kubeconfig` prints on its server instead:

```bash
kite node add --kubeconfig kite.yaml root@node-1
```

If you signed in with `kite login <url>`, leave out `--deployment`. The command
installs the agent and joins the host with a token that expires in an hour. It
prints each install step, and ends with the node's name once the node is
`Ready`:

```text
joined wss://kite.example.com/connect as node-1
bootstrapped node-1. Update this host with 'kite-agent update' from now on.
kite-node-name=node-1
waiting for node-1 to report Ready
node-1
```

:::note

- The join suggests `kite-agent update`, but update a node through the
  cluster's rollout instead, as [Upgrade a node](#upgrade-a-node) shows. Run
  `kite-agent update` only on a host that the rollout cannot update, as
  [Update a node from the host](#update-a-node-from-the-host) says.
- A self-hosted control plane signs its certificate with its own certificate
  authority. With `--deployment` or `--kubeconfig`, `kite node add` trusts that
  authority. The host keeps a copy of the authority's certificate at
  `/etc/kite/ca.pem`, and the agent checks the cluster's certificate against it.
  :::

If another tool gives you a root shell on the host, pass it with `--via`:

```bash
kite node add --via "gcloud compute ssh node-1 -- sudo bash"
```

[Join a host](/docs/reference/cli/#join-a-host) lists every target and option.

:::caution
`kite node add` with no target prints two commands that put the token on the
host's command line. Run them only on a host that nobody else can log in to.
:::

## Join from the host

To join a host from a root shell on the host instead of from your workstation,
run `kite-agent join` there, as
[Administer a Linux node](/docs/reference/cli/#administer-a-linux-node) shows. Before you do,
set two values in `/etc/containerd/config.toml` yourself, then restart
containerd:

- `SystemdCgroup = true` in the runc options. Without it, the agent logs
  `cannot run pods` and exits, because no pod's limits would apply. On
  containerd 1.7, which does not report its cgroup driver, the agent reads
  the setting from `containerd config dump`.
- `use_local_image_pull = true`. Without it, containerd does not use the
  agent's [registry mirror](/docs/reference/node-agent/#registry-mirror), and pulls
  images directly from the registry. `kite node add` sets this value when the
  file sets it to `false`.

## Check a joined host

On the host, run:

```bash
sudo kite-agent status
sudo kite-agent logs
```

A joined host with a running agent prints:

```text
node      node-1
cluster   wss://kite.example.com/connect
reachable yes
machine
driver
host
taints
max-pods
kube-reserved
network-endpoint
network-public-endpoint
network-port
network-mtu
agent     active
version   07eb81443336
```

Each field from `machine` to `network-mtu` shows the value that the join wrote
to `/etc/kite/node.env`. A field is empty when the join set no value. `version`
is the agent build.

| What you see                                    | What to do                                               |
| ----------------------------------------------- | -------------------------------------------------------- |
| `not joined`                                    | Run `kite node add` for the host again.                  |
| The agent is inactive                           | Run `sudo kite-agent start`, then read the logs.         |
| The cluster address does not resolve or respond | Fix the join URL, or restore the host's outbound access. |
| The node is Ready but a pod does not run        | See [Troubleshoot](/docs/troubleshoot/).                 |

## Reserve CPU and memory for the host

A node reserves 100m of CPU and 256Mi of memory for the agent, containerd and
the host's own processes. See
[Capacity and allocatable](/docs/nodes/#capacity-and-allocatable).

On a host that you joined with `kite node add` or `kite-agent join`, run
`kite-agent join` again on the host with `--kube-reserved`, which uses kubelet's
syntax. The agent restarts and keeps its other settings:

```bash
sudo kite-agent join --cluster <wss-url>/connect --kube-reserved cpu=100m,memory=512Mi
```

On the nodes of a pool, set `spec.template.kubeReserved` on the
[NodePool](/docs/reference/node-pools/#nodepool). It applies to the nodes that the
pool creates after you set it, and overrides `--kube-reserved`:

```yaml
spec:
  template:
    kubeReserved:
      cpu: 500m
      memory: 2Gi
```

:::caution
The default reservation does not cover the host's operating system, which can
use several hundred MiB on its own. On a machine with 1 GiB of memory or less,
reserve what the host's processes use, or run an operating system image without
those processes.
:::

## Configure WireGuard transport

Pass the network options in
[WireGuard settings](/docs/reference/node-agent/#wireguard-settings) to
`kite-agent join`, or set them in `/etc/kite/node.env`. Restart the agent after
you change the endpoint, the MTU or the private key. Do not share a key path
between clusters or nodes.

## Upgrade a node

[Upgrade the control plane](/docs/configure/#upgrade-a-cluster) first. Then, with the
cluster's admin token, run:

```bash
kite node update --all
```

The cluster updates each node that runs an older agent, one node at a time. To
update only the nodes you choose, pass their names instead of `--all`. To see
which nodes are behind first, run `kite node update` with no node. It lists
each node that runs another agent or settings, with the reason from its
`AgentUpdate` condition, and says which node a paused rollout waits on.
`kubectl get nodes -o wide` shows each node's `Agent`, `Desired` and `Update`
columns.

Automatic updates are off by default. Turn them on with
`kite node update --automatic on`.

### Update a node from the host

The cluster cannot update an agent that logs `rejected by control plane` with
the reason `protocol version <n>, expected <m>`. Update it over SSH instead:

```bash
kite node update --host root@node-1 --host root@node-2
```

Or run `sudo kite-agent update` on the host.

### If an update fails

If a node is not `Ready` again within ten minutes, the rollout pauses. Read
`sudo kite-agent logs` on the host, fix the cause, then run
`kite node update <node>` to resume the rollout.

## Leave and remove a node

:::caution
A persistent volume can keep its data on the node that you remove. First check
every workload that uses one. See [Storage](/docs/storage/).
:::

Remove the node with its host's target, the same one that `kite node add`
took:

```bash
kite node remove node-1 --host root@node-1
```

It drains the node, then runs `kite-agent leave` on the host, which stops the
agent and deletes its node credential, and then deletes the Node. A host that
still ran the agent would register itself again.

The drain marks the node unschedulable and evicts each of its pods through the
eviction API, as `kubectl drain` does, so a PodDisruptionBudget is honoured.
It keeps a DaemonSet's pods. It waits up to `--timeout`, 5 minutes by default,
for the pods to go. To drain a node without removing it, run
`kite node drain node-1`.

For a host that no longer exists, pass `--gone` instead of `--host`. It
deletes the node's pods at once, without the drain, and then the Node:

```bash
kite node remove node-1 --gone
```

Without `kite`, run `sudo kite-agent leave` on the host, then
`kubectl delete node node-1`. The cluster evicts the node's pods about 60
seconds after the agent stops. See
[When a node disconnects](/docs/nodes/#when-a-node-disconnects).

## Next

- [Run pods in a sandbox](/docs/sandboxed-runtimes/#add-a-runtime-to-a-host-you-joined):
  install gVisor or Kata on the host and label its node.
- [Nodes](/docs/nodes/): what the agent does and what happens when a node
  disconnects.
- [Set up a node pool](/docs/set-up-node-pools/): have Kite create machines in GCP,
  AWS or DigitalOcean.
- [Send node telemetry](/docs/configure/#send-node-telemetry): post node logs and
  metrics to your collector.
- [Node agent reference](/docs/reference/node-agent/): network settings and telemetry
  fields.
