# kubernetesNodePools (/docs/reference/api/kubernetes-node-pools)

> Node pools are the groups of worker nodes of a `standard` Kubernetes cluster ([kubernetesClusters](/docs/reference/api/kubernetes-clusters)); an `autopilot` cluster has none, because the provider runs its nodes. A cluster's first node pools are created with it; these calls add, resize and remove pools later. Every call records what the tenant wants and returns at once: the node pool shows `pending`, `ready`, `updating`, `deleting`, `deleted` or `error` (with a `message`), and its cluster goes `updating` until the reconciler has converged the change, then `ready` again. A node pool the provider refuses is `error`, and so is its cluster, with the pool named in its `message`, until the pool is changed or deleted. The reconciler publishes `kubernetes.nodepool.ready`, `kubernetes.nodepool.error` and `kubernetes.nodepool.deleted` on the cluster's subject. A node pool's name is also its provider-side name.



Node pools are the groups of worker nodes of a `standard` Kubernetes cluster ([kubernetesClusters](/docs/reference/api/kubernetes-clusters)); an `autopilot` cluster has none, because the provider runs its nodes. A cluster's first node pools are created with it; these calls add, resize and remove pools later. Every call records what the tenant wants and returns at once: the node pool shows `pending`, `ready`, `updating`, `deleting`, `deleted` or `error` (with a `message`), and its cluster goes `updating` until the reconciler has converged the change, then `ready` again. A node pool the provider refuses is `error`, and so is its cluster, with the pool named in its `message`, until the pool is changed or deleted. The reconciler publishes `kubernetes.nodepool.ready`, `kubernetes.nodepool.error` and `kubernetes.nodepool.deleted` on the cluster's subject. A node pool's name is also its provider-side name.

All 4 methods are served by @better-compute/server 0.3.0.

| Method              | Kind     | Authorization                                              | Phase | Status     |
| ------------------- | -------- | ---------------------------------------------------------- | ----- | ---------- |
| [`create`](#create) | mutation | `compute:kubernetes:update` @ `compute-kubernetes-cluster` | v1.0  | registered |
| [`list`](#list)     | read     | `compute:kubernetes:read` @ `compute-kubernetes-cluster`   | v1.0  | registered |
| [`update`](#update) | mutation | `compute:kubernetes:update` @ `compute-kubernetes-cluster` | v1.0  | registered |
| [`delete`](#delete) | mutation | `compute:kubernetes:update` @ `compute-kubernetes-cluster` | v1.0  | registered |

## create [#create]

`POST /api/compute/kubernetesNodePools/create`

Adds a node pool to a `standard` cluster that is not being deleted and returns it `pending` (`INVALID_STATE` for an autopilot cluster or one being deleted).

* `name` is 1 to 40 characters, `[a-z]([-a-z0-9]*[a-z0-9])?`, unique among the cluster's node pools that are not deleted (`CONFLICT`); a deleted pool's name is free again.
* `machineType` is the provider's machine type (`e2-standard-4`). `nodeCount` (0 to 1000) is nodes per zone of the pool; with `autoscaling` (`minNodes` 0 to 1000 not above `maxNodes` 1 to 1000) it is the initial count.
* Optional: `diskGiB` (10 to 65536) and `diskType` (`pd-balanced`), `spot`, `accelerators` (`{ type: 'nvidia-l4', count }`, 1 to 16 per node), `zones` (at most 10, zones of the cluster's region and of the account), Kubernetes `labels` (at most 32) and `taints` (at most 32, effect `NoSchedule`, `PreferNoSchedule` or `NoExecute`).
* A cluster has at most 10 node pools that are not deleted (`QUOTA_EXCEEDED`).
* With an `idempotencyKey` (scoped to the tenant, the caller and the cluster) a retry returns the same node pool; the same key with another request is `CONFLICT`.

Publishes `kubernetes.nodepool.created`. Decided as `compute:kubernetes:update` on the cluster.

* **Kind:** mutation
* **Authorization:** `compute:kubernetes:update` @ `compute-kubernetes-cluster`
* **Module:** `kubernetes`
* **Phase:** v1.0 (registered)

**Input**

| Field                  | Type                                                 | Required | Constraints                                                        |
| ---------------------- | ---------------------------------------------------- | -------- | ------------------------------------------------------------------ |
| `tenantId`             | string                                               | yes      | at most 128 characters; matches `^[A-Za-z0-9._:-]{1,128}$`         |
| `clusterId`            | string                                               | yes      | at most 56 characters; matches `^kcl_[0-9a-hjkmnp-tv-z]{26,52}$`   |
| `name`                 | string                                               | yes      | at most 40 characters; matches `^[a-z]([-a-z0-9]{0,38}[a-z0-9])?$` |
| `machineType`          | string                                               | yes      | at most 63 characters; matches `^[a-z0-9][a-z0-9.-]{0,62}$`        |
| `nodeCount`            | integer                                              | yes      | 0-1000                                                             |
| `autoscaling`          | object                                               |          |                                                                    |
| `autoscaling.minNodes` | integer                                              | yes      | 0-1000                                                             |
| `autoscaling.maxNodes` | integer                                              | yes      | 1-1000                                                             |
| `diskGiB`              | integer                                              |          | 10-65536                                                           |
| `diskType`             | string                                               |          | matches `^[a-z][a-z0-9-]{1,40}$`                                   |
| `spot`                 | boolean                                              |          | default `false`                                                    |
| `accelerators`         | object                                               |          |                                                                    |
| `accelerators.type`    | string                                               | yes      | matches `^[a-z0-9][a-z0-9-]{0,62}$`                                |
| `accelerators.count`   | integer                                              | yes      | 1-16                                                               |
| `zones`                | list of string                                       |          | 0-10 items                                                         |
| `labels`               | map of string                                        |          |                                                                    |
| `taints`               | list of object                                       |          | 0-32 items                                                         |
| `taints[].key`         | string                                               | yes      |                                                                    |
| `taints[].value`       | string                                               |          | at most 63 characters                                              |
| `taints[].effect`      | one of `NoSchedule`, `PreferNoSchedule`, `NoExecute` | yes      |                                                                    |
| `idempotencyKey`       | string                                               |          | at most 128 characters; matches `^[A-Za-z0-9._:-]{1,128}$`         |

## list [#list]

`POST /api/compute/kubernetesNodePools/list`

Returns the cluster's node pools that are not deleted. Decided as `compute:kubernetes:read` on the cluster.

* **Kind:** read
* **Authorization:** `compute:kubernetes:read` @ `compute-kubernetes-cluster`
* **Module:** `kubernetes`
* **Phase:** v1.0 (registered)

**Input**

| Field       | Type   | Required | Constraints                                                      |
| ----------- | ------ | -------- | ---------------------------------------------------------------- |
| `tenantId`  | string | yes      | at most 128 characters; matches `^[A-Za-z0-9._:-]{1,128}$`       |
| `clusterId` | string | yes      | at most 56 characters; matches `^kcl_[0-9a-hjkmnp-tv-z]{26,52}$` |

## update [#update]

`POST /api/compute/kubernetesNodePools/update`

Resizes a node pool in place: `nodeCount`, and `autoscaling` (`null` turns it off); name at least one. A `nodeCount` outside the pool's autoscaling bounds is `INVALID_INPUT`. The machine type, disks, accelerators, zones, labels and taints never change: delete the pool and create another. The pool goes `updating` (bumping its `version`) until the provider has resized it. A pool or cluster being deleted is `INVALID_STATE`. Decided as `compute:kubernetes:update` on the cluster.

* **Kind:** mutation
* **Authorization:** `compute:kubernetes:update` @ `compute-kubernetes-cluster`
* **Module:** `kubernetes`
* **Phase:** v1.0 (registered)

**Input**

| Field         | Type        | Required | Constraints                                                      |
| ------------- | ----------- | -------- | ---------------------------------------------------------------- |
| `tenantId`    | string      | yes      | at most 128 characters; matches `^[A-Za-z0-9._:-]{1,128}$`       |
| `clusterId`   | string      | yes      | at most 56 characters; matches `^kcl_[0-9a-hjkmnp-tv-z]{26,52}$` |
| `nodePoolId`  | string      | yes      | at most 56 characters; matches `^knp_[0-9a-hjkmnp-tv-z]{26,52}$` |
| `nodeCount`   | integer     |          | 0-1000                                                           |
| `autoscaling` | object,null |          |                                                                  |

## delete [#delete]

`POST /api/compute/kubernetesNodePools/delete`

Marks the node pool for deletion and returns it `deleting`; the reconciler deletes it at the provider, and it is then `deleted` and gone from `list`. Deleting a pool that is being deleted returns it unchanged. Decided as `compute:kubernetes:update` on the cluster.

* **Kind:** mutation
* **Authorization:** `compute:kubernetes:update` @ `compute-kubernetes-cluster`
* **Module:** `kubernetes`
* **Phase:** v1.0 (registered)

**Input**

| Field        | Type   | Required | Constraints                                                      |
| ------------ | ------ | -------- | ---------------------------------------------------------------- |
| `tenantId`   | string | yes      | at most 128 characters; matches `^[A-Za-z0-9._:-]{1,128}$`       |
| `clusterId`  | string | yes      | at most 56 characters; matches `^kcl_[0-9a-hjkmnp-tv-z]{26,52}$` |
| `nodePoolId` | string | yes      | at most 56 characters; matches `^knp_[0-9a-hjkmnp-tv-z]{26,52}$` |
