//native
type Linode = {
token: string;
};
/**
* Create a Kubernetes cluster
* Creates a Kubernetes cluster.
*/
export async function main(
auth: Linode,
apiVersion: "v4" | "v4beta",
body: {
control_plane?: {
acl?: {
addresses?: { ipv4?: string[]; ipv6?: string[] };
enabled?: false | true;
"revision-id"?: string;
};
high_availability?: false | true;
};
k8s_version: string;
label: string;
node_pools: {
autoscaler?: { enabled?: false | true; max?: number; min?: number };
count: number;
disks?: { size?: number; type?: "raw" | "ext4" }[];
labels?: {};
tags?: string[];
taints?: {
effect: "NoSchedule" | "PreferNoSchedule" | "NoExecute";
key: string;
value: string;
}[];
type: string;
}[];
region: string;
tags?: string[];
tier?: "standard" | "enterprise";
},
) {
const url = new URL(`https://api.linode.com/${apiVersion}/lke/clusters`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago