@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
package/src/k8s/apps/workload.ts
CHANGED
|
@@ -2,9 +2,15 @@ import { defineUnit, z } from "@highstate/contract"
|
|
|
2
2
|
import { pick } from "remeda"
|
|
3
3
|
import { portSchema } from "../../network"
|
|
4
4
|
import { namespaceEntity } from "../resources"
|
|
5
|
-
import { serviceTypeSchema } from "../service"
|
|
6
5
|
import { workloadEntity } from "../workload"
|
|
7
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
optionalSharedInputs,
|
|
8
|
+
schedulingArg,
|
|
9
|
+
serviceArg,
|
|
10
|
+
sharedArgs,
|
|
11
|
+
sharedInputs,
|
|
12
|
+
source,
|
|
13
|
+
} from "./shared"
|
|
8
14
|
|
|
9
15
|
export const databaseConfigKeySchema = z.enum([
|
|
10
16
|
"url",
|
|
@@ -60,6 +66,10 @@ export const workload = defineUnit({
|
|
|
60
66
|
*/
|
|
61
67
|
existingNamespace: z.string().optional(),
|
|
62
68
|
|
|
69
|
+
...pick(sharedArgs, ["external"]),
|
|
70
|
+
...serviceArg,
|
|
71
|
+
...schedulingArg,
|
|
72
|
+
|
|
63
73
|
/**
|
|
64
74
|
* The type of the workload to create.
|
|
65
75
|
*/
|
|
@@ -91,11 +101,6 @@ export const workload = defineUnit({
|
|
|
91
101
|
*/
|
|
92
102
|
fqdn: z.string().optional(),
|
|
93
103
|
|
|
94
|
-
/**
|
|
95
|
-
* The type of the service to create for the workload.
|
|
96
|
-
*/
|
|
97
|
-
serviceType: serviceTypeSchema.default("ClusterIP"),
|
|
98
|
-
|
|
99
104
|
/**
|
|
100
105
|
* The number of replicas for the workload.
|
|
101
106
|
*
|
|
@@ -144,13 +149,6 @@ export const workload = defineUnit({
|
|
|
144
149
|
*/
|
|
145
150
|
manifest: z.record(z.string(), z.unknown()).default({}),
|
|
146
151
|
|
|
147
|
-
/**
|
|
148
|
-
* The Kubernetes service manifest for the deployment.
|
|
149
|
-
*
|
|
150
|
-
* Will be applied to the service manifest before it is created.
|
|
151
|
-
*/
|
|
152
|
-
serviceManifest: z.record(z.string(), z.unknown()).default({}),
|
|
153
|
-
|
|
154
152
|
/**
|
|
155
153
|
* The Kubernetes HTTP route manifest for the deployment.
|
|
156
154
|
*
|
package/src/k8s/cert-manager.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { defineUnit, z } from "@highstate/contract"
|
|
2
|
+
import * as vault from "../apps/vault"
|
|
2
3
|
import { tlsIssuerEntity } from "../common"
|
|
3
4
|
import * as dns from "../dns"
|
|
4
|
-
import { clusterEntity } from "./shared"
|
|
5
|
+
import { clusterEntity, helmExtensionArgs, schedulingArg } from "./shared"
|
|
5
6
|
|
|
6
7
|
export const tlsIssuerDataSchema = z.object({
|
|
7
8
|
/**
|
|
@@ -22,6 +23,9 @@ export const certManager = defineUnit({
|
|
|
22
23
|
type: "k8s.cert-manager.v1",
|
|
23
24
|
|
|
24
25
|
args: {
|
|
26
|
+
...helmExtensionArgs,
|
|
27
|
+
...schedulingArg,
|
|
28
|
+
|
|
25
29
|
/**
|
|
26
30
|
* Whether to enable the native support for Gateway API in cert-manager.
|
|
27
31
|
*
|
|
@@ -89,7 +93,9 @@ export const dns01TlsIssuer = defineUnit({
|
|
|
89
93
|
|
|
90
94
|
meta: {
|
|
91
95
|
title: "DNS01 Issuer",
|
|
92
|
-
icon: "
|
|
96
|
+
icon: "iconoir:dns",
|
|
97
|
+
iconColor: "#2196F3",
|
|
98
|
+
secondaryIcon: "mdi:certificate",
|
|
93
99
|
category: "Kubernetes",
|
|
94
100
|
},
|
|
95
101
|
|
|
@@ -99,4 +105,40 @@ export const dns01TlsIssuer = defineUnit({
|
|
|
99
105
|
},
|
|
100
106
|
})
|
|
101
107
|
|
|
108
|
+
/**
|
|
109
|
+
* The Vault TLS issuer for issuing certificates using a Vault PKI backend.
|
|
110
|
+
*/
|
|
111
|
+
export const vaultTlsIssuer = defineUnit({
|
|
112
|
+
type: "k8s.vault-issuer.v1",
|
|
113
|
+
|
|
114
|
+
inputs: {
|
|
115
|
+
/**
|
|
116
|
+
* The Kubernetes cluster where the Vault issuer should be configured.
|
|
117
|
+
*/
|
|
118
|
+
k8sCluster: clusterEntity,
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The Vault PKI issuer to use for issuing certificates.
|
|
122
|
+
*/
|
|
123
|
+
vaultPkiIssuer: vault.pkiIssuerEntity,
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
outputs: {
|
|
127
|
+
tlsIssuer: tlsIssuerEntity,
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
meta: {
|
|
131
|
+
title: "Vault Issuer",
|
|
132
|
+
icon: "simple-icons:vault",
|
|
133
|
+
iconColor: "#2196F3",
|
|
134
|
+
secondaryIcon: "mdi:certificate",
|
|
135
|
+
category: "Kubernetes",
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
source: {
|
|
139
|
+
package: "@highstate/k8s",
|
|
140
|
+
path: "units/vault-issuer",
|
|
141
|
+
},
|
|
142
|
+
})
|
|
143
|
+
|
|
102
144
|
export type TlsIssuerData = z.infer<typeof tlsIssuerDataSchema>
|
package/src/k8s/cilium.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineUnit, z } from "@highstate/contract"
|
|
2
|
-
import { clusterEntity,
|
|
2
|
+
import { clusterEntity, helmExtensionArgs, schedulingArg } from "./shared"
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The Cilium CNI deployed on Kubernetes.
|
|
@@ -25,21 +25,8 @@ export const cilium = defineUnit({
|
|
|
25
25
|
* To expose the Hubble UI, you can use `k8s.apps.hubble-ui` unit.
|
|
26
26
|
*/
|
|
27
27
|
enableHubble: z.boolean().default(true),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* The tolerations of the cilium agent in the cluster.
|
|
31
|
-
*/
|
|
32
|
-
agentTolerations: tolerationSchema.array().optional(),
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* The tolerations of the cilium envoy in the cluster.
|
|
36
|
-
*/
|
|
37
|
-
envoyTolerations: tolerationSchema.array().optional(),
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The tolerations of the cilium operator in the cluster.
|
|
41
|
-
*/
|
|
42
|
-
operatorTolerations: tolerationSchema.array().optional(),
|
|
28
|
+
...helmExtensionArgs,
|
|
29
|
+
...schedulingArg,
|
|
43
30
|
},
|
|
44
31
|
|
|
45
32
|
inputs: {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { defineUnit, z } from "@highstate/contract"
|
|
2
|
+
import { clusterEntity, schedulingArg } from "./shared"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The CoreDNS cluster DNS service installed on the Kubernetes cluster.
|
|
6
|
+
*/
|
|
7
|
+
export const coreDns = defineUnit({
|
|
8
|
+
type: "k8s.coredns.v1",
|
|
9
|
+
|
|
10
|
+
args: {
|
|
11
|
+
...schedulingArg,
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The mode to use for CoreDNS deployment.
|
|
15
|
+
*
|
|
16
|
+
* `cluster` creates a regular Deployment with a small replica count.
|
|
17
|
+
* It is the default Kubernetes model and fits clusters with reliable pod/service networking between nodes.
|
|
18
|
+
*
|
|
19
|
+
* `node` creates a DaemonSet and configures the DNS Service to route only to node-local endpoints.
|
|
20
|
+
* It fits edge, NATed, or partitioned clusters where each node should answer DNS locally and avoid cross-node DNS traffic.
|
|
21
|
+
*/
|
|
22
|
+
mode: z.enum(["cluster", "node"]).default("cluster"),
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The Kubernetes cluster DNS domain served by CoreDNS.
|
|
26
|
+
*/
|
|
27
|
+
clusterDomain: z.string().default("cluster.local"),
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The stable Service IP to reserve for cluster DNS.
|
|
31
|
+
*
|
|
32
|
+
* The default matches the common K3s service CIDR.
|
|
33
|
+
*/
|
|
34
|
+
clusterIP: z.string().default("10.43.0.10"),
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Whether CoreDNS should connect through the best external Kubernetes API endpoint.
|
|
38
|
+
*
|
|
39
|
+
* By default, CoreDNS uses the in-cluster Kubernetes service endpoint.
|
|
40
|
+
*/
|
|
41
|
+
useExternalKubeApi: z.boolean().default(false),
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
inputs: {
|
|
45
|
+
k8sCluster: clusterEntity,
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
outputs: {
|
|
49
|
+
k8sCluster: clusterEntity,
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
meta: {
|
|
53
|
+
title: "CoreDNS",
|
|
54
|
+
icon: "selfhst:coredns-light",
|
|
55
|
+
category: "Kubernetes",
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
source: {
|
|
59
|
+
package: "@highstate/k8s",
|
|
60
|
+
path: "units/coredns",
|
|
61
|
+
},
|
|
62
|
+
})
|
package/src/k8s/gateway.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { defineUnit, z } from "@highstate/contract"
|
|
2
|
+
import { implementationReferenceSchema } from "../impl-ref"
|
|
2
3
|
import { namespaceEntity } from "./resources"
|
|
3
4
|
import { clusterEntity } from "./shared"
|
|
4
5
|
|
|
6
|
+
const semverVersionSchema = z
|
|
7
|
+
.string()
|
|
8
|
+
.regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/)
|
|
9
|
+
|
|
5
10
|
export const gatewayDataSchema = z.object({
|
|
6
11
|
/**
|
|
7
12
|
* The Kubernetes cluster to use for creating gateway routes.
|
|
@@ -31,6 +36,11 @@ export const gatewayDataSchema = z.object({
|
|
|
31
36
|
* If not provided, defaults to 443.
|
|
32
37
|
*/
|
|
33
38
|
httpsPort: z.number().default(443),
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The nested implementation reference for the Gateway API controller.
|
|
42
|
+
*/
|
|
43
|
+
controllerImplRef: implementationReferenceSchema.optional(),
|
|
34
44
|
})
|
|
35
45
|
|
|
36
46
|
export const gatewayImplRefSchema = z.object({
|
|
@@ -44,6 +54,21 @@ export const gatewayImplRefSchema = z.object({
|
|
|
44
54
|
export const gatewayApi = defineUnit({
|
|
45
55
|
type: "k8s.gateway-api.v1",
|
|
46
56
|
|
|
57
|
+
args: {
|
|
58
|
+
/**
|
|
59
|
+
* The Gateway API release channel to install.
|
|
60
|
+
*/
|
|
61
|
+
channel: z.enum(["stable", "experimental"]).default("stable"),
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The Gateway API version to install.
|
|
65
|
+
*
|
|
66
|
+
* Defaults to the latest stable version when using the stable channel.
|
|
67
|
+
* Must be specified when using the experimental channel.
|
|
68
|
+
*/
|
|
69
|
+
version: semverVersionSchema.optional(),
|
|
70
|
+
},
|
|
71
|
+
|
|
47
72
|
inputs: {
|
|
48
73
|
k8sCluster: clusterEntity,
|
|
49
74
|
},
|
package/src/k8s/index.ts
CHANGED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { $args, z } from "@highstate/contract"
|
|
2
|
+
|
|
3
|
+
export const labelSelectorRequirementSchema = z.object({
|
|
4
|
+
key: z.string(),
|
|
5
|
+
operator: z.enum(["DoesNotExist", "Exists", "In", "NotIn"]),
|
|
6
|
+
values: z.string().array().optional(),
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export const labelSelectorSchema = z.object({
|
|
10
|
+
matchExpressions: labelSelectorRequirementSchema.array().optional(),
|
|
11
|
+
matchLabels: z.record(z.string(), z.string()).optional(),
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
export const nodeSelectorRequirementSchema = z.object({
|
|
15
|
+
key: z.string(),
|
|
16
|
+
operator: z.enum(["DoesNotExist", "Exists", "Gt", "In", "Lt", "NotIn"]),
|
|
17
|
+
values: z.string().array().optional(),
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
export const nodeSelectorTermSchema = z.object({
|
|
21
|
+
matchExpressions: nodeSelectorRequirementSchema.array().optional(),
|
|
22
|
+
matchFields: nodeSelectorRequirementSchema.array().optional(),
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
export const nodeAffinitySchema = z.object({
|
|
26
|
+
preferredDuringSchedulingIgnoredDuringExecution: z
|
|
27
|
+
.object({
|
|
28
|
+
preference: nodeSelectorTermSchema,
|
|
29
|
+
weight: z.number(),
|
|
30
|
+
})
|
|
31
|
+
.array()
|
|
32
|
+
.optional(),
|
|
33
|
+
requiredDuringSchedulingIgnoredDuringExecution: z
|
|
34
|
+
.object({
|
|
35
|
+
nodeSelectorTerms: nodeSelectorTermSchema.array(),
|
|
36
|
+
})
|
|
37
|
+
.optional(),
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
export const podAffinityTermSchema = z.object({
|
|
41
|
+
labelSelector: labelSelectorSchema.optional(),
|
|
42
|
+
matchLabelKeys: z.string().array().optional(),
|
|
43
|
+
mismatchLabelKeys: z.string().array().optional(),
|
|
44
|
+
namespaceSelector: labelSelectorSchema.optional(),
|
|
45
|
+
namespaces: z.string().array().optional(),
|
|
46
|
+
topologyKey: z.string(),
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
export const podAffinitySchema = z.object({
|
|
50
|
+
preferredDuringSchedulingIgnoredDuringExecution: z
|
|
51
|
+
.object({
|
|
52
|
+
podAffinityTerm: podAffinityTermSchema,
|
|
53
|
+
weight: z.number(),
|
|
54
|
+
})
|
|
55
|
+
.array()
|
|
56
|
+
.optional(),
|
|
57
|
+
requiredDuringSchedulingIgnoredDuringExecution: podAffinityTermSchema.array().optional(),
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
export const affinitySchema = z.object({
|
|
61
|
+
nodeAffinity: nodeAffinitySchema.optional(),
|
|
62
|
+
podAffinity: podAffinitySchema.optional(),
|
|
63
|
+
podAntiAffinity: podAffinitySchema.optional(),
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
export const tolerationSchema = z.object({
|
|
67
|
+
effect: z.enum(["NoExecute", "NoSchedule", "PreferNoSchedule"]).optional(),
|
|
68
|
+
key: z.string().optional(),
|
|
69
|
+
operator: z.enum(["Equal", "Exists"]).optional(),
|
|
70
|
+
tolerationSeconds: z.number().optional(),
|
|
71
|
+
value: z.string().optional(),
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
export const schedulingSchema = z.object({
|
|
75
|
+
affinity: affinitySchema.optional(),
|
|
76
|
+
nodeSelector: z.record(z.string(), z.string()).optional(),
|
|
77
|
+
tolerations: tolerationSchema.array().optional(),
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
export const schedulingArg = $args({
|
|
81
|
+
/**
|
|
82
|
+
* The Kubernetes scheduling options to apply to every pod created by the unit.
|
|
83
|
+
*/
|
|
84
|
+
scheduling: schedulingSchema.default({}).meta({ complex: true }),
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
export type Scheduling = z.infer<typeof schedulingSchema>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { $args, z } from "@highstate/contract"
|
|
2
|
+
|
|
3
|
+
export const managedFieldsEntrySchema = z.object({
|
|
4
|
+
apiVersion: z.string().optional(),
|
|
5
|
+
fieldsType: z.string().optional(),
|
|
6
|
+
fieldsV1: z.unknown().optional(),
|
|
7
|
+
manager: z.string().optional(),
|
|
8
|
+
operation: z.string().optional(),
|
|
9
|
+
subresource: z.string().optional(),
|
|
10
|
+
time: z.string().optional(),
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const ownerReferenceSchema = z.object({
|
|
14
|
+
apiVersion: z.string(),
|
|
15
|
+
blockOwnerDeletion: z.boolean().optional(),
|
|
16
|
+
controller: z.boolean().optional(),
|
|
17
|
+
kind: z.string(),
|
|
18
|
+
name: z.string(),
|
|
19
|
+
uid: z.string(),
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
export const objectMetaSchema = z.object({
|
|
23
|
+
annotations: z.record(z.string(), z.string()).optional(),
|
|
24
|
+
creationTimestamp: z.string().optional(),
|
|
25
|
+
deletionGracePeriodSeconds: z.number().optional(),
|
|
26
|
+
deletionTimestamp: z.string().optional(),
|
|
27
|
+
finalizers: z.string().array().optional(),
|
|
28
|
+
generateName: z.string().optional(),
|
|
29
|
+
generation: z.number().optional(),
|
|
30
|
+
labels: z.record(z.string(), z.string()).optional(),
|
|
31
|
+
managedFields: managedFieldsEntrySchema.array().optional(),
|
|
32
|
+
name: z.string().optional(),
|
|
33
|
+
namespace: z.string().optional(),
|
|
34
|
+
ownerReferences: ownerReferenceSchema.array().optional(),
|
|
35
|
+
resourceVersion: z.string().optional(),
|
|
36
|
+
selfLink: z.string().optional(),
|
|
37
|
+
uid: z.string().optional(),
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
export const servicePortSchema = z.object({
|
|
41
|
+
appProtocol: z.string().optional(),
|
|
42
|
+
name: z.string().optional(),
|
|
43
|
+
nodePort: z.number().optional(),
|
|
44
|
+
port: z.number(),
|
|
45
|
+
protocol: z.enum(["SCTP", "TCP", "UDP"]).optional(),
|
|
46
|
+
targetPort: z.union([z.number(), z.string()]).optional(),
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
export const sessionAffinityConfigSchema = z.object({
|
|
50
|
+
clientIP: z
|
|
51
|
+
.object({
|
|
52
|
+
timeoutSeconds: z.number().optional(),
|
|
53
|
+
})
|
|
54
|
+
.optional(),
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
export const serviceArgsSchema = z.object({
|
|
58
|
+
/**
|
|
59
|
+
* The name of the service.
|
|
60
|
+
*/
|
|
61
|
+
name: z.string().optional(),
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The metadata to apply to the service.
|
|
65
|
+
*/
|
|
66
|
+
metadata: objectMetaSchema.optional(),
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The port to expose the service on.
|
|
70
|
+
*/
|
|
71
|
+
port: servicePortSchema.optional(),
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Whether the service should be exposed by NodePort or LoadBalancer.
|
|
75
|
+
*/
|
|
76
|
+
external: z.boolean().optional(),
|
|
77
|
+
|
|
78
|
+
allocateLoadBalancerNodePorts: z.boolean().optional(),
|
|
79
|
+
clusterIP: z.string().optional(),
|
|
80
|
+
clusterIPs: z.string().array().optional(),
|
|
81
|
+
externalIPs: z.string().array().optional(),
|
|
82
|
+
externalName: z.string().optional(),
|
|
83
|
+
externalTrafficPolicy: z.enum(["Cluster", "Local"]).optional(),
|
|
84
|
+
healthCheckNodePort: z.number().optional(),
|
|
85
|
+
internalTrafficPolicy: z.enum(["Cluster", "Local"]).optional(),
|
|
86
|
+
ipFamilies: z.enum(["IPv4", "IPv6"]).array().optional(),
|
|
87
|
+
ipFamilyPolicy: z.enum(["PreferDualStack", "RequireDualStack", "SingleStack"]).optional(),
|
|
88
|
+
loadBalancerClass: z.string().optional(),
|
|
89
|
+
loadBalancerIP: z.string().optional(),
|
|
90
|
+
loadBalancerSourceRanges: z.string().array().optional(),
|
|
91
|
+
ports: servicePortSchema.array().optional(),
|
|
92
|
+
publishNotReadyAddresses: z.boolean().optional(),
|
|
93
|
+
selector: z.record(z.string(), z.string()).optional(),
|
|
94
|
+
sessionAffinity: z.enum(["ClientIP", "None"]).optional(),
|
|
95
|
+
sessionAffinityConfig: sessionAffinityConfigSchema.optional(),
|
|
96
|
+
trafficDistribution: z.string().optional(),
|
|
97
|
+
type: z.enum(["ClusterIP", "ExternalName", "LoadBalancer", "NodePort"]).optional(),
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
export const serviceArg = $args({
|
|
101
|
+
/**
|
|
102
|
+
* The extra arguments to apply to the component service.
|
|
103
|
+
*
|
|
104
|
+
* Accepts Kubernetes Service spec fields and Highstate service helper arguments.
|
|
105
|
+
*/
|
|
106
|
+
service: serviceArgsSchema.default({}).meta({ complex: true }),
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
export type ServiceArgs = z.infer<typeof serviceArgsSchema>
|
package/src/k8s/shared.ts
CHANGED
|
@@ -12,6 +12,9 @@ import { addressEntity, l3EndpointEntity, l4EndpointEntity } from "../network"
|
|
|
12
12
|
import { metadataSchema } from "../utils"
|
|
13
13
|
import { namespacedResourceEntity } from "./resources"
|
|
14
14
|
|
|
15
|
+
export { type Scheduling, schedulingArg, schedulingSchema } from "./scheduling"
|
|
16
|
+
export { type ServiceArgs, serviceArg, serviceArgsSchema } from "./service-args"
|
|
17
|
+
|
|
15
18
|
export const fallbackKubeApiAccessSchema = z.object({
|
|
16
19
|
serverIp: z.string(),
|
|
17
20
|
serverPort: z.number(),
|
|
@@ -31,6 +34,29 @@ export const tunDevicePolicySchema = z.discriminatedUnion("type", [
|
|
|
31
34
|
export const externalServiceTypeSchema = z.enum(["NodePort", "LoadBalancer"])
|
|
32
35
|
export const scheduleOnMastersPolicySchema = z.enum(["always", "when-no-workers", "never"])
|
|
33
36
|
|
|
37
|
+
export const jsonPatchOperationSchema = z.discriminatedUnion("op", [
|
|
38
|
+
z.object({ op: z.literal("add"), path: z.string(), value: z.unknown() }),
|
|
39
|
+
z.object({ op: z.literal("remove"), path: z.string() }),
|
|
40
|
+
z.object({ op: z.literal("replace"), path: z.string(), value: z.unknown() }),
|
|
41
|
+
z.object({ op: z.literal("move"), path: z.string(), from: z.string() }),
|
|
42
|
+
z.object({ op: z.literal("copy"), path: z.string(), from: z.string() }),
|
|
43
|
+
z.object({ op: z.literal("test"), path: z.string(), value: z.unknown() }),
|
|
44
|
+
])
|
|
45
|
+
|
|
46
|
+
export const helmExtensionArgs = $args({
|
|
47
|
+
/**
|
|
48
|
+
* The values to deep merge over the component-provided Helm values.
|
|
49
|
+
*/
|
|
50
|
+
values: z.record(z.string(), z.unknown()).default({}).meta({ complex: true }),
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The JSON Patch operations to apply to the merged Helm values in order.
|
|
54
|
+
*/
|
|
55
|
+
patches: jsonPatchOperationSchema.array().default([]).meta({ complex: true }),
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
export type JsonPatchOperation = z.infer<typeof jsonPatchOperationSchema>
|
|
59
|
+
|
|
34
60
|
export const clusterQuirksSchema = z.object({
|
|
35
61
|
/**
|
|
36
62
|
* The IP and port of the kube-apiserver available from the cluster.
|
package/src/k8s/workload.ts
CHANGED
|
@@ -101,6 +101,25 @@ export const deploymentEntity = defineEntity({
|
|
|
101
101
|
},
|
|
102
102
|
})
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* The entity which represents a Kubernetes daemon set managed by Highstate.
|
|
106
|
+
*
|
|
107
|
+
* Also includes a service associated with the daemon set.
|
|
108
|
+
*/
|
|
109
|
+
export const daemonSetEntity = defineEntity({
|
|
110
|
+
type: "k8s.daemon-set.v1",
|
|
111
|
+
|
|
112
|
+
extends: { workloadEntity },
|
|
113
|
+
schema: z.unknown(),
|
|
114
|
+
|
|
115
|
+
meta: {
|
|
116
|
+
color: "#2196F3",
|
|
117
|
+
title: "Daemon Set",
|
|
118
|
+
icon: "devicon:kubernetes",
|
|
119
|
+
iconColor: "#2196F3",
|
|
120
|
+
},
|
|
121
|
+
})
|
|
122
|
+
|
|
104
123
|
/**
|
|
105
124
|
* The entity which represents a Kubernetes stateful set managed by Highstate.
|
|
106
125
|
*
|
|
@@ -155,6 +174,8 @@ export type CronJob = EntityValue<typeof cronJobEntity>
|
|
|
155
174
|
export type CronJobInput = EntityInput<typeof cronJobEntity>
|
|
156
175
|
export type Deployment = EntityValue<typeof deploymentEntity>
|
|
157
176
|
export type DeploymentInput = EntityInput<typeof deploymentEntity>
|
|
177
|
+
export type DaemonSet = EntityValue<typeof daemonSetEntity>
|
|
178
|
+
export type DaemonSetInput = EntityInput<typeof daemonSetEntity>
|
|
158
179
|
export type StatefulSet = EntityValue<typeof statefulSetEntity>
|
|
159
180
|
export type StatefulSetInput = EntityInput<typeof statefulSetEntity>
|
|
160
181
|
export type NetworkInterface = EntityValue<typeof networkInterfaceEntity>
|