@highstate/library 0.20.0 → 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.
Files changed (61) hide show
  1. package/dist/highstate.library.msgpack +0 -0
  2. package/dist/index.js +4260 -3948
  3. package/package.json +12 -12
  4. package/src/abbreviations.ts +2 -0
  5. package/src/apps/index.ts +1 -0
  6. package/src/apps/vault.ts +374 -0
  7. package/src/common/access-point.ts +150 -4
  8. package/src/common/filter.ts +40 -0
  9. package/src/common/index.ts +1 -0
  10. package/src/common/server.ts +131 -1
  11. package/src/databases/etcd.ts +12 -4
  12. package/src/databases/index.ts +1 -0
  13. package/src/databases/minio.ts +19 -0
  14. package/src/databases/mongodb.ts +12 -4
  15. package/src/databases/mysql.ts +12 -4
  16. package/src/databases/postgresql.ts +12 -4
  17. package/src/databases/rustfs.ts +169 -0
  18. package/src/dns.ts +3 -3
  19. package/src/index.ts +3 -0
  20. package/src/k3s.ts +129 -3
  21. package/src/k8s/apps/envoy-gateway.ts +50 -0
  22. package/src/k8s/apps/etcd.ts +1 -1
  23. package/src/k8s/apps/grafana.ts +1 -1
  24. package/src/k8s/apps/index.ts +4 -0
  25. package/src/k8s/apps/mariadb.ts +1 -1
  26. package/src/k8s/apps/matrix-stack.ts +2 -1
  27. package/src/k8s/apps/minio.ts +2 -2
  28. package/src/k8s/apps/mongodb.ts +1 -1
  29. package/src/k8s/apps/postgresql.ts +1 -1
  30. package/src/k8s/apps/rustfs.ts +119 -0
  31. package/src/k8s/apps/shared.ts +16 -1
  32. package/src/k8s/apps/signoz.ts +32 -0
  33. package/src/k8s/apps/traefik.ts +5 -5
  34. package/src/k8s/apps/valkey.ts +1 -1
  35. package/src/k8s/apps/vault.ts +113 -0
  36. package/src/k8s/apps/vaultwarden.ts +31 -2
  37. package/src/k8s/apps/workload.ts +12 -14
  38. package/src/k8s/cert-manager.ts +44 -2
  39. package/src/k8s/cilium.ts +3 -16
  40. package/src/k8s/coredns.ts +62 -0
  41. package/src/k8s/gateway.ts +25 -0
  42. package/src/k8s/index.ts +1 -0
  43. package/src/k8s/scheduling.ts +87 -0
  44. package/src/k8s/service-args.ts +109 -0
  45. package/src/k8s/shared.ts +26 -0
  46. package/src/k8s/workload.ts +21 -0
  47. package/src/netaminity.ts +950 -0
  48. package/src/network/address-space.ts +14 -0
  49. package/src/network/endpoint.ts +12 -1
  50. package/src/network/index.ts +1 -0
  51. package/src/network/network.ts +58 -0
  52. package/src/restic.ts +2 -1
  53. package/src/ssh.ts +27 -0
  54. package/src/third-party/gcp.ts +427 -0
  55. package/src/third-party/index.ts +1 -0
  56. package/src/third-party/yandex.ts +194 -1
  57. package/src/tls.ts +135 -6
  58. package/src/utils.ts +16 -1
  59. package/src/wireguard.ts +273 -4
  60. package/LICENSE +0 -21
  61. package/dist/index.js.map +0 -1
@@ -0,0 +1,950 @@
1
+ import {
2
+ defineEntity,
3
+ defineUnit,
4
+ type EntityInput,
5
+ type EntityValue,
6
+ secretSchema,
7
+ z,
8
+ } from "@highstate/contract"
9
+ import { gatewayEntity } from "./common"
10
+ import { implementationReferenceSchema } from "./impl-ref"
11
+ import {
12
+ clusterEntity,
13
+ helmExtensionArgs,
14
+ namespacedResourceEntity,
15
+ namespaceEntity,
16
+ schedulingArg,
17
+ serviceEntity,
18
+ } from "./k8s"
19
+ import { l3EndpointEntity, l4EndpointEntity } from "./network"
20
+
21
+ const source = (path: string) => ({
22
+ package: "@highstate/netaminity",
23
+ path,
24
+ })
25
+
26
+ const portSchema = z.number().int().min(1).max(65535)
27
+ const serviceTypeSchema = z.enum(["ClusterIP", "NodePort", "LoadBalancer"])
28
+ const podTemplateSchema = z.record(z.string(), z.unknown()).default({})
29
+ const replicasSchema = z.number().int().min(1).default(1)
30
+ const oddReplicasSchema = z
31
+ .number()
32
+ .int()
33
+ .min(1)
34
+ .refine(replicas => replicas % 2 === 1, "Netaminity replicas must be odd")
35
+ .default(1)
36
+
37
+ export const gatewayDataSchema = z.object({
38
+ /**
39
+ * The proxy-side gateway that accepts public TLS traffic.
40
+ */
41
+ proxyGateway: gatewayEntity.schema,
42
+
43
+ /**
44
+ * The target-side gateway that terminates TLS and routes requests.
45
+ */
46
+ targetGateway: gatewayEntity.schema,
47
+
48
+ /**
49
+ * The implementation reference used to create proxy-side TLS routes.
50
+ */
51
+ proxyImplRef: implementationReferenceSchema,
52
+
53
+ /**
54
+ * The implementation reference used to create target-side application routes.
55
+ */
56
+ targetImplRef: implementationReferenceSchema,
57
+
58
+ /**
59
+ * The TLS port exposed by the target-side gateway.
60
+ */
61
+ targetGatewayPort: portSchema,
62
+
63
+ /**
64
+ * The endpoints of the shared tunnel Service in the proxy cluster.
65
+ */
66
+ tunnelEndpoints: l4EndpointEntity.schema.array(),
67
+ })
68
+
69
+ export const proxyEntity = defineEntity({
70
+ type: "netaminity.proxy.v1",
71
+
72
+ extends: { namespacedResourceEntity },
73
+
74
+ includes: {
75
+ /**
76
+ * The consumer Service created for the proxy.
77
+ */
78
+ service: {
79
+ entity: serviceEntity,
80
+ required: false,
81
+ },
82
+ /**
83
+ * The endpoints where consumers can access the proxied service.
84
+ */
85
+ endpoints: {
86
+ entity: l4EndpointEntity,
87
+ multiple: true,
88
+ required: false,
89
+ },
90
+ },
91
+
92
+ schema: z.object({
93
+ /**
94
+ * The control endpoint where Netaminity targets connect to the proxy.
95
+ */
96
+ proxyEndpoint: z.string(),
97
+
98
+ /**
99
+ * The shared authentication secret used by the proxy and its targets.
100
+ */
101
+ sharedSecret: secretSchema(z.string()),
102
+ }),
103
+
104
+ meta: {
105
+ color: "#477D75",
106
+ title: "Netaminity Proxy",
107
+ icon: "eos-icons:proxy-outlined",
108
+ iconColor: "#477D75",
109
+ secondaryIcon: "mdi:connection",
110
+ },
111
+ })
112
+
113
+ export const targetEntity = defineEntity({
114
+ type: "netaminity.target.v1",
115
+
116
+ extends: { namespacedResourceEntity },
117
+ schema: z.unknown(),
118
+
119
+ meta: {
120
+ color: "#8064A2",
121
+ title: "Netaminity Target",
122
+ icon: "eos-icons:proxy-outlined",
123
+ iconColor: "#8064A2",
124
+ secondaryIcon: "mdi:target",
125
+ },
126
+ })
127
+
128
+ export const tunnelEntity = defineEntity({
129
+ type: "netaminity.tunnel.v1",
130
+
131
+ extends: { namespacedResourceEntity },
132
+
133
+ includes: {
134
+ /**
135
+ * The consumer Service created for the tunnel.
136
+ */
137
+ service: serviceEntity,
138
+
139
+ /**
140
+ * The endpoints where consumers can access the tunnel.
141
+ */
142
+ endpoints: {
143
+ entity: l4EndpointEntity,
144
+ multiple: true,
145
+ required: false,
146
+ },
147
+ },
148
+
149
+ schema: z.unknown(),
150
+
151
+ meta: {
152
+ color: "#2878A0",
153
+ title: "Netaminity Tunnel",
154
+ icon: "eos-icons:proxy-outlined",
155
+ iconColor: "#2878A0",
156
+ secondaryIcon: "bitcoin-icons:proxy-filled",
157
+ },
158
+ })
159
+
160
+ /**
161
+ * Installs the Netaminity operator on a Kubernetes cluster.
162
+ */
163
+ export const operator = defineUnit({
164
+ type: "netaminity.operator.v1",
165
+
166
+ args: {
167
+ ...helmExtensionArgs,
168
+ ...schedulingArg,
169
+
170
+ /**
171
+ * The number of Netaminity operator replicas.
172
+ *
173
+ * Leader election ensures that only one replica actively reconciles resources.
174
+ * The replica count must be odd.
175
+ */
176
+ replicas: oddReplicasSchema,
177
+
178
+ /**
179
+ * The hostname or IP address used to advertise NodePort proxy control Services.
180
+ *
181
+ * When omitted, the proxy host input or the first cluster endpoint is used.
182
+ */
183
+ proxyHost: z.string().optional(),
184
+ },
185
+
186
+ inputs: {
187
+ /**
188
+ * The Kubernetes cluster where the Netaminity operator should be installed.
189
+ */
190
+ k8sCluster: clusterEntity,
191
+
192
+ /**
193
+ * The hostname or IP address used to advertise NodePort proxy control Services.
194
+ *
195
+ * The first cluster endpoint is used when this input and the proxyHost argument are omitted.
196
+ */
197
+ proxyHost: {
198
+ entity: l3EndpointEntity,
199
+ required: false,
200
+ },
201
+ },
202
+
203
+ outputs: {
204
+ /**
205
+ * The Kubernetes cluster after the Netaminity operator has been installed.
206
+ */
207
+ k8sCluster: clusterEntity,
208
+ },
209
+
210
+ meta: {
211
+ title: "Netaminity Operator",
212
+ icon: "eos-icons:proxy-outlined",
213
+ iconColor: "#2878A0",
214
+ category: "Network",
215
+ },
216
+
217
+ source: source("operator"),
218
+ })
219
+
220
+ /**
221
+ * Creates a Netaminity proxy on a Kubernetes cluster.
222
+ */
223
+ export const proxy = defineUnit({
224
+ type: "netaminity.proxy.v1",
225
+
226
+ args: {
227
+ /**
228
+ * The name of the Proxy custom resource.
229
+ *
230
+ * If omitted, the unit name is used.
231
+ */
232
+ resourceName: z.string().optional(),
233
+
234
+ /**
235
+ * The name of the Kubernetes namespace to create for the proxy.
236
+ *
237
+ * Ignored when the namespace input is provided.
238
+ */
239
+ namespace: z.string().optional(),
240
+
241
+ /**
242
+ * Whether to create a Service for consumers of the proxied target.
243
+ */
244
+ serviceEnabled: z.boolean().default(true),
245
+
246
+ /**
247
+ * The name of the consumer Service.
248
+ *
249
+ * If omitted, the Proxy resource name is used.
250
+ */
251
+ serviceName: z.string().optional(),
252
+
253
+ /**
254
+ * The TCP port exposed by the consumer Service.
255
+ *
256
+ * When omitted, the port of the first endpoint input is used.
257
+ */
258
+ servicePort: portSchema.optional(),
259
+
260
+ /**
261
+ * Whether to expose the consumer Service outside the cluster.
262
+ *
263
+ * The Service type is selected automatically from the cluster configuration.
264
+ */
265
+ external: z.boolean().default(false),
266
+
267
+ /**
268
+ * The name of the control Service used by targets.
269
+ */
270
+ proxyServiceName: z.string().optional(),
271
+
272
+ /**
273
+ * The Kubernetes type of the control Service used by targets.
274
+ */
275
+ proxyServiceType: serviceTypeSchema.default("NodePort"),
276
+
277
+ /**
278
+ * The fixed NodePort for the control Service.
279
+ *
280
+ * Kubernetes assigns one when omitted.
281
+ */
282
+ proxyNodePort: portSchema.optional(),
283
+
284
+ /**
285
+ * The number of interchangeable proxy pods behind the Proxy Services.
286
+ */
287
+ replicas: replicasSchema,
288
+
289
+ /**
290
+ * Whether generated proxy pods use the node network namespace.
291
+ */
292
+ hostNetwork: z.boolean().default(false),
293
+
294
+ /**
295
+ * Whether generated proxy pods prefer distribution across Kubernetes nodes.
296
+ */
297
+ distributeByNodes: z.boolean().default(true),
298
+
299
+ /**
300
+ * The raw Netaminity pod template applied to the generated proxy pod.
301
+ */
302
+ podTemplate: podTemplateSchema,
303
+ },
304
+
305
+ secrets: {
306
+ /**
307
+ * The shared authentication secret used by the proxy and its targets.
308
+ *
309
+ * A random key is generated when omitted.
310
+ */
311
+ sharedSecret: z.string().optional(),
312
+ },
313
+
314
+ inputs: {
315
+ /**
316
+ * The Kubernetes cluster with the Netaminity operator installed.
317
+ */
318
+ k8sCluster: clusterEntity,
319
+
320
+ /**
321
+ * The target TCP endpoints whose port should be exposed by the consumer Service.
322
+ *
323
+ * The first endpoint's port is used when the servicePort argument is omitted.
324
+ */
325
+ endpoints: {
326
+ entity: l4EndpointEntity,
327
+ multiple: true,
328
+ required: false,
329
+ },
330
+
331
+ /**
332
+ * The existing Kubernetes namespace where the proxy should be created.
333
+ */
334
+ namespace: {
335
+ entity: namespaceEntity,
336
+ required: false,
337
+ },
338
+ },
339
+
340
+ outputs: {
341
+ /**
342
+ * The Netaminity proxy, including its control endpoint and shared secret.
343
+ */
344
+ proxy: proxyEntity,
345
+
346
+ /**
347
+ * The consumer Service created for the proxy.
348
+ */
349
+ service: {
350
+ entity: serviceEntity,
351
+ required: false,
352
+ },
353
+ /**
354
+ * The endpoints where consumers can access the proxied service.
355
+ */
356
+ endpoints: {
357
+ entity: l4EndpointEntity,
358
+ multiple: true,
359
+ },
360
+ },
361
+
362
+ meta: {
363
+ title: "Netaminity Proxy",
364
+ icon: "eos-icons:proxy-outlined",
365
+ iconColor: "#477D75",
366
+ secondaryIcon: "mdi:connection",
367
+ category: "Network",
368
+ },
369
+
370
+ source: source("proxy"),
371
+ })
372
+
373
+ /**
374
+ * Creates a Netaminity target connected to a standalone proxy.
375
+ */
376
+ export const target = defineUnit({
377
+ type: "netaminity.target.v1",
378
+
379
+ args: {
380
+ /**
381
+ * The name of the Target custom resource.
382
+ *
383
+ * If omitted, the unit name is used.
384
+ */
385
+ resourceName: z.string().optional(),
386
+
387
+ /**
388
+ * The name of the Kubernetes namespace to create for the target.
389
+ *
390
+ * Ignored when the namespace input is provided.
391
+ */
392
+ namespace: z.string().optional(),
393
+
394
+ /**
395
+ * The target TCP endpoint reachable from the generated target pod.
396
+ *
397
+ * When omitted, the first endpoint input is used.
398
+ */
399
+ endpoint: z.string().min(3).optional(),
400
+
401
+ /**
402
+ * Whether the generated target pod uses the node network namespace.
403
+ */
404
+ hostNetwork: z.boolean().default(false),
405
+
406
+ /**
407
+ * Whether the generated target pod prefers distribution across Kubernetes nodes.
408
+ */
409
+ distributeByNodes: z.boolean().default(true),
410
+
411
+ /**
412
+ * The raw Netaminity pod template applied to the generated target pod.
413
+ */
414
+ podTemplate: podTemplateSchema,
415
+ },
416
+
417
+ inputs: {
418
+ /**
419
+ * The Kubernetes cluster with the Netaminity operator installed.
420
+ */
421
+ k8sCluster: clusterEntity,
422
+
423
+ /**
424
+ * The standalone Netaminity proxy to connect the target to.
425
+ */
426
+ proxy: proxyEntity,
427
+
428
+ /**
429
+ * The target TCP endpoints reachable from the generated target pod.
430
+ *
431
+ * The first endpoint is used when the endpoint argument is omitted.
432
+ */
433
+ endpoints: {
434
+ entity: l4EndpointEntity,
435
+ multiple: true,
436
+ required: false,
437
+ },
438
+
439
+ /**
440
+ * The existing Kubernetes namespace where the target should be created.
441
+ */
442
+ namespace: {
443
+ entity: namespaceEntity,
444
+ required: false,
445
+ },
446
+ },
447
+
448
+ outputs: {
449
+ /**
450
+ * The created Netaminity target resource.
451
+ */
452
+ target: targetEntity,
453
+ },
454
+
455
+ meta: {
456
+ title: "Netaminity Target",
457
+ icon: "eos-icons:proxy-outlined",
458
+ iconColor: "#8064A2",
459
+ secondaryIcon: "mdi:target",
460
+ category: "Network",
461
+ },
462
+
463
+ source: source("target"),
464
+ })
465
+
466
+ /**
467
+ * Creates a complete Netaminity tunnel within one Kubernetes cluster.
468
+ */
469
+ export const tunnel = defineUnit({
470
+ type: "netaminity.tunnel.v1",
471
+
472
+ args: {
473
+ /**
474
+ * The name of the Tunnel custom resource.
475
+ *
476
+ * If omitted, the unit name is used.
477
+ */
478
+ resourceName: z.string().optional(),
479
+
480
+ /**
481
+ * The name of the Kubernetes namespace to create for the tunnel.
482
+ *
483
+ * Ignored when the namespace input is provided.
484
+ */
485
+ namespace: z.string().optional(),
486
+
487
+ /**
488
+ * The number of proxy and target pairs created for the tunnel.
489
+ */
490
+ replicas: replicasSchema,
491
+
492
+ /**
493
+ * The number of interchangeable proxy pods created for each Proxy resource.
494
+ */
495
+ proxyReplicas: replicasSchema,
496
+
497
+ /**
498
+ * Whether generated proxy and target pods use their node network namespace.
499
+ */
500
+ hostNetwork: z.boolean().default(false),
501
+
502
+ /**
503
+ * Whether generated proxy and target pods prefer distribution across Kubernetes nodes.
504
+ */
505
+ distributeByNodes: z.boolean().default(true),
506
+
507
+ /**
508
+ * The target TCP endpoint reachable from generated target pods.
509
+ *
510
+ * When omitted, the first endpoint input is used.
511
+ */
512
+ endpoint: z.string().min(3).optional(),
513
+
514
+ /**
515
+ * The name of the consumer Service.
516
+ *
517
+ * If omitted, the Tunnel resource name is used.
518
+ */
519
+ serviceName: z.string().optional(),
520
+
521
+ /**
522
+ * The TCP port exposed by the consumer Service.
523
+ *
524
+ * When omitted, the destination endpoint port is used.
525
+ */
526
+ servicePort: portSchema.optional(),
527
+
528
+ /**
529
+ * Whether to expose the consumer Service outside the cluster.
530
+ *
531
+ * The Service type is selected automatically from the cluster configuration.
532
+ */
533
+ external: z.boolean().default(false),
534
+
535
+ /**
536
+ * The Kubernetes type of the control Services used by generated targets.
537
+ */
538
+ proxyServiceType: serviceTypeSchema.default("NodePort"),
539
+
540
+ /**
541
+ * The first fixed NodePort assigned to generated proxy control Services.
542
+ *
543
+ * Replica indexes are added to this value.
544
+ */
545
+ proxyNodePort: portSchema.optional(),
546
+
547
+ /**
548
+ * The raw base pod template inherited by generated proxy and target pods.
549
+ */
550
+ podTemplate: podTemplateSchema,
551
+
552
+ /**
553
+ * The raw pod template merged into generated proxy pods.
554
+ */
555
+ proxyPodTemplate: podTemplateSchema,
556
+
557
+ /**
558
+ * The raw pod template merged into generated target pods.
559
+ */
560
+ targetPodTemplate: podTemplateSchema,
561
+ },
562
+
563
+ inputs: {
564
+ /**
565
+ * The Kubernetes cluster with the Netaminity operator installed.
566
+ */
567
+ k8sCluster: clusterEntity,
568
+
569
+ /**
570
+ * The target TCP endpoints reachable from generated target pods.
571
+ *
572
+ * The first endpoint is used when the endpoint argument is omitted.
573
+ */
574
+ endpoints: {
575
+ entity: l4EndpointEntity,
576
+ multiple: true,
577
+ required: false,
578
+ },
579
+
580
+ /**
581
+ * The existing Kubernetes namespace where the tunnel should be created.
582
+ */
583
+ namespace: {
584
+ entity: namespaceEntity,
585
+ required: false,
586
+ },
587
+ },
588
+
589
+ outputs: {
590
+ /**
591
+ * The created Netaminity tunnel resource.
592
+ */
593
+ tunnel: tunnelEntity,
594
+
595
+ /**
596
+ * The consumer Service created for the tunnel.
597
+ */
598
+ service: serviceEntity,
599
+
600
+ /**
601
+ * The endpoints where consumers can access the tunnel.
602
+ */
603
+ endpoints: {
604
+ entity: l4EndpointEntity,
605
+ multiple: true,
606
+ },
607
+ },
608
+
609
+ meta: {
610
+ title: "Netaminity Tunnel",
611
+ icon: "eos-icons:proxy-outlined",
612
+ iconColor: "#2878A0",
613
+ secondaryIcon: "bitcoin-icons:proxy-filled",
614
+ category: "Network",
615
+ },
616
+
617
+ source: source("tunnel"),
618
+ })
619
+
620
+ /**
621
+ * Creates a replicated Netaminity tunnel across two Kubernetes clusters.
622
+ */
623
+ export const tunnelMc = defineUnit({
624
+ type: "netaminity.tunnel.mc.v1",
625
+
626
+ args: {
627
+ /**
628
+ * The base name of the generated Proxy and Target custom resources.
629
+ *
630
+ * If omitted, the unit name is used.
631
+ */
632
+ resourceName: z.string().optional(),
633
+
634
+ /**
635
+ * The name of the Kubernetes namespace to create in the proxy cluster.
636
+ *
637
+ * Ignored when the proxyNamespace input is provided.
638
+ */
639
+ proxyNamespace: z.string().optional(),
640
+
641
+ /**
642
+ * The name of the Kubernetes namespace to create in the target cluster.
643
+ *
644
+ * Ignored when the targetNamespace input is provided.
645
+ */
646
+ targetNamespace: z.string().optional(),
647
+
648
+ /**
649
+ * The number of Proxy and Target pairs created for the tunnel.
650
+ */
651
+ replicas: replicasSchema,
652
+
653
+ /**
654
+ * The number of interchangeable proxy pods created for each Proxy resource.
655
+ */
656
+ proxyReplicas: replicasSchema,
657
+
658
+ /**
659
+ * Whether generated Proxy and Target pods use their node network namespace.
660
+ */
661
+ hostNetwork: z.boolean().default(false),
662
+
663
+ /**
664
+ * Whether generated Proxy and Target pods prefer distribution across Kubernetes nodes.
665
+ */
666
+ distributeByNodes: z.boolean().default(true),
667
+
668
+ /**
669
+ * The target TCP endpoint reachable from generated Target pods.
670
+ *
671
+ * When omitted, the first endpoint input is used.
672
+ */
673
+ endpoint: z.string().min(3).optional(),
674
+
675
+ /**
676
+ * The name of the shared consumer Service in the proxy cluster.
677
+ *
678
+ * If omitted, the base resource name is used.
679
+ */
680
+ serviceName: z.string().optional(),
681
+
682
+ /**
683
+ * The TCP port exposed by the shared consumer Service.
684
+ *
685
+ * When omitted, the destination endpoint port is used.
686
+ */
687
+ servicePort: portSchema.optional(),
688
+
689
+ /**
690
+ * Whether to expose the shared consumer Service outside the proxy cluster.
691
+ *
692
+ * The Service type is selected automatically from the proxy cluster configuration.
693
+ */
694
+ external: z.boolean().default(false),
695
+
696
+ /**
697
+ * The Kubernetes type of the control Services used by generated Targets.
698
+ */
699
+ proxyServiceType: serviceTypeSchema.default("NodePort"),
700
+
701
+ /**
702
+ * The first fixed NodePort assigned to generated Proxy control Services.
703
+ *
704
+ * Replica indexes are added to this value.
705
+ */
706
+ proxyNodePort: portSchema.optional(),
707
+
708
+ /**
709
+ * The raw base pod template inherited by generated Proxy and Target pods.
710
+ */
711
+ podTemplate: podTemplateSchema,
712
+
713
+ /**
714
+ * The raw pod template merged into generated Proxy pods.
715
+ */
716
+ proxyPodTemplate: podTemplateSchema,
717
+
718
+ /**
719
+ * The raw pod template merged into generated Target pods.
720
+ */
721
+ targetPodTemplate: podTemplateSchema,
722
+ },
723
+
724
+ secrets: {
725
+ /**
726
+ * The shared authentication secret used by every generated Proxy and Target.
727
+ *
728
+ * A random key is generated when omitted.
729
+ */
730
+ sharedSecret: z.string().optional(),
731
+ },
732
+
733
+ inputs: {
734
+ /**
735
+ * The Kubernetes cluster where generated Proxies and the consumer Service are created.
736
+ */
737
+ proxyK8sCluster: clusterEntity,
738
+
739
+ /**
740
+ * The Kubernetes cluster where generated Targets are created.
741
+ */
742
+ targetK8sCluster: clusterEntity,
743
+
744
+ /**
745
+ * The target TCP endpoints reachable from generated Target pods.
746
+ *
747
+ * The first endpoint is used when the endpoint argument is omitted.
748
+ */
749
+ endpoints: {
750
+ entity: l4EndpointEntity,
751
+ multiple: true,
752
+ required: false,
753
+ },
754
+
755
+ /**
756
+ * The existing Kubernetes namespace where Proxies and the consumer Service are created.
757
+ */
758
+ proxyNamespace: {
759
+ entity: namespaceEntity,
760
+ required: false,
761
+ },
762
+
763
+ /**
764
+ * The existing Kubernetes namespace where Targets are created.
765
+ */
766
+ targetNamespace: {
767
+ entity: namespaceEntity,
768
+ required: false,
769
+ },
770
+ },
771
+
772
+ outputs: {
773
+ /**
774
+ * The shared consumer Service created in the proxy cluster.
775
+ */
776
+ service: serviceEntity,
777
+
778
+ /**
779
+ * The endpoints where consumers can access the multi-cluster tunnel.
780
+ */
781
+ endpoints: {
782
+ entity: l4EndpointEntity,
783
+ multiple: true,
784
+ },
785
+ },
786
+
787
+ meta: {
788
+ title: "Netaminity MC Tunnel",
789
+ icon: "eos-icons:proxy-outlined",
790
+ iconColor: "#2878A0",
791
+ secondaryIcon: "bitcoin-icons:proxy-filled",
792
+ category: "Network",
793
+ },
794
+
795
+ source: source("tunnel.mc"),
796
+ })
797
+
798
+ /**
799
+ * Wraps proxy-side and target-side gateways with one shared Netaminity tunnel.
800
+ */
801
+ export const gateway = defineUnit({
802
+ type: "netaminity.gateway.v1",
803
+
804
+ args: {
805
+ /**
806
+ * The name of the generated Netaminity resources.
807
+ *
808
+ * If omitted, the unit name is used.
809
+ */
810
+ resourceName: z.string().optional(),
811
+
812
+ /**
813
+ * The name of the Kubernetes namespace to create in the proxy cluster.
814
+ *
815
+ * Ignored when the proxyNamespace input is provided.
816
+ */
817
+ proxyNamespace: z.string().optional(),
818
+
819
+ /**
820
+ * The name of the Kubernetes namespace to create in the target cluster.
821
+ *
822
+ * Ignored when the targetNamespace input is provided.
823
+ */
824
+ targetNamespace: z.string().optional(),
825
+
826
+ /**
827
+ * The number of Proxy and Target pairs created for the shared tunnel.
828
+ */
829
+ replicas: replicasSchema,
830
+
831
+ /**
832
+ * The number of interchangeable proxy pods created for each Proxy resource.
833
+ */
834
+ proxyReplicas: replicasSchema,
835
+
836
+ /**
837
+ * Whether generated Proxy and Target pods use their node network namespace.
838
+ */
839
+ hostNetwork: z.boolean().default(false),
840
+
841
+ /**
842
+ * Whether generated Proxy and Target pods prefer distribution across Kubernetes nodes.
843
+ */
844
+ distributeByNodes: z.boolean().default(true),
845
+
846
+ /**
847
+ * The TLS port exposed by the target-side gateway.
848
+ */
849
+ targetGatewayPort: portSchema.default(443),
850
+
851
+ /**
852
+ * The Kubernetes type of the control Services used by generated Targets.
853
+ */
854
+ proxyServiceType: serviceTypeSchema.default("NodePort"),
855
+
856
+ /**
857
+ * The first fixed NodePort assigned to generated Proxy control Services.
858
+ *
859
+ * Replica indexes are added to this value.
860
+ */
861
+ proxyNodePort: portSchema.optional(),
862
+
863
+ /**
864
+ * The raw base pod template inherited by generated Proxy and Target pods.
865
+ */
866
+ podTemplate: podTemplateSchema,
867
+
868
+ /**
869
+ * The raw pod template merged into generated Proxy pods.
870
+ */
871
+ proxyPodTemplate: podTemplateSchema,
872
+
873
+ /**
874
+ * The raw pod template merged into generated Target pods.
875
+ */
876
+ targetPodTemplate: podTemplateSchema,
877
+ },
878
+
879
+ secrets: {
880
+ /**
881
+ * The shared authentication secret used by every generated Proxy and Target.
882
+ *
883
+ * A random key is generated when omitted.
884
+ */
885
+ sharedSecret: z.string().optional(),
886
+ },
887
+
888
+ inputs: {
889
+ /**
890
+ * The public gateway in the proxy cluster.
891
+ */
892
+ proxyGateway: gatewayEntity,
893
+
894
+ /**
895
+ * The local gateway in the target cluster.
896
+ */
897
+ targetGateway: gatewayEntity,
898
+
899
+ /**
900
+ * The operator-ready Kubernetes cluster where Proxy resources are created.
901
+ */
902
+ proxyK8sCluster: clusterEntity,
903
+
904
+ /**
905
+ * The operator-ready Kubernetes cluster where Target resources are created.
906
+ */
907
+ targetK8sCluster: clusterEntity,
908
+
909
+ /**
910
+ * The existing Kubernetes namespace where Proxy resources are created.
911
+ */
912
+ proxyNamespace: {
913
+ entity: namespaceEntity,
914
+ required: false,
915
+ },
916
+
917
+ /**
918
+ * The existing Kubernetes namespace where Target resources are created.
919
+ */
920
+ targetNamespace: {
921
+ entity: namespaceEntity,
922
+ required: false,
923
+ },
924
+ },
925
+
926
+ outputs: {
927
+ /**
928
+ * The gateway that delegates termination to the target cluster through Netaminity.
929
+ */
930
+ gateway: gatewayEntity,
931
+ },
932
+
933
+ meta: {
934
+ title: "Netaminity Gateway",
935
+ icon: "eos-icons:proxy-outlined",
936
+ iconColor: "#2878A0",
937
+ secondaryIcon: "bitcoin-icons:proxy-filled",
938
+ category: "Network",
939
+ },
940
+
941
+ source: source("gateway"),
942
+ })
943
+
944
+ export type Proxy = EntityValue<typeof proxyEntity>
945
+ export type ProxyInput = EntityInput<typeof proxyEntity>
946
+ export type Target = EntityValue<typeof targetEntity>
947
+ export type TargetInput = EntityInput<typeof targetEntity>
948
+ export type Tunnel = EntityValue<typeof tunnelEntity>
949
+ export type TunnelInput = EntityInput<typeof tunnelEntity>
950
+ export type GatewayData = z.infer<typeof gatewayDataSchema>