@highstate/talos 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/charts/cilium-1.16.4.tgz +0 -0
- package/assets/manifests/cilium.yaml +2177 -0
- package/dist/cluster/index.js +154 -0
- package/package.json +10 -4
- package/dist/cluster/index.mjs +0 -3
@@ -0,0 +1,154 @@
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
2
|
+
import { forUnit, output, interpolate, all } from '@highstate/pulumi';
|
3
|
+
import { talos } from '@highstate/library';
|
4
|
+
import { machine, cluster } from '@pulumiverse/talos';
|
5
|
+
|
6
|
+
const { name, args, inputs, outputs } = forUnit(talos.cluster);
|
7
|
+
const clusterName = args.clusterName ?? name;
|
8
|
+
const globalConfigPatch = output({
|
9
|
+
machine: {
|
10
|
+
install: {
|
11
|
+
image: "ghcr.io/siderolabs/installer:v1.8.3",
|
12
|
+
extensions: [{ image: "ghcr.io/siderolabs/qemu-guest-agent:9.1.0" }]
|
13
|
+
},
|
14
|
+
sysctls: {
|
15
|
+
"net.ipv4.ip_forward": "1",
|
16
|
+
"net.ipv4.conf.all.src_valid_mark": "1"
|
17
|
+
}
|
18
|
+
},
|
19
|
+
cluster: {
|
20
|
+
allowSchedulingOnMasters: inputs.workers.length.apply(
|
21
|
+
(length) => length === 0 || args.scheduleOnMasters
|
22
|
+
),
|
23
|
+
inlineManifests: [
|
24
|
+
{
|
25
|
+
name: "cilium",
|
26
|
+
contents: readFileSync("../../assets/manifests/cilium.yaml", "utf-8")
|
27
|
+
}
|
28
|
+
],
|
29
|
+
network: {
|
30
|
+
cni: {
|
31
|
+
name: "none"
|
32
|
+
}
|
33
|
+
},
|
34
|
+
proxy: {
|
35
|
+
disabled: true
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}).apply(JSON.stringify);
|
39
|
+
const secrets = new machine.Secrets("secrets", { talosVersion: "v1.8.3" });
|
40
|
+
const clusterEndpoint = args.endpoint ?? interpolate`https://${inputs.masters[0].endpoint}:6443`;
|
41
|
+
const masterConfig = getConfiguration("controlplane");
|
42
|
+
const workerConfig = getConfiguration("worker");
|
43
|
+
const masterApplies = inputs.masters.apply((masters) => {
|
44
|
+
if (!masters.length) {
|
45
|
+
throw new Error("At least one master node is required.");
|
46
|
+
}
|
47
|
+
return masters.map((master) => {
|
48
|
+
return new machine.ConfigurationApply(
|
49
|
+
master.hostname,
|
50
|
+
getConfigurationApplyArgs(master, masterConfig.machineConfiguration)
|
51
|
+
);
|
52
|
+
});
|
53
|
+
});
|
54
|
+
const bootstrap = new machine.Bootstrap(
|
55
|
+
"bootstrap",
|
56
|
+
{
|
57
|
+
clientConfiguration: secrets.clientConfiguration,
|
58
|
+
node: masterApplies[0].node
|
59
|
+
},
|
60
|
+
{ dependsOn: masterApplies }
|
61
|
+
);
|
62
|
+
const workerApplies = inputs.workers.apply((workers) => {
|
63
|
+
return workers.map((worker) => {
|
64
|
+
return new machine.ConfigurationApply(
|
65
|
+
worker.hostname,
|
66
|
+
getConfigurationApplyArgs(worker, workerConfig.machineConfiguration),
|
67
|
+
{ dependsOn: bootstrap }
|
68
|
+
);
|
69
|
+
});
|
70
|
+
});
|
71
|
+
const kubeconfig = all([
|
72
|
+
cluster.getKubeconfigOutput({
|
73
|
+
clientConfiguration: secrets.clientConfiguration,
|
74
|
+
node: masterApplies[0].node
|
75
|
+
}),
|
76
|
+
cluster.getHealthOutput({
|
77
|
+
clientConfiguration: secrets.clientConfiguration,
|
78
|
+
endpoints: masterApplies.apply((masterApplies2) => masterApplies2.map((x) => x.node)),
|
79
|
+
controlPlaneNodes: masterApplies.apply((masterApplies2) => masterApplies2.map((x) => x.node)),
|
80
|
+
workerNodes: workerApplies.apply((workerApplies2) => workerApplies2.map((x) => x.node))
|
81
|
+
})
|
82
|
+
]).apply(([kubeconfig2]) => kubeconfig2.kubeconfigRaw);
|
83
|
+
const clientConfiguration = output({
|
84
|
+
context: clusterName,
|
85
|
+
contexts: {
|
86
|
+
[clusterName]: {
|
87
|
+
endpoints: masterApplies.apply((masterApplies2) => masterApplies2.map((x) => x.node)),
|
88
|
+
ca: secrets.clientConfiguration.caCertificate,
|
89
|
+
crt: secrets.clientConfiguration.clientCertificate,
|
90
|
+
key: secrets.clientConfiguration.clientKey
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}).apply(JSON.stringify);
|
94
|
+
const machineSecrets = secrets.machineSecrets.apply(JSON.stringify);
|
95
|
+
function getConfiguration(machineType) {
|
96
|
+
const configPatches = [globalConfigPatch];
|
97
|
+
if (args.sharedConfigPatch && Object.keys(args.sharedConfigPatch).length > 0) {
|
98
|
+
configPatches.push(JSON.stringify(args.sharedConfigPatch));
|
99
|
+
}
|
100
|
+
if (machineType === "controlplane" && args.masterConfigPatch && Object.keys(args.masterConfigPatch).length > 0) {
|
101
|
+
configPatches.push(JSON.stringify(args.masterConfigPatch));
|
102
|
+
}
|
103
|
+
if (machineType === "worker" && args.workerConfigPatch && Object.keys(args.workerConfigPatch).length > 0) {
|
104
|
+
configPatches.push(JSON.stringify(args.workerConfigPatch));
|
105
|
+
}
|
106
|
+
return machine.getConfigurationOutput({
|
107
|
+
clusterEndpoint,
|
108
|
+
machineSecrets: secrets.machineSecrets,
|
109
|
+
clusterName,
|
110
|
+
machineType,
|
111
|
+
talosVersion: "v1.8.3",
|
112
|
+
configPatches
|
113
|
+
});
|
114
|
+
}
|
115
|
+
function getConfigurationApplyArgs(node, machineConfiguration) {
|
116
|
+
return {
|
117
|
+
clientConfiguration: secrets.clientConfiguration,
|
118
|
+
machineConfigurationInput: machineConfiguration,
|
119
|
+
node: node.endpoint,
|
120
|
+
configPatches: [
|
121
|
+
JSON.stringify({
|
122
|
+
machine: { network: { hostname: node.hostname } }
|
123
|
+
})
|
124
|
+
]
|
125
|
+
};
|
126
|
+
}
|
127
|
+
var index = outputs({
|
128
|
+
k8sCluster: {
|
129
|
+
kubeconfig
|
130
|
+
},
|
131
|
+
talosCluster: {
|
132
|
+
clientConfiguration,
|
133
|
+
machineSecrets
|
134
|
+
},
|
135
|
+
egress: {
|
136
|
+
someField: "hi"
|
137
|
+
},
|
138
|
+
$terminal: {
|
139
|
+
image: "ghcr.io/exeteres/highstate/terminal-talos",
|
140
|
+
command: ["/bin/bash"],
|
141
|
+
cwd: "/cluster",
|
142
|
+
files: {
|
143
|
+
"/cluster/kubeconfig": kubeconfig,
|
144
|
+
"/cluster/talosconfig": clientConfiguration,
|
145
|
+
"/cluster/secrets": machineSecrets
|
146
|
+
},
|
147
|
+
env: {
|
148
|
+
KUBECONFIG: "/cluster/kubeconfig",
|
149
|
+
TALOSCONFIG: "/cluster/talosconfig"
|
150
|
+
}
|
151
|
+
}
|
152
|
+
});
|
153
|
+
|
154
|
+
export { index as default };
|
package/package.json
CHANGED
@@ -1,18 +1,24 @@
|
|
1
1
|
{
|
2
2
|
"name": "@highstate/talos",
|
3
|
-
"version": "0.4.
|
3
|
+
"version": "0.4.2",
|
4
4
|
"type": "module",
|
5
5
|
"files": [
|
6
|
+
"assets",
|
6
7
|
"dist"
|
7
8
|
],
|
8
9
|
"exports": {
|
9
|
-
"./cluster": "./dist/cluster/index.
|
10
|
+
"./cluster": "./dist/cluster/index.js"
|
10
11
|
},
|
11
12
|
"publishConfig": {
|
12
13
|
"access": "public"
|
13
14
|
},
|
14
15
|
"scripts": {
|
15
|
-
"build": "pkgroll --
|
16
|
+
"build": "pkgroll --tsconfig=tsconfig.build.json",
|
17
|
+
"generate-cilium": "bash ./scripts/generate-cilium.sh"
|
18
|
+
},
|
19
|
+
"dependencies": {
|
20
|
+
"@highstate/pulumi": "^0.4.2",
|
21
|
+
"@pulumiverse/talos": "^0.4.1"
|
16
22
|
},
|
17
23
|
"peerDependencies": {
|
18
24
|
"@highstate/library": "workspace:^"
|
@@ -20,5 +26,5 @@
|
|
20
26
|
"devDependencies": {
|
21
27
|
"pkgroll": "^2.5.1"
|
22
28
|
},
|
23
|
-
"gitHead": "
|
29
|
+
"gitHead": "e88c7c588267cf028c054f694d402902dc057919"
|
24
30
|
}
|
package/dist/cluster/index.mjs
DELETED