Skip to content
betterstack-alchemyUnofficial

Cloud.KubernetesNodePool

Kind ResourceType id BetterStack.Cloud.KubernetesNodePoolSource src/Cloud/KubernetesNodePool.tsLive test gated Lifecycle test runs against the offline mock; a live run exists but is gated behind BETTERSTACK_TEST_CLOUD_BILLABLE=1 because it bills; live runs need the owner's go-ahead (test/Cloud/KubernetesNodePool.test.ts).

A group of workers in a KubernetesCluster, all of one server type (Cloud.listServerType lists them; pick at least 4 vCPU and 4 GB, since Kubernetes itself takes some of every node). Workers are ordinary servers, billed as such. A cluster has at most 10 node pools and 100 workers.

Deploying blocks until the node pool is active (up to 30 minutes), after create and after every update; it fails with a typed WaitFailed when the pool is being deleted, or WaitTimeout past the budget. active means the pool isn’t changing size; its workers can still be joining (see nodes).

What changes in place. nodeCount (0 to 100; scaling down drains each worker first), labels and taints. serverType, name, kubernetesClusterId and availabilityZone replace the node pool — the documented way to change the server type of your workers.

Reserved names. A deleted node pool’s name stays taken in its cluster until the delete finishes (a create reusing it gets a 422 on name). Replacing a pool that keeps an explicit name therefore deletes the old pool first, and every create retries (for up to 15 minutes) while the API rejects the name — also when the pool was deleted out of band and is created again under its generated name. Leave name out to replace create-before-delete under a fresh generated name. An explicit name held by another live pool of the cluster fails with the 422 at once.

Ownership. The API keeps no metadata for it, so the generated name (it ends in the resource instance’s random suffix) is what identifies an object this stack created: a create interrupted before its state was saved is found by that name on the next deploy. An explicitly named object can’t be told apart from someone else’s (it is taken over only with --adopt), and list returns every object.

Zone. A child doesn’t take its zone from its parent: it uses its own availabilityZone, else the credentials’ zone. When the parent lives in another zone, pass the parent’s along (availabilityZone: parent.availabilityZone), or every call for it answers NotFound.

Two workers with a label and a taint

const cluster = yield* BetterStack.Cloud.KubernetesCluster("k8s", {});
const pool = yield* BetterStack.Cloud.KubernetesNodePool("workers", {
kubernetesClusterId: cluster.id,
name: "workers",
serverType: "AM4",
nodeCount: 2,
labels: { tier: "backend" },
taints: [{ key: "dedicated", value: "backend", effect: "NoSchedule" }],
});

Reference a node pool by cluster and id

const existing = BetterStack.Cloud.KubernetesNodePool.lookup({
kubernetesClusterId: "42",
id: "7",
});

kubernetesClusterId string required

The ID of the parent this kubernetes cluster belongs to.

serverType string required

The server type of the workers. List the server types with betterstack server-type list. The server type can't be changed after the node pool is created.

availabilityZone string

Availability zone the resource lives in, such as us-west-2a. Defaults to the credentials' zone (BETTERSTACK_AVAILABILITY_ZONE, or the profile's). Changing it replaces the resource. A child of a resource in another zone (a firewall rule, a node pool, a snapshot of an instance outside the credentials' zone) must repeat the parent's availabilityZone: it receives only the parent's id, so its zone cannot be derived.

labels CreateKubernetesNodePoolRequestLabelsMap

The Kubernetes labels of the workers, as string pairs, or an empty object when there are none.

name string

The node pool's name, unique among the cluster's node pools: up to 30 lowercase letters, digits and hyphens, starting and ending with a letter or digit. Defaults to a unique name generated from the stack, stage and logical id. Changing it replaces the node pool.

nodeCount number

How many workers the node pool should have, from 0 to 100. The node pools of a cluster can have 100 workers in total. nodes lists the workers the node pool has now.

taints CreateKubernetesNodePoolRequestTaintsItem[]

The Kubernetes taints of the workers, or an empty list when there are none.

availabilityZone string always set

Availability zone the resource lives in, such as us-west-2a.

id string always set

The node pool's ID.

kubernetesClusterId string always set

The ID of the Kubernetes cluster the node pool belongs to.

name string always set

The node pool's name.

labels KubernetesNodePoolLabelsMap

The Kubernetes labels of the workers, as string pairs, or an empty object when there are none.

nodeCount number

How many workers the node pool should have, from 0 to 100. The node pools of a cluster can have 100 workers in total. nodes lists the workers the node pool has now.

nodes KubernetesNodePoolNodesItem[]

The node pool's workers, sorted by name. New workers show up at once as queued, then go through provisioning and joining to ready.

nodesReady number

How many workers of the node pool are ready.

scaling KubernetesNodePoolScaling | null

How a change of size is going while status is scaling, or null otherwise.

serverType string

The server type of the workers. List the server types with betterstack server-type list. The server type can't be changed after the node pool is created.

status string

The node pool's state. The node pool is ready when the cluster is running and every worker of the node pool is ready. - active: The node pool isn't changing size. The node pool's workers can still be joining or being replaced. - scaling: We're adding or removing workers to reach node_count. Scaling happens after you change node_count, or when the node pool has more or fewer workers than node_count. - deleting: We're removing the node pool. - destroyed: The node pool is deleted.

statusMessage string | null

Why the node pool has fewer workers than node_count, such as a quota limit, no capacity for the server type in the zone, or a server we couldn't create. Is null again once the node pool reaches node_count.

taints KubernetesNodePoolTaintsItem[]

The Kubernetes taints of the workers, or an empty list when there are none.

KubernetesNodePool.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.

id string required

The node pool's ID.

kubernetesClusterId string required

The ID of the Kubernetes cluster.

availabilityZone string

Zone the cluster lives in. Defaults to the credentials' zone.