0

Run Clusterlint Checks on a Kubernetes Cluster

by
Published Dec 20, 2024

Clusterlint helps operators conform to Kubernetes best practices around resources, security and reliability to avoid common problems while operating or upgrading the clusters.

Script digitalocean Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Digitalocean = {
3
  token: string;
4
};
5
/**
6
 * Run Clusterlint Checks on a Kubernetes Cluster
7
 * Clusterlint helps operators conform to Kubernetes best practices around
8
resources, security and reliability to avoid common problems while operating
9
or upgrading the clusters.
10
 */
11
export async function main(
12
  auth: Digitalocean,
13
  cluster_id: string,
14
  body: {
15
    include_groups?: string[];
16
    include_checks?: string[];
17
    exclude_groups?: string[];
18
    exclude_checks?: string[];
19
  },
20
) {
21
  const url = new URL(
22
    `https://api.digitalocean.com/v2/kubernetes/clusters/${cluster_id}/clusterlint`,
23
  );
24

25
  const response = await fetch(url, {
26
    method: "POST",
27
    headers: {
28
      "Content-Type": "application/json",
29
      Authorization: "Bearer " + auth.token,
30
    },
31
    body: JSON.stringify(body),
32
  });
33
  if (!response.ok) {
34
    const text = await response.text();
35
    throw new Error(`${response.status} ${text}`);
36
  }
37
  return await response.json();
38
}
39