0

Retrieve Available Upgrades for an Existing Kubernetes Cluster

by
Published Dec 20, 2024

To determine whether a cluster can be upgraded, and the versions to which it can be upgraded, send a GET request to `/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades`.

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 Available Upgrades for an Existing Kubernetes Cluster
7
 * To determine whether a cluster can be upgraded, and the versions to which it
8
can be upgraded, send a GET request to
9
`/v2/kubernetes/clusters/$K8S_CLUSTER_ID/upgrades`.
10

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

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