0

Install Kubernetes 1-Click Applications

by
Published Dec 20, 2024

To install a Kubernetes 1-Click application on a cluster, send a POST request to `/v2/1-clicks/kubernetes`. The `addon_slugs` and `cluster_uuid` must be provided as body parameter in order to specify which 1-Click application(s) to install. To list all available 1-Click Kubernetes applications, send a request to `/v2/1-clicks?type=kubernetes`.

Script digitalocean Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Digitalocean = {
3
  token: string;
4
};
5
/**
6
 * Install Kubernetes 1-Click Applications
7
 * To install a Kubernetes 1-Click application on a cluster, send a POST request to
8
`/v2/1-clicks/kubernetes`. The `addon_slugs` and `cluster_uuid` must be provided as body
9
parameter in order to specify which 1-Click application(s) to install. To list all available
10
1-Click Kubernetes applications, send a request to `/v2/1-clicks?type=kubernetes`.
11

12
 */
13
export async function main(
14
  auth: Digitalocean,
15
  body: { addon_slugs: string[]; cluster_uuid: string },
16
) {
17
  const url = new URL(`https://api.digitalocean.com/v2/1-clicks/kubernetes`);
18

19
  const response = await fetch(url, {
20
    method: "POST",
21
    headers: {
22
      "Content-Type": "application/json",
23
      Authorization: "Bearer " + auth.token,
24
    },
25
    body: JSON.stringify(body),
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