# Node pool reference

`NodeClass`, `NodePool`, and `NodeClaim` are cluster-scoped resources in `kiteplane.dev/v1alpha1`. [Node pools](/docs/node-pools/) explains how they work together.

## NodeClass

A `NodeClass` describes one provider account and the machine types that a pool may request. Set exactly one of `spec.gcp`, `spec.digitalocean` or `spec.aws`.

| Field               | Required | Meaning                                                                                                                                             |
| ------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `spec.machineTypes` | Yes      | Machine types, in order of preference.                                                                                                              |
| `spec.image`        | No       | Provider image. Defaults to Ubuntu 24.04: see each provider below.                                                                                  |
| `spec.diskGiB`      | No       | Boot-disk size in GiB. GCP and AWS.                                                                                                                 |
| `spec.runtimes`     | No       | Sandboxed runtimes each machine installs beside runc: `gvisor`, `kata`, or both. See [Run a pod in a sandboxed runtime](/docs/sandboxed-runtimes/). |

:::caution
The API accepts a class that sets more than one of `spec.gcp`, `spec.digitalocean` and `spec.aws`, but no pool that uses it creates machines.
:::

### GCP

| Field                               | Required                | Meaning                                                                                   |
| ----------------------------------- | ----------------------- | ----------------------------------------------------------------------------------------- |
| `spec.gcp.project`                  | Yes                     | Project that owns the instances.                                                          |
| `spec.gcp.zones`                    | Yes                     | Zones, in order of preference.                                                            |
| `spec.gcp.workloadIdentityProvider` | No                      | The full resource name of a workload identity pool provider. With it, Kite stores no key. |
| `spec.gcp.credentialsSecretRef`     | No                      | Secret with a service-account key under `key.json`, for use without federation.           |
| `spec.gcp.serviceAccount`           | Yes, to create machines | Service account assigned to created instances.                                            |
| `spec.gcp.network`                  | No                      | VPC network.                                                                              |
| `spec.gcp.subnetwork`               | No                      | Subnetwork.                                                                               |
| `spec.gcp.diskType`                 | No                      | Boot-disk type name, such as `pd-balanced`. Not a path or URL.                            |
| `spec.gcp.localSsdCount`            | No                      | NVMe Local SSDs for runtime and pod data, 0 to 32. Defaults to 0.                         |
| `spec.gcp.spot`                     | No                      | `true` creates Spot instances. Defaults to `false`.                                       |
| `spec.gcp.nicType`                  | No                      | `GVNIC` or `VIRTIO_NET`. C3D machine types need `GVNIC`.                                  |
| `spec.gcp.endpoints`                | No                      | Replaces the Google API base URLs.                                                        |
| `spec.gcp.identityIssuer`           | No                      | Replaces the issuer that Kite expects on an instance identity document.                   |

Without `spec.image`, Kite uses Canonical's minimal Ubuntu 24.04, `projects/ubuntu-os-cloud/global/images/family/ubuntu-minimal-2404-lts-amd64`. A class that lists an Arm machine type needs an Arm `spec.image`.

For a machine type with bundled Local SSDs, set `localSsdCount` to the bundled count. Data on [Local SSD](/docs/node-pools/#local-ssd) is lost when the machine is deleted. When the provider stops a Spot instance, it deletes the instance.

### AWS

| Field                      | Required | Meaning                                                                                                                              |
| -------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `spec.aws.region`          | Yes      | Region, such as `us-east-1`.                                                                                                         |
| `spec.aws.zones`           | Yes      | Availability zones, in order of preference.                                                                                          |
| `spec.aws.roleArn`         | Yes      | The IAM role that the control plane assumes with a token that it signs. Kite stores no access key.                                   |
| `spec.aws.instanceProfile` | Yes      | Instance profile for created instances. Its role must have the same name.                                                            |
| `spec.aws.subnets`         | No       | Subnets to launch into. Defaults to each zone's default subnet.                                                                      |
| `spec.aws.securityGroups`  | No       | Security groups. Defaults to the VPC's default group.                                                                                |
| `spec.aws.spot`            | No       | `true` creates one-time Spot instances. Defaults to `false`.                                                                         |
| `spec.aws.order`           | No       | `Listed` or `SpotPrice`, the order in which a pool tries offerings. Defaults to `Listed`. See [Spot price order](#spot-price-order). |
| `spec.aws.endpoints`       | No       | Replaces the STS, EC2 and Systems Manager base URLs.                                                                                 |

`spec.image` is an AMI ID or `resolve:ssm:<parameter>`. Without it, Kite uses the Systems Manager parameter for Canonical's minimal Ubuntu 24.04 on the machine type's architecture, `/aws/service/canonical/ubuntu/server-minimal/24.04/stable/current/<arch>/hvm/ebs-gp3/ami-id`.

`spec.diskGiB` sets the size of the root volume, which is a gp3 volume. On a machine type with an NVMe SSD instance store, the machine keeps runtime and pod data on that store instead of the root volume.

### DigitalOcean

| Field                                    | Required | Meaning                                           |
| ---------------------------------------- | -------- | ------------------------------------------------- |
| `spec.digitalocean.credentialsSecretRef` | Yes      | Secret with the DigitalOcean token under `token`. |
| `spec.digitalocean.regions`              | Yes      | Regions, in order of preference.                  |
| `spec.digitalocean.vpc`                  | No       | VPC UUID. Defaults to the region's default VPC.   |
| `spec.digitalocean.endpoint`             | No       | Replaces the DigitalOcean API base URL.           |

Without `spec.image`, Kite uses `ubuntu-24-04-x64`.

### NodeClass status

| Field                                 | Meaning                                                                                                                                    |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `status.machineTypes`                 | The CPUs, memory and architecture of each machine type. A pool cannot use a machine type until the type appears in this list.              |
| `status.machineTypes[].localSsdBytes` | On AWS, the size of the type's NVMe SSD instance store.                                                                                    |
| `status.machineTypes[].observed`      | Once a node of the type has joined: the CPUs, memory and storage that the node reported, with the image and storage layout it booted with. |
| `status.machineTypesVersion`          | For the node pool controller's own use. Do not set it.                                                                                     |
| `status.spotPrices`                   | On AWS, each offering's `machineType`, `location` and `price` in dollars an hour. See [Spot price order](#spot-price-order).               |
| `status.spotPricesReadAt`             | The time of the last price read.                                                                                                           |
| `status.credentialsVerifiedAt`        | The time the class's credential was last checked.                                                                                          |
| `status.conditions`                   | `SpotPricesRead` is `False` while a price read fails, with the account's error in its message. `CredentialsVerified` is below.             |

While a pool uses the class, the controller checks its credential once an hour: it reads the credential, exchanges it, and reads the first machine type, as `kite nodepool verify` does. `kite nodepool verify` records its own result as well, so after you fix a credential, running it clears the failure at once. The `CredentialsVerified` condition is `True` with reason `Verified`, or `False` with the step that failed, `CredentialFailed`, `ExchangeFailed`, `ComputeFailed` or `PricesFailed`, and the account's error in its message. A class whose credential fails is listed in the [cluster summary](/docs/reference/resources/#read-the-cluster-summary).

A pool plans a new machine of a type against `observed` while the class's image matches it, and until then against the listed size less 7.5% of its memory.

### Credentials and endpoints

- `credentialsSecretRef.namespace` defaults to `kube-system`. Anyone who writes the class needs `get` on that Secret.
- Credential errors do not appear on the class. To check the credentials, run `kite nodepool verify <nodeclass>` ([CLI reference](/docs/reference/cli/#connect-a-cloud-account-for-node-pools)).
- Without `spec.gcp.serviceAccount`, a GCP claim reports `Launched=Unknown` with reason `CreateFailed`.
- The control plane refuses an endpoint or issuer override whose origin is not listed in `KITE_PROVIDER_ENDPOINTS`.
- The control plane ignores a service-account key's own `token_uri`. It exchanges the key at Google's token endpoint, or at `spec.gcp.endpoints.oauth` when the deployment allows that origin.

### Spot price order

An offering is a machine type in a zone. By default, a pool tries each type in `spec.machineTypes` in each zone in turn, and moves to the next type only when every zone has refused the type. With `spec.aws.order: SpotPrice` and `spec.aws.spot: true`:

- A pool tries the offerings from the cheapest Spot price. Equal prices keep the listed order, and an offering with no price comes after every priced one.
- The node pool controller reads each listed type's price in each zone with `ec2:DescribeSpotPriceHistory`, at most once an hour, into `status.spotPrices`.
- A pool uses the listed order when no prices have been read, or when the last read is more than six hours old.

To check that the class's role can read prices, run `kite nodepool verify <nodeclass>`.

## NodePool

A `NodePool` refers to a class. It sets the limits, labels and taints of the pool's nodes. It also sets what each node reserves for the agent and the system, and when the pool removes nodes. [Consolidation and expiry](/docs/node-pools/#consolidation-and-expiry) describes the disruption fields.

### Example

This pool uses the `gce` class from [Set up a node pool](/docs/set-up-node-pools/), and removes empty nodes after ten minutes. To select its nodes, use the label `kiteplane.dev/nodepool: workers`.

```yaml
apiVersion: kiteplane.dev/v1alpha1
kind: NodePool
metadata:
  name: workers
spec:
  nodeClassRef:
    name: gce
  limits:
    nodes: "10"
    cpu: "20"
  disruption:
    consolidateAfter: 10m
    consolidationPolicy: WhenEmpty
    registrationTimeout: 10m
```

### Fields

| Field                                    | Required | Meaning                                                                                                                                                                                                  |
| ---------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `spec.nodeClassRef.name`                 | Yes      | The `NodeClass` to use.                                                                                                                                                                                  |
| `spec.weight`                            | No       | The pool's place in the order that the controller tries pools: higher first, then by name. 0 to 100. Default: 0.                                                                                         |
| `spec.template.labels`                   | No       | Labels copied to every claim and node the pool creates.                                                                                                                                                  |
| `spec.template.taints`                   | No       | Taints copied to every claim and node the pool creates.                                                                                                                                                  |
| `spec.template.kubeReserved`             | No       | The `cpu`, `memory` or `ephemeral-storage` that each node the pool creates reserves out of its allocatable. Defaults: `cpu: 100m`, `memory: 256Mi`.                                                      |
| `spec.limits`                            | No       | Maximum totals of `nodes`, `cpu`, `memory`, `pods` and `ephemeral-storage` across the pool, including pending claims. The pool ignores any other key. Unset: no limit.                                   |
| `spec.queueing.reserveAfter`             | No       | How long a pod can wait on the pool's limits before the pool reserves its capacity for the pod. Unset: no reservation.                                                                                   |
| `spec.disruption.consolidateAfter`       | No       | How long a node must stay removable under `consolidationPolicy` before the pool removes it. Unset: no consolidation.                                                                                     |
| `spec.disruption.consolidationPolicy`    | No       | `WhenEmpty` (default) or `WhenEmptyOrUnderutilized`.                                                                                                                                                     |
| `spec.disruption.expireAfter`            | No       | Maximum node age. Unset: no expiry.                                                                                                                                                                      |
| `spec.disruption.terminationGracePeriod` | No       | Maximum time to drain a node. Defaults to 5 minutes.                                                                                                                                                     |
| `spec.disruption.registrationTimeout`    | No       | How long a new claim has to register before Kite deletes its machine. Defaults to 10 minutes.                                                                                                            |
| `spec.disruption.unreachableTimeout`     | No       | How long a node may stay unreachable before Kite deletes its machine. Defaults to 30 minutes.                                                                                                            |
| `spec.disruption.budgets`                | No       | How many of the pool's nodes consolidation and drift may remove at once. Unset: one budget of `nodes: 10%`. An empty list sets no limit. See [Disruption budgets](/docs/node-pools/#disruption-budgets). |
| `spec.disruption.budgets[].nodes`        | Yes      | A count, such as `3`, or a percentage of the pool's nodes, such as `10%`, rounded up.                                                                                                                    |
| `spec.disruption.budgets[].reasons`      | No       | The kinds of removal that the budget limits: `Empty`, `Underutilized` or `Drifted`. Unset: all three.                                                                                                    |
| `spec.disruption.budgets[].schedule`     | No       | A cron schedule, in UTC, when the budget starts to apply. Set it with `duration`. Unset: the budget always applies.                                                                                      |
| `spec.disruption.budgets[].duration`     | No       | How long the budget applies after each time the schedule matches, such as `8h`.                                                                                                                          |

Set limits on every pool ([Limits and placement](/docs/node-pools/#limits-and-placement)).

### NodePool status

| Field                | Meaning                                                                                                                                                                                                                                                                                                                 |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `status.unavailable` | The provider's capacity refusals. See [Capacity refusals](#capacity-refusals).                                                                                                                                                                                                                                          |
| `status.reservedFor` | The pod that the pool reserves its capacity for, by its `namespace`, `name` and `uid`. Absent while the pool reserves capacity for no pod.                                                                                                                                                                              |
| `status.conditions`  | `UnreachableDeletionPaused` is `True` while more than one node, and more than a fifth of the cluster's nodes, are unreachable. While it is `True`, the pool deletes no machine for being unreachable.                                                                                                                   |
| `status.resources`   | The pool's totals of `nodes`, `cpu`, `memory`, `pods` and `ephemeral-storage`, counted as `spec.limits` counts them: every claim of the pool, pending ones included, except a claim being deleted or one that failed. Each machine counts at the size the pool plans it at. The pool writes it each time it reconciles. |

The pool records a Warning event when the `UnreachableDeletionPaused` pause starts.

### Durations

A duration is one or more whole numbers, each followed by `ms`, `s`, `m` or `h`, such as `90s` or `1h30m`.

:::caution
The API accepts any string, but Kite ignores any other form, such as `1.5h` or `1d`. An ignored `consolidateAfter` or `expireAfter` removes nothing, and an ignored `reserveAfter` reserves nothing. An ignored `terminationGracePeriod`, `registrationTimeout` or `unreachableTimeout` takes its default.
:::

### Capacity refusals

A capacity refusal is an error in which the provider refuses a machine for lack of capacity or quota. `status.unavailable` lists each refusal with these fields:

- `nodeClass`, `machineType` and `location`.
- `attempts`.
- `retryAt`, in Unix milliseconds.
- The provider's `message` and `code`.

These GCP codes count as capacity refusals:

- `ZONE_RESOURCE_POOL_EXHAUSTED`
- `ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS`
- `RESOURCE_POOL_EXHAUSTED`
- `QUOTA_EXCEEDED`

These AWS codes count too:

- `InsufficientInstanceCapacity`
- `Unsupported`
- `SpotMaxPriceTooLow`
- `VcpuLimitExceeded`
- `MaxSpotInstanceCountExceeded`
- `InstanceLimitExceeded`

An AWS instance that stops with `Server.InsufficientInstanceCapacity` also counts. No DigitalOcean error counts. Any other error does not make the controller [fall back](/docs/node-pools/#capacity-refusals) to another zone, machine type or pool.

When the provider takes back a Spot machine, the controller adds an entry with the code `SpotReclaimed`. The controller then waits 30 minutes before it uses that machine type in that location again. The wait doubles with each further reclaim in a row, up to 6 hours.

### Deletion

Each `NodePool` has the finalizer `kiteplane.dev/termination`. A deleted pool keeps its `deletionTimestamp` and stays listed until the provider lists none of its machines.

`kite deploy destroy` deletes the pools. To remove a cluster another way, first delete each pool through the cluster's API, then wait until `/apis/kiteplane.dev/v1alpha1/nodepools` lists none. A machine whose cluster is gone keeps running until you delete it.

## NodeClaim

A `NodeClaim` tracks one machine from creation until its node registers. Kite creates and deletes claims. Do not create one yourself.

| Field                                                  | Meaning                                                                                                                                                                                               |
| ------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `metadata.annotations["kiteplane.dev/nodeclass-hash"]` | A hash of the class fields that the machine was built with, such as its image, disk and runtimes, taken when the machine was created. When the class's hash differs, Kite treats the node as drifted. |
| `spec.nodePool`                                        | The pool that created the claim.                                                                                                                                                                      |
| `spec.nodeClass`                                       | The class that supplied the provider settings.                                                                                                                                                        |
| `spec.machineType`                                     | The machine type that the controller chose from the class's list.                                                                                                                                     |
| `spec.location`                                        | The zone or region that the controller chose.                                                                                                                                                         |
| `spec.labels`                                          | The pool's template labels, plus the node labels below.                                                                                                                                               |
| `spec.taints`                                          | Copied from the pool.                                                                                                                                                                                 |
| `spec.kubeReserved`                                    | Copied from the pool's `template.kubeReserved`.                                                                                                                                                       |
| `status.phase`                                         | `Pending`, `Provisioning`, `Registered`, or `Failed`.                                                                                                                                                 |
| `status.instanceName`                                  | The instance name that Kite requested from the provider.                                                                                                                                              |
| `status.instanceId`                                    | Provider's instance ID.                                                                                                                                                                               |
| `status.addresses`                                     | The addresses the provider gave the machine, private and public, IPv4 and IPv6.                                                                                                                       |
| `status.location`                                      | Provider location.                                                                                                                                                                                    |
| `status.image`                                         | The image that the machine uses, when Kite knows it.                                                                                                                                                  |
| `status.storage`                                       | The `diskGiB`, `diskType`, and `localSsdCount` that the machine uses.                                                                                                                                 |
| `status.nodeName`                                      | Node name after registration.                                                                                                                                                                         |
| `status.joinTokenHash`                                 | SHA-256 of a one-time join token, for machines that cannot attest.                                                                                                                                    |
| `status.callerIdentity`                                | On AWS, the account, role and STS endpoint a join is checked against.                                                                                                                                 |
| `status.conditions`                                    | `Launched` and `Registered`, with a reason and message when not `True`.                                                                                                                               |
| `status.capacityFailure`                               | The provider's `code` and `message`, while Kite confirms that a failed machine is gone.                                                                                                               |

### Node labels

Every node that a pool creates has these labels. A pod can select nodes by them. A pool's `template.labels` cannot change them.

| Label                              | Value                           |
| ---------------------------------- | ------------------------------- |
| `kiteplane.dev/nodepool`           | The pool's name.                |
| `topology.kubernetes.io/zone`      | The zone, on GCE and EC2.       |
| `topology.kubernetes.io/region`    | The region.                     |
| `node.kubernetes.io/instance-type` | The machine type.               |
| `kiteplane.dev/provider`           | `gcp`, `aws` or `digitalocean`. |
| `kiteplane.dev/capacity-type`      | `spot` or `on-demand`.          |

A node whose class lists a runtime in `spec.runtimes` also has the label `runtime.kiteplane.dev/<runtime>: "true"`, such as `runtime.kiteplane.dev/gvisor: "true"`.
