@highstate/library 0.19.1 → 0.21.1
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 +2836 -3440
- package/package.json +12 -12
- package/src/abbreviations.ts +3 -0
- package/src/common/access-point.ts +19 -4
- package/src/common/files.ts +24 -17
- package/src/common/server.ts +19 -6
- package/src/databases/etcd.ts +141 -39
- package/src/databases/index.ts +8 -7
- package/src/databases/influxdb3.ts +103 -0
- package/src/databases/minio.ts +157 -0
- package/src/databases/mongodb.ts +122 -41
- package/src/databases/mysql.ts +172 -0
- package/src/databases/postgresql.ts +133 -40
- package/src/databases/redis.ts +118 -44
- package/src/databases/s3.ts +48 -127
- package/src/dns.ts +11 -7
- package/src/index.ts +3 -1
- package/src/k3s.ts +7 -0
- package/src/k8s/apps/etcd.ts +3 -3
- package/src/k8s/apps/gitea.ts +1 -1
- package/src/k8s/apps/grafana.ts +48 -0
- package/src/k8s/apps/index.ts +4 -2
- package/src/k8s/apps/mariadb.ts +7 -38
- package/src/k8s/apps/matrix-stack.ts +62 -0
- package/src/k8s/apps/minio.ts +38 -45
- package/src/k8s/apps/mongodb.ts +6 -38
- package/src/k8s/apps/portal.ts +27 -0
- package/src/k8s/apps/postgresql.ts +7 -41
- package/src/k8s/apps/refluxdb.ts +49 -0
- package/src/k8s/apps/remnawave.ts +15 -2
- package/src/k8s/apps/shared.ts +16 -15
- package/src/k8s/apps/traefik.ts +5 -0
- package/src/k8s/apps/valkey.ts +5 -5
- package/src/k8s/apps/vaultwarden.ts +2 -6
- package/src/k8s/apps/workload.ts +14 -11
- package/src/k8s/cert-manager.ts +22 -0
- package/src/k8s/cilium.ts +17 -2
- package/src/k8s/resources.ts +41 -9
- package/src/k8s/service.ts +6 -2
- package/src/k8s/shared.ts +49 -18
- package/src/k8s/workload.ts +59 -43
- package/src/network/address-space.ts +30 -7
- package/src/network/address.ts +13 -2
- package/src/network/endpoint-container.ts +235 -0
- package/src/network/endpoint-schema.ts +8 -0
- package/src/network/endpoint.ts +20 -39
- package/src/network/index.ts +1 -1
- package/src/network/subnet.ts +4 -2
- package/src/proxmox.ts +24 -7
- package/src/restic.ts +8 -2
- package/src/ssh.ts +52 -30
- package/src/talos.ts +8 -2
- package/src/third-party/cloudflare.ts +4 -4
- package/src/third-party/timeweb.ts +17 -3
- package/src/third-party/yandex.ts +198 -88
- package/src/tls.ts +22 -0
- package/src/utils.ts +16 -1
- package/src/wireguard.ts +362 -120
- package/LICENSE +0 -21
- package/dist/index.js.map +0 -1
- package/src/databases/mariadb.ts +0 -91
- package/src/databases/shared.ts +0 -67
- package/src/k8s/apps/kubernetes-dashboard.ts +0 -28
- package/src/k8s/apps/maybe.ts +0 -39
- package/src/network/dynamic-endpoint.ts +0 -43
package/src/k8s/apps/shared.ts
CHANGED
|
@@ -12,13 +12,7 @@ import {
|
|
|
12
12
|
} from "@highstate/contract"
|
|
13
13
|
import { mapValues } from "remeda"
|
|
14
14
|
import { accessPointEntity } from "../../common"
|
|
15
|
-
import {
|
|
16
|
-
etcdEntity,
|
|
17
|
-
mariadbEntity,
|
|
18
|
-
mongodbEntity,
|
|
19
|
-
postgresqlEntity,
|
|
20
|
-
redisEntity,
|
|
21
|
-
} from "../../databases"
|
|
15
|
+
import { etcd, mongodb, mysql, postgresql, redis } from "../../databases"
|
|
22
16
|
import { providerEntity } from "../../dns"
|
|
23
17
|
import { repositoryEntity } from "../../restic"
|
|
24
18
|
import { namespaceEntity, persistentVolumeClaimEntity } from "../resources"
|
|
@@ -46,6 +40,13 @@ export const sharedArgs = $args({
|
|
|
46
40
|
* The number of replicas for the application.
|
|
47
41
|
*/
|
|
48
42
|
replicas: z.number().default(1),
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The name of namespace to create for the application.
|
|
46
|
+
*
|
|
47
|
+
* If not provided, defaults to the appName.
|
|
48
|
+
*/
|
|
49
|
+
namespace: z.string().optional(),
|
|
49
50
|
})
|
|
50
51
|
|
|
51
52
|
type ToOptionalArgs<T extends Record<string, FullComponentArgumentOptions>> = Simplify<{
|
|
@@ -80,9 +81,9 @@ export function appName(defaultAppName: string) {
|
|
|
80
81
|
|
|
81
82
|
export const sharedSecrets = $secrets({
|
|
82
83
|
/**
|
|
83
|
-
* The
|
|
84
|
+
* The admin password for the application. If not provided, a random password will be generated.
|
|
84
85
|
*/
|
|
85
|
-
|
|
86
|
+
adminPassword: z.string().optional(),
|
|
86
87
|
|
|
87
88
|
/**
|
|
88
89
|
* The key to use for backup encryption. If not provided, a random key will be generated.
|
|
@@ -135,20 +136,20 @@ export const sharedInputs = $inputs({
|
|
|
135
136
|
volume: {
|
|
136
137
|
entity: persistentVolumeClaimEntity,
|
|
137
138
|
},
|
|
138
|
-
|
|
139
|
-
entity:
|
|
139
|
+
mysql: {
|
|
140
|
+
entity: mysql.connectionEntity,
|
|
140
141
|
},
|
|
141
142
|
postgresql: {
|
|
142
|
-
entity:
|
|
143
|
+
entity: postgresql.connectionEntity,
|
|
143
144
|
},
|
|
144
145
|
mongodb: {
|
|
145
|
-
entity:
|
|
146
|
+
entity: mongodb.connectionEntity,
|
|
146
147
|
},
|
|
147
148
|
redis: {
|
|
148
|
-
entity:
|
|
149
|
+
entity: redis.connectionEntity,
|
|
149
150
|
},
|
|
150
151
|
etcd: {
|
|
151
|
-
entity:
|
|
152
|
+
entity: etcd.connectionEntity,
|
|
152
153
|
},
|
|
153
154
|
})
|
|
154
155
|
|
package/src/k8s/apps/traefik.ts
CHANGED
|
@@ -22,6 +22,11 @@ export const traefik = defineUnit({
|
|
|
22
22
|
*/
|
|
23
23
|
className: z.string().default("traefik"),
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* The node selector to apply to all Traefik pods.
|
|
27
|
+
*/
|
|
28
|
+
nodeSelector: z.record(z.string(), z.string()).default({}),
|
|
29
|
+
|
|
25
30
|
/**
|
|
26
31
|
* Whether to create and enable reconciliation for Traefik CRDs.
|
|
27
32
|
*/
|
package/src/k8s/apps/valkey.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineUnit } from "@highstate/contract"
|
|
2
2
|
import { pick } from "remeda"
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { redis } from "../../databases"
|
|
4
|
+
import { statefulSetEntity } from "../workload"
|
|
5
5
|
import {
|
|
6
6
|
appName,
|
|
7
7
|
optionalSharedInputs,
|
|
@@ -32,8 +32,8 @@ export const valkey = defineUnit({
|
|
|
32
32
|
},
|
|
33
33
|
|
|
34
34
|
outputs: {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
connection: redis.connectionEntity,
|
|
36
|
+
statefulSet: statefulSetEntity,
|
|
37
37
|
},
|
|
38
38
|
|
|
39
39
|
meta: {
|
|
@@ -43,5 +43,5 @@ export const valkey = defineUnit({
|
|
|
43
43
|
category: "Databases",
|
|
44
44
|
},
|
|
45
45
|
|
|
46
|
-
source: source("valkey
|
|
46
|
+
source: source("valkey"),
|
|
47
47
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineUnit
|
|
1
|
+
import { defineUnit } from "@highstate/contract"
|
|
2
2
|
import { pick } from "remeda"
|
|
3
3
|
import { appName, sharedArgs, sharedInputs, source } from "./shared"
|
|
4
4
|
|
|
@@ -13,12 +13,8 @@ export const vaultwarden = defineUnit({
|
|
|
13
13
|
...pick(sharedArgs, ["fqdn"]),
|
|
14
14
|
},
|
|
15
15
|
|
|
16
|
-
secrets: {
|
|
17
|
-
mariadbPassword: z.string().optional(),
|
|
18
|
-
},
|
|
19
|
-
|
|
20
16
|
inputs: {
|
|
21
|
-
...pick(sharedInputs, ["k8sCluster", "accessPoint", "
|
|
17
|
+
...pick(sharedInputs, ["k8sCluster", "accessPoint", "mysql"]),
|
|
22
18
|
},
|
|
23
19
|
|
|
24
20
|
meta: {
|
package/src/k8s/apps/workload.ts
CHANGED
|
@@ -2,8 +2,8 @@ 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 {
|
|
6
|
-
import {
|
|
5
|
+
import { serviceTypeSchema } from "../service"
|
|
6
|
+
import { workloadEntity } from "../workload"
|
|
7
7
|
import { optionalSharedInputs, sharedInputs, source } from "./shared"
|
|
8
8
|
|
|
9
9
|
export const databaseConfigKeySchema = z.enum([
|
|
@@ -123,6 +123,11 @@ export const workload = defineUnit({
|
|
|
123
123
|
*/
|
|
124
124
|
env: z.record(z.string(), environmentVariableSchema).default({}),
|
|
125
125
|
|
|
126
|
+
/**
|
|
127
|
+
* The files to mount in the workload from a config map.
|
|
128
|
+
*/
|
|
129
|
+
files: z.record(z.string(), z.string()).default({}),
|
|
130
|
+
|
|
126
131
|
/**
|
|
127
132
|
* The configuration for the workload.
|
|
128
133
|
*
|
|
@@ -195,19 +200,17 @@ export const workload = defineUnit({
|
|
|
195
200
|
|
|
196
201
|
inputs: {
|
|
197
202
|
...pick(sharedInputs, ["k8sCluster"]),
|
|
198
|
-
...pick(optionalSharedInputs, [
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
]),
|
|
203
|
+
...pick(optionalSharedInputs, ["accessPoint", "resticRepo", "mysql", "postgresql", "mongodb"]),
|
|
204
|
+
|
|
205
|
+
workload: {
|
|
206
|
+
entity: workloadEntity,
|
|
207
|
+
required: false,
|
|
208
|
+
},
|
|
205
209
|
},
|
|
206
210
|
|
|
207
211
|
outputs: {
|
|
208
212
|
namespace: namespaceEntity,
|
|
209
|
-
workload:
|
|
210
|
-
service: serviceEntity,
|
|
213
|
+
workload: workloadEntity,
|
|
211
214
|
},
|
|
212
215
|
|
|
213
216
|
meta: {
|
package/src/k8s/cert-manager.ts
CHANGED
|
@@ -56,6 +56,28 @@ export const certManager = defineUnit({
|
|
|
56
56
|
export const dns01TlsIssuer = defineUnit({
|
|
57
57
|
type: "k8s.dns01-issuer.v1",
|
|
58
58
|
|
|
59
|
+
args: {
|
|
60
|
+
/**
|
|
61
|
+
* The ACME server to use for issuing certificates.
|
|
62
|
+
*/
|
|
63
|
+
acmeServer: z
|
|
64
|
+
.union([
|
|
65
|
+
z.object({
|
|
66
|
+
type: z.enum(["letsencrypt", "zerossl"]),
|
|
67
|
+
}),
|
|
68
|
+
z.object({
|
|
69
|
+
type: z.literal("custom"),
|
|
70
|
+
url: z.string(),
|
|
71
|
+
}),
|
|
72
|
+
])
|
|
73
|
+
.default({ type: "letsencrypt" }),
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
secrets: {
|
|
77
|
+
eabKeyId: z.string().optional(),
|
|
78
|
+
eabKeySecret: z.string().optional(),
|
|
79
|
+
},
|
|
80
|
+
|
|
59
81
|
inputs: {
|
|
60
82
|
k8sCluster: clusterEntity,
|
|
61
83
|
dnsProvider: dns.providerEntity,
|
package/src/k8s/cilium.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineUnit, z } from "@highstate/contract"
|
|
2
|
-
import { clusterEntity } from "./shared"
|
|
2
|
+
import { clusterEntity, tolerationSchema } from "./shared"
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The Cilium CNI deployed on Kubernetes.
|
|
@@ -25,6 +25,21 @@ 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
43
|
},
|
|
29
44
|
|
|
30
45
|
inputs: {
|
|
@@ -49,7 +64,7 @@ export const cilium = defineUnit({
|
|
|
49
64
|
})
|
|
50
65
|
|
|
51
66
|
export const ciliumClusterMetadata = z.object({
|
|
52
|
-
cilium: z.object({
|
|
67
|
+
"cilium.cni": z.object({
|
|
53
68
|
/**
|
|
54
69
|
* If set to `true`, the generated network policy will allow
|
|
55
70
|
* all DNS queries to be resolved, even if they are
|
package/src/k8s/resources.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Simplify, SimplifyDeep } from "type-fest"
|
|
2
|
-
import { defineEntity, type EntityInput, z } from "@highstate/contract"
|
|
2
|
+
import { defineEntity, type EntityInput, type EntityValue, z } from "@highstate/contract"
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The generic metadata schema for Kubernetes resources.
|
|
@@ -46,6 +46,13 @@ export const resourceEntity = defineEntity({
|
|
|
46
46
|
}),
|
|
47
47
|
]),
|
|
48
48
|
),
|
|
49
|
+
|
|
50
|
+
meta: {
|
|
51
|
+
color: "#607D8B",
|
|
52
|
+
title: "Resource",
|
|
53
|
+
icon: "devicon:kubernetes",
|
|
54
|
+
iconColor: "#607D8B",
|
|
55
|
+
},
|
|
49
56
|
})
|
|
50
57
|
|
|
51
58
|
/**
|
|
@@ -59,6 +66,13 @@ export const namespacedResourceEntity = defineEntity({
|
|
|
59
66
|
schema: z.object({
|
|
60
67
|
isNamespaced: z.literal(true),
|
|
61
68
|
}),
|
|
69
|
+
|
|
70
|
+
meta: {
|
|
71
|
+
color: "#78909C",
|
|
72
|
+
title: "Namespaced Resource",
|
|
73
|
+
icon: "devicon:kubernetes",
|
|
74
|
+
iconColor: "#78909C",
|
|
75
|
+
},
|
|
62
76
|
})
|
|
63
77
|
|
|
64
78
|
/**
|
|
@@ -72,6 +86,9 @@ export const namespaceEntity = defineEntity({
|
|
|
72
86
|
|
|
73
87
|
meta: {
|
|
74
88
|
color: "#9E9E9E",
|
|
89
|
+
title: "Namespace",
|
|
90
|
+
icon: "devicon:kubernetes",
|
|
91
|
+
iconColor: "#9E9E9E",
|
|
75
92
|
},
|
|
76
93
|
})
|
|
77
94
|
|
|
@@ -86,6 +103,9 @@ export const persistentVolumeClaimEntity = defineEntity({
|
|
|
86
103
|
|
|
87
104
|
meta: {
|
|
88
105
|
color: "#FFC107",
|
|
106
|
+
title: "Persistent Volume Claim",
|
|
107
|
+
icon: "devicon:kubernetes",
|
|
108
|
+
iconColor: "#FFC107",
|
|
89
109
|
},
|
|
90
110
|
})
|
|
91
111
|
|
|
@@ -100,6 +120,9 @@ export const gatewayEntity = defineEntity({
|
|
|
100
120
|
|
|
101
121
|
meta: {
|
|
102
122
|
color: "#4CAF50",
|
|
123
|
+
title: "Gateway",
|
|
124
|
+
icon: "devicon:kubernetes",
|
|
125
|
+
iconColor: "#4CAF50",
|
|
103
126
|
},
|
|
104
127
|
})
|
|
105
128
|
|
|
@@ -111,6 +134,9 @@ export const certificateEntity = defineEntity({
|
|
|
111
134
|
|
|
112
135
|
meta: {
|
|
113
136
|
color: "#3F51B5",
|
|
137
|
+
title: "Certificate",
|
|
138
|
+
icon: "devicon:kubernetes",
|
|
139
|
+
iconColor: "#3F51B5",
|
|
114
140
|
},
|
|
115
141
|
})
|
|
116
142
|
|
|
@@ -122,6 +148,9 @@ export const configMapEntity = defineEntity({
|
|
|
122
148
|
|
|
123
149
|
meta: {
|
|
124
150
|
color: "#FF9800",
|
|
151
|
+
title: "ConfigMap",
|
|
152
|
+
icon: "devicon:kubernetes",
|
|
153
|
+
iconColor: "#FF9800",
|
|
125
154
|
},
|
|
126
155
|
})
|
|
127
156
|
|
|
@@ -133,31 +162,34 @@ export const secretEntity = defineEntity({
|
|
|
133
162
|
|
|
134
163
|
meta: {
|
|
135
164
|
color: "#9C27B0",
|
|
165
|
+
title: "Secret",
|
|
166
|
+
icon: "devicon:kubernetes",
|
|
167
|
+
iconColor: "#9C27B0",
|
|
136
168
|
},
|
|
137
169
|
})
|
|
138
170
|
|
|
139
171
|
export type Metadata = z.infer<typeof metadataSchema>
|
|
140
|
-
export type Resource =
|
|
172
|
+
export type Resource = EntityValue<typeof resourceEntity>
|
|
141
173
|
export type ResourceInput = EntityInput<typeof resourceEntity>
|
|
142
174
|
|
|
143
175
|
export type NamespacedMetadata = z.infer<typeof namespacedMetadataSchema>
|
|
144
176
|
|
|
145
177
|
export type NamespacedResource = SimplifyDeep<
|
|
146
|
-
|
|
178
|
+
EntityValue<typeof namespacedResourceEntity>,
|
|
147
179
|
Record<string, string>
|
|
148
180
|
>
|
|
149
181
|
|
|
150
182
|
export type NamespacedResourceInput = EntityInput<typeof namespacedResourceEntity>
|
|
151
183
|
|
|
152
|
-
export type Namespace = Simplify<
|
|
184
|
+
export type Namespace = Simplify<EntityValue<typeof namespaceEntity>>
|
|
153
185
|
export type NamespaceInput = EntityInput<typeof namespaceEntity>
|
|
154
|
-
export type PersistentVolumeClaim =
|
|
186
|
+
export type PersistentVolumeClaim = EntityValue<typeof persistentVolumeClaimEntity>
|
|
155
187
|
export type PersistentVolumeClaimInput = EntityInput<typeof persistentVolumeClaimEntity>
|
|
156
|
-
export type Gateway =
|
|
188
|
+
export type Gateway = EntityValue<typeof gatewayEntity>
|
|
157
189
|
export type GatewayInput = EntityInput<typeof gatewayEntity>
|
|
158
|
-
export type Certificate =
|
|
190
|
+
export type Certificate = EntityValue<typeof certificateEntity>
|
|
159
191
|
export type CertificateInput = EntityInput<typeof certificateEntity>
|
|
160
|
-
export type ConfigMap =
|
|
192
|
+
export type ConfigMap = EntityValue<typeof configMapEntity>
|
|
161
193
|
export type ConfigMapInput = EntityInput<typeof configMapEntity>
|
|
162
|
-
export type Secret =
|
|
194
|
+
export type Secret = EntityValue<typeof secretEntity>
|
|
163
195
|
export type SecretInput = EntityInput<typeof secretEntity>
|
package/src/k8s/service.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Simplify } from "type-fest"
|
|
2
|
-
import { defineEntity, type EntityInput, z } from "@highstate/contract"
|
|
2
|
+
import { defineEntity, type EntityInput, type EntityValue, z } from "@highstate/contract"
|
|
3
3
|
import { l4EndpointEntity } from "../network"
|
|
4
4
|
import { namespacedResourceEntity } from "./resources"
|
|
5
5
|
|
|
@@ -58,6 +58,7 @@ export const serviceEntity = defineEntity({
|
|
|
58
58
|
endpoints: {
|
|
59
59
|
entity: l4EndpointEntity,
|
|
60
60
|
multiple: true,
|
|
61
|
+
required: false,
|
|
61
62
|
},
|
|
62
63
|
},
|
|
63
64
|
|
|
@@ -65,6 +66,9 @@ export const serviceEntity = defineEntity({
|
|
|
65
66
|
|
|
66
67
|
meta: {
|
|
67
68
|
color: "#2196F3",
|
|
69
|
+
title: "Service",
|
|
70
|
+
icon: "devicon:kubernetes",
|
|
71
|
+
iconColor: "#2196F3",
|
|
68
72
|
},
|
|
69
73
|
})
|
|
70
74
|
|
|
@@ -73,5 +77,5 @@ export const serviceTypeSchema = z.enum(["NodePort", "LoadBalancer", "ClusterIP"
|
|
|
73
77
|
export type EndpointServiceMetadata = z.infer<typeof serviceEndpointMetadataSchema>
|
|
74
78
|
export type ServiceEndpoint = Simplify<z.infer<typeof serviceEndpointSchema>>
|
|
75
79
|
export type ServiceType = z.infer<typeof serviceTypeSchema>
|
|
76
|
-
export type Service =
|
|
80
|
+
export type Service = EntityValue<typeof serviceEntity>
|
|
77
81
|
export type ServiceInput = EntityInput<typeof serviceEntity>
|
package/src/k8s/shared.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
$args,
|
|
3
|
+
defineEntity,
|
|
4
|
+
defineUnit,
|
|
5
|
+
type EntityInput,
|
|
6
|
+
type EntityValue,
|
|
7
|
+
z,
|
|
8
|
+
} from "@highstate/contract"
|
|
9
|
+
import { fileEntity, serverEntity } from "../common"
|
|
3
10
|
import { implementationReferenceSchema } from "../impl-ref"
|
|
4
11
|
import { addressEntity, l3EndpointEntity, l4EndpointEntity } from "../network"
|
|
5
12
|
import { metadataSchema } from "../utils"
|
|
@@ -78,20 +85,6 @@ export const clusterInfoProperties = {
|
|
|
78
85
|
*/
|
|
79
86
|
networkPolicyImplRef: implementationReferenceSchema.optional(),
|
|
80
87
|
|
|
81
|
-
/**
|
|
82
|
-
* The endpoints of the API server.
|
|
83
|
-
*
|
|
84
|
-
* The entry may represent real node endpoint or virtual endpoint (like a load balancer).
|
|
85
|
-
*
|
|
86
|
-
* The same node may also be represented by multiple entries (e.g. a node with private and public IP).
|
|
87
|
-
*/
|
|
88
|
-
apiEndpoints: l4EndpointEntity.schema.array(),
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* The external IPs of the cluster nodes allowed to be used for external access.
|
|
92
|
-
*/
|
|
93
|
-
externalIps: addressEntity.schema.array(),
|
|
94
|
-
|
|
95
88
|
/**
|
|
96
89
|
* The extra quirks of the cluster to improve compatibility.
|
|
97
90
|
*/
|
|
@@ -107,6 +100,18 @@ export const clusterEntity = defineEntity({
|
|
|
107
100
|
type: "k8s.cluster.v1",
|
|
108
101
|
|
|
109
102
|
includes: {
|
|
103
|
+
/**
|
|
104
|
+
* The endpoints of the API server.
|
|
105
|
+
*
|
|
106
|
+
* The entry may represent real node endpoint or virtual endpoint (like a load balancer).
|
|
107
|
+
*
|
|
108
|
+
* The same node may also be represented by multiple entries (e.g. a node with private and public IP).
|
|
109
|
+
*/
|
|
110
|
+
apiEndpoints: {
|
|
111
|
+
entity: l4EndpointEntity,
|
|
112
|
+
multiple: true,
|
|
113
|
+
},
|
|
114
|
+
|
|
110
115
|
/**
|
|
111
116
|
* The endpoints of the cluster nodes.
|
|
112
117
|
*
|
|
@@ -117,16 +122,33 @@ export const clusterEntity = defineEntity({
|
|
|
117
122
|
endpoints: {
|
|
118
123
|
entity: l3EndpointEntity,
|
|
119
124
|
multiple: true,
|
|
125
|
+
required: false,
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The external IPs of the cluster nodes allowed to be used for external access.
|
|
130
|
+
*/
|
|
131
|
+
externalIps: {
|
|
132
|
+
entity: addressEntity,
|
|
133
|
+
multiple: true,
|
|
134
|
+
required: false,
|
|
120
135
|
},
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The kubeconfig file to use for connecting to the cluster.
|
|
139
|
+
*/
|
|
140
|
+
kubeconfig: fileEntity,
|
|
121
141
|
},
|
|
122
142
|
|
|
123
143
|
schema: z.object({
|
|
124
144
|
...clusterInfoProperties,
|
|
125
|
-
kubeconfig: z.string(),
|
|
126
145
|
}),
|
|
127
146
|
|
|
128
147
|
meta: {
|
|
129
148
|
color: "#2196F3",
|
|
149
|
+
title: "K8S Cluster",
|
|
150
|
+
icon: "devicon:kubernetes",
|
|
151
|
+
iconColor: "#2196F3",
|
|
130
152
|
},
|
|
131
153
|
})
|
|
132
154
|
|
|
@@ -305,10 +327,19 @@ export const monitorWorkerParamsSchema = z.object({
|
|
|
305
327
|
resources: namespacedResourceEntity.schema.array(),
|
|
306
328
|
})
|
|
307
329
|
|
|
308
|
-
export
|
|
330
|
+
export const tolerationSchema = z.object({
|
|
331
|
+
key: z.string().optional(),
|
|
332
|
+
operator: z.enum(["Exists", "Equal"]),
|
|
333
|
+
value: z.string().optional(),
|
|
334
|
+
effect: z.enum(["NoSchedule", "PreferNoSchedule", "NoExecute"]).optional(),
|
|
335
|
+
})
|
|
336
|
+
|
|
337
|
+
export type Cluster = EntityValue<typeof clusterEntity>
|
|
309
338
|
export type ClusterInput = EntityInput<typeof clusterEntity>
|
|
310
339
|
|
|
311
340
|
export type InternalIpsPolicy = z.infer<typeof internalIpsPolicySchema>
|
|
312
341
|
|
|
313
342
|
export type MonitorWorkerParams = z.infer<typeof monitorWorkerParamsSchema>
|
|
314
343
|
export type MonitorWorkerResourceGroup = z.infer<typeof monitorWorkerResourceGroupSchema>
|
|
344
|
+
|
|
345
|
+
export type Toleration = z.infer<typeof tolerationSchema>
|
package/src/k8s/workload.ts
CHANGED
|
@@ -1,19 +1,48 @@
|
|
|
1
|
-
import { defineEntity, type EntityInput, z } from "@highstate/contract"
|
|
2
|
-
import { l4EndpointEntity } from "../network"
|
|
1
|
+
import { defineEntity, type EntityInput, type EntityValue, z } from "@highstate/contract"
|
|
3
2
|
import { namespacedResourceEntity } from "./resources"
|
|
4
3
|
import { serviceEntity } from "./service"
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* The entity which represents a Kubernetes workload.
|
|
7
|
+
*
|
|
8
|
+
* Can optionally include a service associated with the workload.
|
|
8
9
|
*/
|
|
9
10
|
export const workloadEntity = defineEntity({
|
|
10
11
|
type: "k8s.workload.v1",
|
|
11
12
|
|
|
12
13
|
extends: { namespacedResourceEntity },
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
includes: {
|
|
16
|
+
service: {
|
|
17
|
+
entity: serviceEntity,
|
|
18
|
+
required: false,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
schema: z.object({
|
|
23
|
+
spec: z.object({
|
|
24
|
+
template: z.object({
|
|
25
|
+
spec: z.object({
|
|
26
|
+
containers: z.array(
|
|
27
|
+
z.object({
|
|
28
|
+
name: z.string(),
|
|
29
|
+
ports: z.array(
|
|
30
|
+
z.object({
|
|
31
|
+
containerPort: z.number(),
|
|
32
|
+
}),
|
|
33
|
+
),
|
|
34
|
+
}),
|
|
35
|
+
),
|
|
36
|
+
}),
|
|
37
|
+
}),
|
|
38
|
+
}),
|
|
39
|
+
}),
|
|
14
40
|
|
|
15
41
|
meta: {
|
|
16
42
|
color: "#9C27B0",
|
|
43
|
+
title: "Workload",
|
|
44
|
+
icon: "devicon:kubernetes",
|
|
45
|
+
iconColor: "#9C27B0",
|
|
17
46
|
},
|
|
18
47
|
})
|
|
19
48
|
|
|
@@ -29,6 +58,9 @@ export const jobEntity = defineEntity({
|
|
|
29
58
|
|
|
30
59
|
meta: {
|
|
31
60
|
color: "#FF5722",
|
|
61
|
+
title: "Job",
|
|
62
|
+
icon: "devicon:kubernetes",
|
|
63
|
+
iconColor: "#FF5722",
|
|
32
64
|
},
|
|
33
65
|
})
|
|
34
66
|
|
|
@@ -44,35 +76,9 @@ export const cronJobEntity = defineEntity({
|
|
|
44
76
|
|
|
45
77
|
meta: {
|
|
46
78
|
color: "#FF9800",
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* The entity which represents a Kubernetes workload (optionally) exposed via a service.
|
|
52
|
-
*
|
|
53
|
-
* Includes both the workload and its associated service.
|
|
54
|
-
*/
|
|
55
|
-
export const exposableWorkloadEntity = defineEntity({
|
|
56
|
-
type: "k8s.exposable-workload.v1",
|
|
57
|
-
|
|
58
|
-
extends: { workloadEntity },
|
|
59
|
-
|
|
60
|
-
includes: {
|
|
61
|
-
service: {
|
|
62
|
-
entity: serviceEntity,
|
|
63
|
-
required: false,
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
endpoints: {
|
|
67
|
-
entity: l4EndpointEntity,
|
|
68
|
-
multiple: true,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
schema: z.unknown(),
|
|
73
|
-
|
|
74
|
-
meta: {
|
|
75
|
-
color: "#4CAF50",
|
|
79
|
+
title: "CronJob",
|
|
80
|
+
icon: "devicon:kubernetes",
|
|
81
|
+
iconColor: "#FF9800",
|
|
76
82
|
},
|
|
77
83
|
})
|
|
78
84
|
|
|
@@ -84,11 +90,14 @@ export const exposableWorkloadEntity = defineEntity({
|
|
|
84
90
|
export const deploymentEntity = defineEntity({
|
|
85
91
|
type: "k8s.deployment.v1",
|
|
86
92
|
|
|
87
|
-
extends: {
|
|
93
|
+
extends: { workloadEntity },
|
|
88
94
|
schema: z.unknown(),
|
|
89
95
|
|
|
90
96
|
meta: {
|
|
91
97
|
color: "#4CAF50",
|
|
98
|
+
title: "Deployment",
|
|
99
|
+
icon: "devicon:kubernetes",
|
|
100
|
+
iconColor: "#4CAF50",
|
|
92
101
|
},
|
|
93
102
|
})
|
|
94
103
|
|
|
@@ -100,7 +109,7 @@ export const deploymentEntity = defineEntity({
|
|
|
100
109
|
export const statefulSetEntity = defineEntity({
|
|
101
110
|
type: "k8s.stateful-set.v1",
|
|
102
111
|
|
|
103
|
-
extends: {
|
|
112
|
+
extends: { workloadEntity },
|
|
104
113
|
|
|
105
114
|
includes: {
|
|
106
115
|
service: serviceEntity,
|
|
@@ -110,6 +119,9 @@ export const statefulSetEntity = defineEntity({
|
|
|
110
119
|
|
|
111
120
|
meta: {
|
|
112
121
|
color: "#FFC107",
|
|
122
|
+
title: "Stateful Set",
|
|
123
|
+
icon: "devicon:kubernetes",
|
|
124
|
+
iconColor: "#FFC107",
|
|
113
125
|
},
|
|
114
126
|
})
|
|
115
127
|
|
|
@@ -119,27 +131,31 @@ export const statefulSetEntity = defineEntity({
|
|
|
119
131
|
export const networkInterfaceEntity = defineEntity({
|
|
120
132
|
type: "k8s.network-interface.v1",
|
|
121
133
|
|
|
134
|
+
includes: {
|
|
135
|
+
workload: workloadEntity,
|
|
136
|
+
},
|
|
137
|
+
|
|
122
138
|
schema: z.object({
|
|
123
139
|
name: z.string(),
|
|
124
|
-
workload: workloadEntity.schema,
|
|
125
140
|
}),
|
|
126
141
|
|
|
127
142
|
meta: {
|
|
128
143
|
color: "#2196F3",
|
|
144
|
+
title: "Network Interface",
|
|
145
|
+
icon: "devicon:kubernetes",
|
|
146
|
+
iconColor: "#2196F3",
|
|
129
147
|
},
|
|
130
148
|
})
|
|
131
149
|
|
|
132
|
-
export type Workload =
|
|
150
|
+
export type Workload = EntityValue<typeof workloadEntity>
|
|
133
151
|
export type WorkloadInput = EntityInput<typeof workloadEntity>
|
|
134
|
-
export type Job =
|
|
152
|
+
export type Job = EntityValue<typeof jobEntity>
|
|
135
153
|
export type JobInput = EntityInput<typeof jobEntity>
|
|
136
|
-
export type CronJob =
|
|
154
|
+
export type CronJob = EntityValue<typeof cronJobEntity>
|
|
137
155
|
export type CronJobInput = EntityInput<typeof cronJobEntity>
|
|
138
|
-
export type
|
|
139
|
-
export type ExposableWorkloadInput = EntityInput<typeof exposableWorkloadEntity>
|
|
140
|
-
export type Deployment = z.infer<typeof deploymentEntity.schema>
|
|
156
|
+
export type Deployment = EntityValue<typeof deploymentEntity>
|
|
141
157
|
export type DeploymentInput = EntityInput<typeof deploymentEntity>
|
|
142
|
-
export type StatefulSet =
|
|
158
|
+
export type StatefulSet = EntityValue<typeof statefulSetEntity>
|
|
143
159
|
export type StatefulSetInput = EntityInput<typeof statefulSetEntity>
|
|
144
|
-
export type NetworkInterface =
|
|
160
|
+
export type NetworkInterface = EntityValue<typeof networkInterfaceEntity>
|
|
145
161
|
export type NetworkInterfaceInput = EntityInput<typeof networkInterfaceEntity>
|