-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster.ts
51 lines (43 loc) · 1.36 KB
/
cluster.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import * as pulumi from "@pulumi/pulumi";
import * as command from "@pulumi/command";
import * as k8s from "@pulumi/kubernetes";
import { promises, readFileSync } from "fs";
const { readFile } = promises;
export type K8sClusterOptions = {};
const pulumiComponentNamespace: string = "turingev:K8sCluster";
const stack = pulumi.getStack();
export class K8sCluster extends pulumi.ComponentResource {
provider: k8s.Provider;
constructor(
name,
args: K8sClusterOptions,
opts?: pulumi.ComponentResourceOptions,
) {
super(pulumiComponentNamespace, name, args, opts);
// TODO: debug cmd error 126 in pipeline
// const k3seCmd = new command.local.Command(
// "k3seCmd",
// {
// create: "k3se up ./k3se/stage.yml -k /dev/null",
// update: "k3se up ./k3se/stage.yml -k /dev/null",
// delete: "k3se down ./k3se/stage.yml",
// },
// { parent: this },
// );
const getKubeconfigCmd = new command.local.Command(
"getKubeconfigCmd",
{
create: `k3se up -s -k /tmp/k3se-kubeconfig ./k3se/${stack}.yml &> /dev/null && cat /tmp/k3se-kubeconfig`,
},
{ parent: this },
);
const provider = new k8s.Provider(
"k8sProvider",
{
kubeconfig: getKubeconfigCmd.stdout,
},
{ parent: this, dependsOn: getKubeconfigCmd },
);
this.provider = provider;
}
}