@highstate/library 0.11.7 → 0.12.0
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/dist/highstate.library.msgpack +0 -0
- package/dist/index.js +288 -93
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/k3s.ts +14 -0
- package/src/third-party/yandex.ts +235 -66
package/package.json
CHANGED
package/src/k3s.ts
CHANGED
|
@@ -49,6 +49,20 @@ export const cluster = defineUnit({
|
|
|
49
49
|
*/
|
|
50
50
|
config: z.record(z.string(), z.unknown()).optional(),
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* The K3S configuration to pass to each server in the cluster.
|
|
54
|
+
*
|
|
55
|
+
* See: https://docs.k3s.io/installation/configuration
|
|
56
|
+
*/
|
|
57
|
+
serverConfig: z.record(z.string(), z.unknown()).optional(),
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The K3S configuration to pass to each agent in the cluster.
|
|
61
|
+
*
|
|
62
|
+
* See: https://docs.k3s.io/installation/configuration
|
|
63
|
+
*/
|
|
64
|
+
agentConfig: z.record(z.string(), z.unknown()).optional(),
|
|
65
|
+
|
|
52
66
|
/**
|
|
53
67
|
* The configuration of the registries to use for the K3S cluster.
|
|
54
68
|
*
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
import { defineEntity, defineUnit, z } from "@highstate/contract"
|
|
2
2
|
import { serverOutputs, vmSecrets, vmSshArgs } from "../common"
|
|
3
|
-
import { ipv4PrefixSchema, ipv46Schema } from "../network"
|
|
4
3
|
import * as ssh from "../ssh"
|
|
5
4
|
|
|
6
|
-
export const
|
|
7
|
-
type: "yandex.
|
|
5
|
+
export const connectionEntity = defineEntity({
|
|
6
|
+
type: "yandex.connection.v1",
|
|
8
7
|
|
|
9
8
|
schema: z.object({
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* The service account key file content (JSON).
|
|
11
|
+
*/
|
|
11
12
|
serviceAccountKeyFile: z.string().optional(),
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The ID of the cloud.
|
|
16
|
+
*/
|
|
12
17
|
cloudId: z.string(),
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The default folder ID.
|
|
21
|
+
*/
|
|
13
22
|
defaultFolderId: z.string(),
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The default availability zone.
|
|
26
|
+
*/
|
|
14
27
|
defaultZone: z.string(),
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The region ID.
|
|
31
|
+
*/
|
|
15
32
|
regionId: z.string().optional(),
|
|
16
33
|
}),
|
|
17
34
|
|
|
@@ -24,23 +41,51 @@ export const cloudEntity = defineEntity({
|
|
|
24
41
|
* The connection to a Yandex Cloud account.
|
|
25
42
|
*/
|
|
26
43
|
export const connection = defineUnit({
|
|
27
|
-
type: "yandex.connection.
|
|
44
|
+
type: "yandex.connection.v1",
|
|
28
45
|
|
|
29
46
|
args: {
|
|
30
47
|
/**
|
|
31
|
-
* The
|
|
48
|
+
* The region to create connection for.
|
|
49
|
+
*
|
|
50
|
+
* See [Regions](https://yandex.cloud/en/docs/overview/concepts/region) for details.
|
|
32
51
|
*/
|
|
33
|
-
|
|
52
|
+
region: z
|
|
53
|
+
.discriminatedUnion("id", [
|
|
54
|
+
z.object({
|
|
55
|
+
/**
|
|
56
|
+
* The ID of the region.
|
|
57
|
+
*/
|
|
58
|
+
id: z.literal("ru-central1"),
|
|
34
59
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
60
|
+
/**
|
|
61
|
+
* The default availability zone in ru-central1 to place resources in.
|
|
62
|
+
*/
|
|
63
|
+
defaultZone: z
|
|
64
|
+
.enum(["ru-central1-a", "ru-central1-b", "ru-central1-d"])
|
|
65
|
+
.default("ru-central1-d"),
|
|
66
|
+
}),
|
|
67
|
+
z.object({
|
|
68
|
+
/**
|
|
69
|
+
* The ID of the region.
|
|
70
|
+
*/
|
|
71
|
+
id: z.literal("kz1"),
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The default availability zone in kz1 to place resources in.
|
|
75
|
+
*/
|
|
76
|
+
defaultZone: z.enum(["kz1-a"]).default("kz1-a"),
|
|
77
|
+
}),
|
|
78
|
+
])
|
|
79
|
+
.prefault({ id: "ru-central1" }),
|
|
39
80
|
},
|
|
40
81
|
|
|
41
82
|
secrets: {
|
|
42
83
|
/**
|
|
43
84
|
* The service account key file content (JSON).
|
|
85
|
+
*
|
|
86
|
+
* Important: service account must have `iam.serviceAccounts.user` role to work properly.
|
|
87
|
+
*
|
|
88
|
+
* See [Creating an authorized key](https://yandex.cloud/en/docs/iam/operations/authentication/manage-authorized-keys#create-authorized-key) for details.
|
|
44
89
|
*/
|
|
45
90
|
serviceAccountKeyFile: {
|
|
46
91
|
schema: z.string().meta({ language: "json" }),
|
|
@@ -58,11 +103,11 @@ export const connection = defineUnit({
|
|
|
58
103
|
/**
|
|
59
104
|
* The Yandex Cloud connection.
|
|
60
105
|
*/
|
|
61
|
-
|
|
106
|
+
connection: connectionEntity,
|
|
62
107
|
},
|
|
63
108
|
|
|
64
109
|
meta: {
|
|
65
|
-
title: "
|
|
110
|
+
title: "YC Connection",
|
|
66
111
|
category: "Yandex Cloud",
|
|
67
112
|
icon: "simple-icons:yandexcloud",
|
|
68
113
|
iconColor: "#0080ff",
|
|
@@ -74,17 +119,186 @@ export const connection = defineUnit({
|
|
|
74
119
|
},
|
|
75
120
|
})
|
|
76
121
|
|
|
122
|
+
export const diskSchema = z.object({
|
|
123
|
+
/**
|
|
124
|
+
* The disk type.
|
|
125
|
+
*
|
|
126
|
+
* - Network SSD (network-ssd): Fast network drive; SSD network block storage.
|
|
127
|
+
* - Network HDD (network-hdd): Standard network drive; HDD network block storage.
|
|
128
|
+
* - Non-replicated SSD (network-ssd-nonreplicated): Enhanced performance network drive without redundancy.
|
|
129
|
+
* - Ultra high-speed network storage with three replicas (SSD) (network-ssd-io-m3): High-performance SSD offering the same speed as network-ssd-nonreplicated, plus redundancy.
|
|
130
|
+
*/
|
|
131
|
+
type: z
|
|
132
|
+
.enum(["network-ssd", "network-hdd", "network-ssd-nonreplicated", "network-ssd-io-m3"])
|
|
133
|
+
.default("network-ssd"),
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The disk size in GB.
|
|
137
|
+
*
|
|
138
|
+
* For `network-ssd-nonreplicated` and `network-ssd-io-m3` must be multiple of 93.
|
|
139
|
+
*/
|
|
140
|
+
size: z.number().default(20),
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
export const diskEntity = defineEntity({
|
|
144
|
+
type: "yandex.disk.v1",
|
|
145
|
+
|
|
146
|
+
schema: z.object({
|
|
147
|
+
/**
|
|
148
|
+
* The global ID of the disk.
|
|
149
|
+
*/
|
|
150
|
+
id: z.string(),
|
|
151
|
+
}),
|
|
152
|
+
|
|
153
|
+
meta: {
|
|
154
|
+
title: "YC Disk",
|
|
155
|
+
icon: "simple-icons:yandexcloud",
|
|
156
|
+
iconColor: "#0080ff",
|
|
157
|
+
secondaryIcon: "icon-park-outline:disk",
|
|
158
|
+
},
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* The disk on Yandex Cloud.
|
|
163
|
+
*/
|
|
164
|
+
export const disk = defineUnit({
|
|
165
|
+
type: "yandex.disk.v1",
|
|
166
|
+
|
|
167
|
+
args: {
|
|
168
|
+
/**
|
|
169
|
+
* The name of the disk in the folder.
|
|
170
|
+
* If not specified, the name of the unit will be used.
|
|
171
|
+
*/
|
|
172
|
+
diskName: z.string().optional(),
|
|
173
|
+
|
|
174
|
+
...diskSchema.shape,
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
inputs: {
|
|
178
|
+
connection: connectionEntity,
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
outputs: {
|
|
182
|
+
/**
|
|
183
|
+
* The disk entity.
|
|
184
|
+
*/
|
|
185
|
+
disk: diskEntity,
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
meta: {
|
|
189
|
+
title: "YC Disk",
|
|
190
|
+
category: "Yandex Cloud",
|
|
191
|
+
icon: "icon-park-outline:disk",
|
|
192
|
+
iconColor: "#0080ff",
|
|
193
|
+
secondaryIcon: "mage:compact-disk-fill",
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
source: {
|
|
197
|
+
package: "@highstate/yandex",
|
|
198
|
+
path: "disk",
|
|
199
|
+
},
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
export const imageEntity = defineEntity({
|
|
203
|
+
type: "yandex.image.v1",
|
|
204
|
+
|
|
205
|
+
schema: z.object({
|
|
206
|
+
/**
|
|
207
|
+
* The global ID of the image.
|
|
208
|
+
*/
|
|
209
|
+
id: z.string(),
|
|
210
|
+
}),
|
|
211
|
+
|
|
212
|
+
meta: {
|
|
213
|
+
title: "Yandex Cloud Image",
|
|
214
|
+
icon: "simple-icons:yandexcloud",
|
|
215
|
+
iconColor: "#0080ff",
|
|
216
|
+
secondaryIcon: "mage:compact-disk-fill",
|
|
217
|
+
},
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* The existing image from Yandex Cloud Marketplace or user images.
|
|
222
|
+
*/
|
|
223
|
+
export const existingImage = defineUnit({
|
|
224
|
+
type: "yandex.existing-image.v1",
|
|
225
|
+
|
|
226
|
+
args: {
|
|
227
|
+
/**
|
|
228
|
+
* The ID of the image.
|
|
229
|
+
*
|
|
230
|
+
* See [Yandex Cloud Marketplace Images](https://yandex.cloud/en/marketplace) to find available images and their IDs.
|
|
231
|
+
* You can also use user images by specifying their IDs.
|
|
232
|
+
*/
|
|
233
|
+
id: z.string(),
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
inputs: {
|
|
237
|
+
connection: connectionEntity,
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
outputs: {
|
|
241
|
+
/**
|
|
242
|
+
* The image entity.
|
|
243
|
+
*/
|
|
244
|
+
image: imageEntity,
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
meta: {
|
|
248
|
+
title: "YC Existing Image",
|
|
249
|
+
category: "Yandex Cloud",
|
|
250
|
+
icon: "simple-icons:yandexcloud",
|
|
251
|
+
iconColor: "#0080ff",
|
|
252
|
+
secondaryIcon: "mage:compact-disk-fill",
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
source: {
|
|
256
|
+
package: "@highstate/yandex",
|
|
257
|
+
path: "existing-image",
|
|
258
|
+
},
|
|
259
|
+
})
|
|
260
|
+
|
|
77
261
|
/**
|
|
78
262
|
* The virtual machine on Yandex Cloud.
|
|
79
263
|
*/
|
|
80
264
|
export const virtualMachine = defineUnit({
|
|
81
|
-
type: "yandex.virtual-machine.
|
|
265
|
+
type: "yandex.virtual-machine.v1",
|
|
82
266
|
|
|
83
267
|
args: {
|
|
268
|
+
/**
|
|
269
|
+
* The name of the virtual machine.
|
|
270
|
+
* If not specified, the name of the unit will be used.
|
|
271
|
+
*/
|
|
272
|
+
vmName: z.string().optional(),
|
|
273
|
+
|
|
84
274
|
/**
|
|
85
275
|
* The platform ID for the instance.
|
|
276
|
+
*
|
|
277
|
+
* See [Platforms](https://yandex.cloud/en/docs/compute/concepts/vm-platforms) for details.
|
|
86
278
|
*/
|
|
87
|
-
platformId: z
|
|
279
|
+
platformId: z
|
|
280
|
+
.enum([
|
|
281
|
+
// standard platforms
|
|
282
|
+
"standard-v1",
|
|
283
|
+
"standard-v2",
|
|
284
|
+
"standard-v3",
|
|
285
|
+
"amd-v1",
|
|
286
|
+
"standard-v4a",
|
|
287
|
+
|
|
288
|
+
// high-performance platforms
|
|
289
|
+
"highfreq-v3",
|
|
290
|
+
"highfreq-v4a",
|
|
291
|
+
|
|
292
|
+
// with gpu
|
|
293
|
+
"gpu-standard-v1",
|
|
294
|
+
"gpu-standard-v2",
|
|
295
|
+
"gpu-standard-v3",
|
|
296
|
+
"gpu-standard-v3i",
|
|
297
|
+
"standard-v3-t4",
|
|
298
|
+
"standard-v3-t4i",
|
|
299
|
+
"gpu-platform-v4",
|
|
300
|
+
])
|
|
301
|
+
.default("standard-v3"),
|
|
88
302
|
|
|
89
303
|
/**
|
|
90
304
|
* The resources to allocate to the virtual machine.
|
|
@@ -102,7 +316,7 @@ export const virtualMachine = defineUnit({
|
|
|
102
316
|
memory: z.number().default(4),
|
|
103
317
|
|
|
104
318
|
/**
|
|
105
|
-
* The core
|
|
319
|
+
* The guaranteed CPU core performance (10-100).
|
|
106
320
|
*/
|
|
107
321
|
coreFraction: z.number().min(10).max(100).optional(),
|
|
108
322
|
})
|
|
@@ -111,26 +325,7 @@ export const virtualMachine = defineUnit({
|
|
|
111
325
|
/**
|
|
112
326
|
* The boot disk configuration.
|
|
113
327
|
*/
|
|
114
|
-
|
|
115
|
-
.object({
|
|
116
|
-
/**
|
|
117
|
-
* The disk size in GB.
|
|
118
|
-
*
|
|
119
|
-
* For `network-ssd-nonreplicated` must be multiple of 93.
|
|
120
|
-
*/
|
|
121
|
-
size: z.number().default(20),
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* The disk type.
|
|
125
|
-
*/
|
|
126
|
-
type: z.string().default("network-ssd-nonreplicated"),
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* The image family to use.
|
|
130
|
-
*/
|
|
131
|
-
imageFamily: z.string().default("ubuntu-2204-lts"),
|
|
132
|
-
})
|
|
133
|
-
.prefault({}),
|
|
328
|
+
bootDisk: diskSchema.prefault({}),
|
|
134
329
|
|
|
135
330
|
/**
|
|
136
331
|
* The network configuration.
|
|
@@ -147,40 +342,13 @@ export const virtualMachine = defineUnit({
|
|
|
147
342
|
* Whether to assign a public IP.
|
|
148
343
|
*/
|
|
149
344
|
assignPublicIp: z.boolean().default(true),
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* The list of DNS servers.
|
|
153
|
-
*/
|
|
154
|
-
dns: ipv46Schema.array().default([]),
|
|
155
345
|
})
|
|
156
346
|
.prefault({}),
|
|
157
347
|
|
|
158
|
-
/**
|
|
159
|
-
* The IPv4 address configuration.
|
|
160
|
-
*/
|
|
161
|
-
ipv4: z
|
|
162
|
-
.discriminatedUnion("type", [
|
|
163
|
-
z.object({
|
|
164
|
-
type: z.literal("dhcp"),
|
|
165
|
-
}),
|
|
166
|
-
z.object({
|
|
167
|
-
type: z.literal("static"),
|
|
168
|
-
address: z.string(),
|
|
169
|
-
prefix: ipv4PrefixSchema.default(24),
|
|
170
|
-
gateway: z.string().optional(),
|
|
171
|
-
}),
|
|
172
|
-
])
|
|
173
|
-
.default({ type: "dhcp" }),
|
|
174
|
-
|
|
175
348
|
/**
|
|
176
349
|
* The SSH configuration.
|
|
177
350
|
*/
|
|
178
351
|
ssh: vmSshArgs,
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Additional metadata for cloud-init.
|
|
182
|
-
*/
|
|
183
|
-
metadata: z.record(z.string(), z.string()).default({}),
|
|
184
352
|
},
|
|
185
353
|
|
|
186
354
|
secrets: {
|
|
@@ -188,14 +356,15 @@ export const virtualMachine = defineUnit({
|
|
|
188
356
|
},
|
|
189
357
|
|
|
190
358
|
inputs: {
|
|
191
|
-
|
|
359
|
+
connection: connectionEntity,
|
|
360
|
+
image: imageEntity,
|
|
192
361
|
...ssh.inputs,
|
|
193
362
|
},
|
|
194
363
|
|
|
195
364
|
outputs: serverOutputs,
|
|
196
365
|
|
|
197
366
|
meta: {
|
|
198
|
-
title: "
|
|
367
|
+
title: "YC Virtual Machine",
|
|
199
368
|
category: "Yandex Cloud",
|
|
200
369
|
icon: "simple-icons:yandexcloud",
|
|
201
370
|
iconColor: "#0080ff",
|
|
@@ -208,4 +377,4 @@ export const virtualMachine = defineUnit({
|
|
|
208
377
|
},
|
|
209
378
|
})
|
|
210
379
|
|
|
211
|
-
export type
|
|
380
|
+
export type Connection = z.infer<typeof connectionEntity.schema>
|