0

Retrieve a Node Pool for a Kubernetes Cluster

by
Published Dec 20, 2024

To show information about a specific node pool in a Kubernetes cluster, send a GET request to `/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID`.

Script digitalocean Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Digitalocean = {
3
  token: string;
4
};
5
/**
6
 * Retrieve a Node Pool for a Kubernetes Cluster
7
 * To show information about a specific node pool in a Kubernetes cluster, send
8
a GET request to `/v2/kubernetes/clusters/$K8S_CLUSTER_ID/node_pools/$NODE_POOL_ID`.
9

10
 */
11
export async function main(
12
  auth: Digitalocean,
13
  cluster_id: string,
14
  node_pool_id: string,
15
) {
16
  const url = new URL(
17
    `https://api.digitalocean.com/v2/kubernetes/clusters/${cluster_id}/node_pools/${node_pool_id}`,
18
  );
19

20
  const response = await fetch(url, {
21
    method: "GET",
22
    headers: {
23
      Authorization: "Bearer " + auth.token,
24
    },
25
    body: undefined,
26
  });
27
  if (!response.ok) {
28
    const text = await response.text();
29
    throw new Error(`${response.status} ${text}`);
30
  }
31
  return await response.json();
32
}
33