@highstate/library 0.21.1 → 0.25.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 +3534 -1445
- package/package.json +3 -3
- package/src/abbreviations.ts +2 -0
- package/src/apps/index.ts +1 -0
- package/src/apps/vault.ts +374 -0
- package/src/common/access-point.ts +150 -4
- package/src/common/filter.ts +40 -0
- package/src/common/index.ts +1 -0
- package/src/common/server.ts +131 -1
- package/src/databases/etcd.ts +12 -4
- package/src/databases/index.ts +1 -0
- package/src/databases/minio.ts +19 -0
- package/src/databases/mongodb.ts +12 -4
- package/src/databases/mysql.ts +12 -4
- package/src/databases/postgresql.ts +12 -4
- package/src/databases/rustfs.ts +169 -0
- package/src/dns.ts +3 -3
- package/src/index.ts +3 -2
- package/src/k3s.ts +129 -3
- package/src/k8s/apps/envoy-gateway.ts +50 -0
- package/src/k8s/apps/etcd.ts +1 -1
- package/src/k8s/apps/grafana.ts +1 -1
- package/src/k8s/apps/index.ts +4 -0
- package/src/k8s/apps/mariadb.ts +1 -1
- package/src/k8s/apps/matrix-stack.ts +2 -1
- package/src/k8s/apps/minio.ts +2 -2
- package/src/k8s/apps/mongodb.ts +1 -1
- package/src/k8s/apps/postgresql.ts +1 -1
- package/src/k8s/apps/rustfs.ts +119 -0
- package/src/k8s/apps/shared.ts +16 -1
- package/src/k8s/apps/signoz.ts +32 -0
- package/src/k8s/apps/traefik.ts +5 -5
- package/src/k8s/apps/valkey.ts +1 -1
- package/src/k8s/apps/vault.ts +113 -0
- package/src/k8s/apps/vaultwarden.ts +31 -2
- package/src/k8s/apps/workload.ts +12 -14
- package/src/k8s/cert-manager.ts +44 -2
- package/src/k8s/cilium.ts +3 -16
- package/src/k8s/coredns.ts +62 -0
- package/src/k8s/gateway.ts +25 -0
- package/src/k8s/index.ts +1 -0
- package/src/k8s/scheduling.ts +87 -0
- package/src/k8s/service-args.ts +109 -0
- package/src/k8s/shared.ts +26 -0
- package/src/k8s/workload.ts +21 -0
- package/src/netaminity.ts +950 -0
- package/src/network/endpoint.ts +12 -1
- package/src/network/index.ts +1 -0
- package/src/network/network.ts +58 -0
- package/src/restic.ts +2 -1
- package/src/ssh.ts +27 -0
- package/src/third-party/gcp.ts +427 -0
- package/src/third-party/index.ts +1 -0
- package/src/third-party/yandex.ts +194 -1
- package/src/tls.ts +135 -6
- package/src/utils.ts +16 -1
- package/src/wireguard.ts +257 -4
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
z,
|
|
9
9
|
} from "@highstate/contract"
|
|
10
10
|
import { serverEntity, serverOutputs, vmSecrets, vmSshArgs } from "../common"
|
|
11
|
+
import { l4EndpointEntity, portSchema } from "../network"
|
|
11
12
|
import * as ssh from "../ssh"
|
|
12
13
|
|
|
13
14
|
export const connectionEntity = defineEntity({
|
|
@@ -77,7 +78,7 @@ export const connection = defineUnit({
|
|
|
77
78
|
* The default availability zone in ru-central1 to place resources in.
|
|
78
79
|
*/
|
|
79
80
|
defaultZone: z
|
|
80
|
-
.enum(["ru-central1-a", "ru-central1-b", "ru-central1-d"])
|
|
81
|
+
.enum(["ru-central1-a", "ru-central1-b", "ru-central1-d", "ru-central1-e"])
|
|
81
82
|
.default("ru-central1-d"),
|
|
82
83
|
}),
|
|
83
84
|
z.object({
|
|
@@ -222,6 +223,91 @@ export const disk = defineUnit({
|
|
|
222
223
|
},
|
|
223
224
|
})
|
|
224
225
|
|
|
226
|
+
export const publicAddressEntity = defineEntity({
|
|
227
|
+
type: "yandex.public-address.v1",
|
|
228
|
+
|
|
229
|
+
schema: z.object({
|
|
230
|
+
/**
|
|
231
|
+
* The global ID of the public address.
|
|
232
|
+
*/
|
|
233
|
+
id: z.string(),
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The name of the public address.
|
|
237
|
+
*/
|
|
238
|
+
name: z.string(),
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* The IPv4 address value.
|
|
242
|
+
*/
|
|
243
|
+
address: z.string(),
|
|
244
|
+
}),
|
|
245
|
+
|
|
246
|
+
meta: {
|
|
247
|
+
title: "YC Public Address",
|
|
248
|
+
icon: "simple-icons:yandexcloud",
|
|
249
|
+
iconColor: "#0080ff",
|
|
250
|
+
secondaryIcon: "mdi:ip-network-outline",
|
|
251
|
+
},
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* The reserved public IPv4 address on Yandex Cloud.
|
|
256
|
+
*/
|
|
257
|
+
export const publicAddress = defineUnit({
|
|
258
|
+
type: "yandex.public-address.v1",
|
|
259
|
+
|
|
260
|
+
args: {
|
|
261
|
+
/**
|
|
262
|
+
* The name of the public address in the folder.
|
|
263
|
+
* If not specified, the name of the unit will be used.
|
|
264
|
+
*/
|
|
265
|
+
addressName: z.string().optional(),
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* The ID of the cloud to create the public address in.
|
|
269
|
+
* If not specified, will use the cloud from the connection.
|
|
270
|
+
*/
|
|
271
|
+
cloudId: z.string().optional(),
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* The ID of the folder to create the public address in.
|
|
275
|
+
* If not specified, will use the default folder from the connection.
|
|
276
|
+
*/
|
|
277
|
+
folderId: z.string().optional(),
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* The availability zone to reserve the address in.
|
|
281
|
+
* If not specified, will use the default zone from the connection.
|
|
282
|
+
*/
|
|
283
|
+
zone: z.string().optional(),
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
inputs: {
|
|
287
|
+
connection: connectionEntity,
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
outputs: {
|
|
291
|
+
/**
|
|
292
|
+
* The public address entity.
|
|
293
|
+
*/
|
|
294
|
+
publicAddress: publicAddressEntity,
|
|
295
|
+
},
|
|
296
|
+
|
|
297
|
+
meta: {
|
|
298
|
+
title: "YC Public Address",
|
|
299
|
+
category: "Yandex Cloud",
|
|
300
|
+
icon: "simple-icons:yandexcloud",
|
|
301
|
+
iconColor: "#0080ff",
|
|
302
|
+
secondaryIcon: "mdi:ip-network-outline",
|
|
303
|
+
},
|
|
304
|
+
|
|
305
|
+
source: {
|
|
306
|
+
package: "@highstate/yandex",
|
|
307
|
+
path: "public-address",
|
|
308
|
+
},
|
|
309
|
+
})
|
|
310
|
+
|
|
225
311
|
export const imageEntity = defineEntity({
|
|
226
312
|
type: "yandex.image.v1",
|
|
227
313
|
|
|
@@ -378,6 +464,65 @@ const vmArgs = $args({
|
|
|
378
464
|
preemptible: z.boolean().default(false),
|
|
379
465
|
})
|
|
380
466
|
|
|
467
|
+
const nlbArgs = z.object({
|
|
468
|
+
/**
|
|
469
|
+
* Whether to create a network load balancer for the instance group.
|
|
470
|
+
*/
|
|
471
|
+
enabled: z.boolean().default(false),
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* The name of the network load balancer.
|
|
475
|
+
* If not specified, the instance group name will be used.
|
|
476
|
+
*/
|
|
477
|
+
name: z.string().optional(),
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* The load-balanced ports to expose through the shared public address.
|
|
481
|
+
*
|
|
482
|
+
* Each listener must use `protocol:source=>target` format, for example `tcp:80=>8080`.
|
|
483
|
+
*
|
|
484
|
+
* If the source and target ports are the same, use `protocol:port` shorthand, for example `tcp:80`.
|
|
485
|
+
*
|
|
486
|
+
* When SSH is enabled, the `tcp:<ssh-port>` listener is included automatically.
|
|
487
|
+
*/
|
|
488
|
+
listeners: z.string().array().default([]),
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* The health check protocol.
|
|
492
|
+
*/
|
|
493
|
+
healthCheckProtocol: z.enum(["tcp", "http"]).default("tcp"),
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* The port to use for health checks.
|
|
497
|
+
*/
|
|
498
|
+
healthCheckPort: portSchema.default(22),
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* The HTTP path to use for health checks.
|
|
502
|
+
*/
|
|
503
|
+
healthCheckPath: z.string().default("/"),
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* The interval between health checks in seconds.
|
|
507
|
+
*/
|
|
508
|
+
healthCheckInterval: z.number().int().min(1).max(60).default(2),
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* The timeout for health check responses in seconds.
|
|
512
|
+
*/
|
|
513
|
+
healthCheckTimeout: z.number().int().min(1).max(60).default(1),
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* The number of successful checks required to mark a target healthy.
|
|
517
|
+
*/
|
|
518
|
+
healthCheckHealthyThreshold: z.number().int().default(2),
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* The number of failed checks required to mark a target unhealthy.
|
|
522
|
+
*/
|
|
523
|
+
healthCheckUnhealthyThreshold: z.number().int().default(2),
|
|
524
|
+
})
|
|
525
|
+
|
|
381
526
|
/**
|
|
382
527
|
* The virtual machine on Yandex Cloud.
|
|
383
528
|
*/
|
|
@@ -413,6 +558,15 @@ export const virtualMachine = defineUnit({
|
|
|
413
558
|
inputs: {
|
|
414
559
|
connection: connectionEntity,
|
|
415
560
|
image: imageEntity,
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* The reserved public address to attach to the virtual machine.
|
|
564
|
+
*/
|
|
565
|
+
publicAddress: {
|
|
566
|
+
entity: publicAddressEntity,
|
|
567
|
+
required: false,
|
|
568
|
+
},
|
|
569
|
+
|
|
416
570
|
...ssh.inputs,
|
|
417
571
|
},
|
|
418
572
|
|
|
@@ -462,6 +616,17 @@ export const instanceGroup = defineUnit({
|
|
|
462
616
|
*/
|
|
463
617
|
size: z.number().default(1),
|
|
464
618
|
|
|
619
|
+
/**
|
|
620
|
+
* The zones to spread instances across.
|
|
621
|
+
* If not specified, will use the default zone from the connection.
|
|
622
|
+
*/
|
|
623
|
+
zones: z.string().array().optional(),
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* The network load balancer configuration.
|
|
627
|
+
*/
|
|
628
|
+
nlb: nlbArgs.prefault({}),
|
|
629
|
+
|
|
465
630
|
...vmArgs,
|
|
466
631
|
},
|
|
467
632
|
|
|
@@ -472,6 +637,25 @@ export const instanceGroup = defineUnit({
|
|
|
472
637
|
inputs: {
|
|
473
638
|
connection: connectionEntity,
|
|
474
639
|
image: imageEntity,
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* The public addresses to attach to instances.
|
|
643
|
+
* Addresses are sorted by name and assigned to instances in that order.
|
|
644
|
+
*/
|
|
645
|
+
publicAddresses: {
|
|
646
|
+
entity: publicAddressEntity,
|
|
647
|
+
required: false,
|
|
648
|
+
multiple: true,
|
|
649
|
+
},
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* The reserved public address to use for the network load balancer.
|
|
653
|
+
*/
|
|
654
|
+
nlbPublicAddress: {
|
|
655
|
+
entity: publicAddressEntity,
|
|
656
|
+
required: false,
|
|
657
|
+
},
|
|
658
|
+
|
|
475
659
|
...ssh.inputs,
|
|
476
660
|
},
|
|
477
661
|
|
|
@@ -480,6 +664,12 @@ export const instanceGroup = defineUnit({
|
|
|
480
664
|
entity: serverEntity,
|
|
481
665
|
multiple: true,
|
|
482
666
|
},
|
|
667
|
+
|
|
668
|
+
nlbEndpoints: {
|
|
669
|
+
entity: l4EndpointEntity,
|
|
670
|
+
multiple: true,
|
|
671
|
+
required: false,
|
|
672
|
+
},
|
|
483
673
|
},
|
|
484
674
|
|
|
485
675
|
meta: {
|
|
@@ -502,5 +692,8 @@ export type ConnectionInput = EntityInput<typeof connectionEntity>
|
|
|
502
692
|
export type Disk = EntityValue<typeof diskEntity>
|
|
503
693
|
export type DiskInput = EntityInput<typeof diskEntity>
|
|
504
694
|
|
|
695
|
+
export type PublicAddress = EntityValue<typeof publicAddressEntity>
|
|
696
|
+
export type PublicAddressInput = EntityInput<typeof publicAddressEntity>
|
|
697
|
+
|
|
505
698
|
export type Image = EntityValue<typeof imageEntity>
|
|
506
699
|
export type ImageInput = EntityInput<typeof imageEntity>
|
package/src/tls.ts
CHANGED
|
@@ -1,22 +1,151 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
defineEntity,
|
|
3
|
+
defineUnit,
|
|
4
|
+
type EntityInput,
|
|
5
|
+
type EntityValue,
|
|
6
|
+
z,
|
|
7
|
+
} from "@highstate/contract"
|
|
8
|
+
import { fileEntity, tlsIssuerEntity } from "./common"
|
|
9
|
+
|
|
10
|
+
export const privateKeyAlgorithmSchema = z.enum(["RSA", "ECDSA", "Ed25519"])
|
|
11
|
+
|
|
12
|
+
export const privateKeySchema = z
|
|
13
|
+
.object({
|
|
14
|
+
/**
|
|
15
|
+
* The private key algorithm.
|
|
16
|
+
*/
|
|
17
|
+
algorithm: privateKeyAlgorithmSchema.default("RSA"),
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The private key size in bits.
|
|
21
|
+
*/
|
|
22
|
+
size: z.number().int().positive().optional(),
|
|
23
|
+
})
|
|
24
|
+
.default({
|
|
25
|
+
algorithm: "RSA",
|
|
26
|
+
size: 4096,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
export const certificateUsageSchema = z.enum([
|
|
30
|
+
"digitalSignature",
|
|
31
|
+
"keyEncipherment",
|
|
32
|
+
"serverAuth",
|
|
33
|
+
"clientAuth",
|
|
34
|
+
])
|
|
35
|
+
|
|
36
|
+
export const certificateChainEntity = defineEntity({
|
|
37
|
+
type: "tls.certificate-chain.v1",
|
|
38
|
+
|
|
39
|
+
includes: {
|
|
40
|
+
/**
|
|
41
|
+
* The file containing the certificate chain (leaf and intermediate certificates) in PEM format.
|
|
42
|
+
*/
|
|
43
|
+
chain: fileEntity,
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The file containing the root certificate in PEM format.
|
|
47
|
+
* May be omitted if the root certificate is already trusted by the system.
|
|
48
|
+
*/
|
|
49
|
+
root: {
|
|
50
|
+
entity: fileEntity,
|
|
51
|
+
required: false,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
schema: z.unknown(),
|
|
56
|
+
|
|
57
|
+
meta: {
|
|
58
|
+
title: "TLS Certificate Chain",
|
|
59
|
+
color: "#2E7D32",
|
|
60
|
+
icon: "mdi:certificate",
|
|
61
|
+
iconColor: "#2E7D32",
|
|
62
|
+
},
|
|
63
|
+
})
|
|
3
64
|
|
|
4
65
|
export const certificateEntity = defineEntity({
|
|
5
66
|
type: "tls.certificate.v1",
|
|
6
67
|
|
|
7
68
|
includes: {
|
|
8
69
|
/**
|
|
9
|
-
* The
|
|
70
|
+
* The public chain of the certificate.
|
|
71
|
+
*/
|
|
72
|
+
chain: certificateChainEntity,
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The private key of the certificate in PEM format.
|
|
10
76
|
*/
|
|
11
|
-
|
|
77
|
+
privateKey: fileEntity,
|
|
12
78
|
},
|
|
13
79
|
|
|
14
80
|
schema: z.unknown(),
|
|
15
81
|
|
|
16
82
|
meta: {
|
|
17
83
|
title: "TLS Certificate",
|
|
18
|
-
color: "#
|
|
84
|
+
color: "#4CAF50",
|
|
19
85
|
icon: "mdi:certificate",
|
|
20
|
-
iconColor: "#
|
|
86
|
+
iconColor: "#4CAF50",
|
|
21
87
|
},
|
|
22
88
|
})
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Issues a TLS certificate using the provided TLS issuer.
|
|
92
|
+
*/
|
|
93
|
+
export const certificate = defineUnit({
|
|
94
|
+
type: "tls.certificate.v1",
|
|
95
|
+
|
|
96
|
+
args: {
|
|
97
|
+
/**
|
|
98
|
+
* The common name for the certificate.
|
|
99
|
+
*/
|
|
100
|
+
commonName: z.string().optional(),
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The alternative DNS names for the certificate.
|
|
104
|
+
*/
|
|
105
|
+
dnsNames: z.string().array().default([]),
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The private key configuration for the certificate.
|
|
109
|
+
*/
|
|
110
|
+
privateKey: privateKeySchema,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The requested key usages for the certificate.
|
|
114
|
+
*
|
|
115
|
+
* If not provided, the issuer default usages will be used.
|
|
116
|
+
*/
|
|
117
|
+
usages: certificateUsageSchema.array().default(["digitalSignature", "keyEncipherment"]),
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
inputs: {
|
|
121
|
+
/**
|
|
122
|
+
* The TLS issuer used to issue the certificate.
|
|
123
|
+
*/
|
|
124
|
+
issuer: tlsIssuerEntity,
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
outputs: {
|
|
128
|
+
certificate: certificateEntity,
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
meta: {
|
|
132
|
+
title: "TLS Certificate",
|
|
133
|
+
icon: "mdi:certificate",
|
|
134
|
+
category: "Security",
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
source: {
|
|
138
|
+
package: "@highstate/common",
|
|
139
|
+
path: "units/tls/certificate",
|
|
140
|
+
},
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
export type CertificateChain = EntityValue<typeof certificateChainEntity>
|
|
144
|
+
export type CertificateChainInput = EntityInput<typeof certificateChainEntity>
|
|
145
|
+
|
|
146
|
+
export type Certificate = EntityValue<typeof certificateEntity>
|
|
147
|
+
export type CertificateInput = EntityInput<typeof certificateEntity>
|
|
148
|
+
|
|
149
|
+
export type PrivateKeyAlgorithm = z.infer<typeof privateKeyAlgorithmSchema>
|
|
150
|
+
export type PrivateKeySpec = z.infer<typeof privateKeySchema>
|
|
151
|
+
export type CertificateUsage = z.infer<typeof certificateUsageSchema>
|
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type FullComponentArgumentOptions,
|
|
3
|
+
genericNameSchema,
|
|
4
|
+
objectMetaSchema,
|
|
5
|
+
z,
|
|
6
|
+
} from "@highstate/contract"
|
|
2
7
|
import { mapValues } from "remeda"
|
|
3
8
|
|
|
4
9
|
type PrefixWith<TString extends string, TPrefix extends string> = TPrefix extends ""
|
|
@@ -101,3 +106,13 @@ export const metadataSchema = z.record(metadataKeySchema, z.unknown())
|
|
|
101
106
|
export type Metadata = z.infer<typeof metadataSchema>
|
|
102
107
|
export type MetadataKey = z.infer<typeof metadataKeySchema>
|
|
103
108
|
export type MetadataContainer = { metadata?: Metadata }
|
|
109
|
+
|
|
110
|
+
export const entityMetaArgsSchema = objectMetaSchema
|
|
111
|
+
.pick({
|
|
112
|
+
title: true,
|
|
113
|
+
description: true,
|
|
114
|
+
icon: true,
|
|
115
|
+
iconColor: true,
|
|
116
|
+
})
|
|
117
|
+
.partial()
|
|
118
|
+
.prefault({})
|