@highstate/library 0.18.0 → 0.20.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 (65) hide show
  1. package/dist/highstate.library.msgpack +0 -0
  2. package/dist/index.js +2314 -1141
  3. package/dist/index.js.map +1 -1
  4. package/package.json +3 -3
  5. package/src/abbreviations.ts +3 -0
  6. package/src/common/access-point.ts +23 -4
  7. package/src/common/files.ts +27 -17
  8. package/src/common/server.ts +28 -7
  9. package/src/databases/etcd.ts +142 -37
  10. package/src/databases/index.ts +8 -7
  11. package/src/databases/influxdb3.ts +103 -0
  12. package/src/databases/minio.ts +157 -0
  13. package/src/databases/mongodb.ts +122 -40
  14. package/src/databases/mysql.ts +172 -0
  15. package/src/databases/postgresql.ts +133 -39
  16. package/src/databases/redis.ts +118 -43
  17. package/src/databases/s3.ts +49 -126
  18. package/src/dns.ts +12 -7
  19. package/src/index.ts +1 -1
  20. package/src/k3s.ts +7 -0
  21. package/src/k8s/apps/etcd.ts +3 -3
  22. package/src/k8s/apps/gitea.ts +1 -1
  23. package/src/k8s/apps/grafana.ts +48 -0
  24. package/src/k8s/apps/index.ts +4 -2
  25. package/src/k8s/apps/mariadb.ts +7 -38
  26. package/src/k8s/apps/matrix-stack.ts +62 -0
  27. package/src/k8s/apps/minio.ts +38 -45
  28. package/src/k8s/apps/mongodb.ts +6 -38
  29. package/src/k8s/apps/portal.ts +27 -0
  30. package/src/k8s/apps/postgresql.ts +7 -41
  31. package/src/k8s/apps/refluxdb.ts +49 -0
  32. package/src/k8s/apps/remnawave.ts +17 -1
  33. package/src/k8s/apps/shared.ts +16 -15
  34. package/src/k8s/apps/traefik.ts +5 -0
  35. package/src/k8s/apps/valkey.ts +5 -5
  36. package/src/k8s/apps/vaultwarden.ts +2 -6
  37. package/src/k8s/apps/workload.ts +14 -11
  38. package/src/k8s/cert-manager.ts +22 -0
  39. package/src/k8s/cilium.ts +17 -2
  40. package/src/k8s/resources.ts +50 -9
  41. package/src/k8s/service.ts +7 -2
  42. package/src/k8s/shared.ts +50 -18
  43. package/src/k8s/workload.ts +65 -42
  44. package/src/network/address-space.ts +17 -7
  45. package/src/network/address.ts +14 -2
  46. package/src/network/endpoint-container.ts +235 -0
  47. package/src/network/endpoint-schema.ts +8 -0
  48. package/src/network/endpoint.ts +23 -39
  49. package/src/network/index.ts +1 -1
  50. package/src/network/subnet.ts +5 -2
  51. package/src/proxmox.ts +27 -7
  52. package/src/restic.ts +9 -2
  53. package/src/ssh.ts +63 -31
  54. package/src/talos.ts +10 -1
  55. package/src/third-party/cloudflare.ts +4 -4
  56. package/src/third-party/timeweb.ts +18 -3
  57. package/src/third-party/yandex.ts +203 -86
  58. package/src/tls.ts +22 -0
  59. package/src/utils.ts +16 -1
  60. package/src/wireguard.ts +352 -120
  61. package/src/databases/mariadb.ts +0 -90
  62. package/src/databases/shared.ts +0 -67
  63. package/src/k8s/apps/kubernetes-dashboard.ts +0 -28
  64. package/src/k8s/apps/maybe.ts +0 -39
  65. package/src/network/dynamic-endpoint.ts +0 -39
@@ -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 root password for the database instance. If not provided, a random password will be generated.
84
+ * The admin password for the application. If not provided, a random password will be generated.
84
85
  */
85
- rootPassword: z.string().optional(),
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
- mariadb: {
139
- entity: mariadbEntity,
139
+ mysql: {
140
+ entity: mysql.connectionEntity,
140
141
  },
141
142
  postgresql: {
142
- entity: postgresqlEntity,
143
+ entity: postgresql.connectionEntity,
143
144
  },
144
145
  mongodb: {
145
- entity: mongodbEntity,
146
+ entity: mongodb.connectionEntity,
146
147
  },
147
148
  redis: {
148
- entity: redisEntity,
149
+ entity: redis.connectionEntity,
149
150
  },
150
151
  etcd: {
151
- entity: etcdEntity,
152
+ entity: etcd.connectionEntity,
152
153
  },
153
154
  })
154
155
 
@@ -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
  */
@@ -1,7 +1,7 @@
1
1
  import { defineUnit } from "@highstate/contract"
2
2
  import { pick } from "remeda"
3
- import { databases } from "../.."
4
- import { serviceEntity } from "../service"
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
- redis: databases.redisEntity,
36
- service: serviceEntity,
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/app"),
46
+ source: source("valkey"),
47
47
  })
@@ -1,4 +1,4 @@
1
- import { defineUnit, z } from "@highstate/contract"
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", "mariadb"]),
17
+ ...pick(sharedInputs, ["k8sCluster", "accessPoint", "mysql"]),
22
18
  },
23
19
 
24
20
  meta: {
@@ -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 { serviceEntity, serviceTypeSchema } from "../service"
6
- import { exposableWorkloadEntity } from "../workload"
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
- "accessPoint",
200
- "resticRepo",
201
- "mariadb",
202
- "postgresql",
203
- "mongodb",
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: exposableWorkloadEntity,
210
- service: serviceEntity,
213
+ workload: workloadEntity,
211
214
  },
212
215
 
213
216
  meta: {
@@ -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
@@ -1,5 +1,5 @@
1
1
  import type { Simplify, SimplifyDeep } from "type-fest"
2
- import { defineEntity, 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,22 +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 = z.infer<typeof resourceEntity.schema>
172
+ export type Resource = EntityValue<typeof resourceEntity>
173
+ export type ResourceInput = EntityInput<typeof resourceEntity>
141
174
 
142
175
  export type NamespacedMetadata = z.infer<typeof namespacedMetadataSchema>
143
176
 
144
177
  export type NamespacedResource = SimplifyDeep<
145
- z.infer<typeof namespacedResourceEntity.schema>,
178
+ EntityValue<typeof namespacedResourceEntity>,
146
179
  Record<string, string>
147
180
  >
148
181
 
149
- export type Namespace = Simplify<z.infer<typeof namespaceEntity.schema>>
150
- export type PersistentVolumeClaim = z.infer<typeof persistentVolumeClaimEntity.schema>
151
- export type Gateway = z.infer<typeof gatewayEntity.schema>
152
- export type Certificate = z.infer<typeof certificateEntity.schema>
153
- export type ConfigMap = z.infer<typeof configMapEntity.schema>
154
- export type Secret = z.infer<typeof secretEntity.schema>
182
+ export type NamespacedResourceInput = EntityInput<typeof namespacedResourceEntity>
183
+
184
+ export type Namespace = Simplify<EntityValue<typeof namespaceEntity>>
185
+ export type NamespaceInput = EntityInput<typeof namespaceEntity>
186
+ export type PersistentVolumeClaim = EntityValue<typeof persistentVolumeClaimEntity>
187
+ export type PersistentVolumeClaimInput = EntityInput<typeof persistentVolumeClaimEntity>
188
+ export type Gateway = EntityValue<typeof gatewayEntity>
189
+ export type GatewayInput = EntityInput<typeof gatewayEntity>
190
+ export type Certificate = EntityValue<typeof certificateEntity>
191
+ export type CertificateInput = EntityInput<typeof certificateEntity>
192
+ export type ConfigMap = EntityValue<typeof configMapEntity>
193
+ export type ConfigMapInput = EntityInput<typeof configMapEntity>
194
+ export type Secret = EntityValue<typeof secretEntity>
195
+ export type SecretInput = EntityInput<typeof secretEntity>
@@ -1,5 +1,5 @@
1
1
  import type { Simplify } from "type-fest"
2
- import { defineEntity, 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,4 +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 = z.infer<typeof serviceEntity.schema>
80
+ export type Service = EntityValue<typeof serviceEntity>
81
+ export type ServiceInput = EntityInput<typeof serviceEntity>
package/src/k8s/shared.ts CHANGED
@@ -1,5 +1,12 @@
1
- import { $args, defineEntity, defineUnit, z } from "@highstate/contract"
2
- import { serverEntity } from "../common"
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,9 +327,19 @@ export const monitorWorkerParamsSchema = z.object({
305
327
  resources: namespacedResourceEntity.schema.array(),
306
328
  })
307
329
 
308
- export type Cluster = z.infer<typeof clusterEntity.schema>
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>
338
+ export type ClusterInput = EntityInput<typeof clusterEntity>
309
339
 
310
340
  export type InternalIpsPolicy = z.infer<typeof internalIpsPolicySchema>
311
341
 
312
342
  export type MonitorWorkerParams = z.infer<typeof monitorWorkerParamsSchema>
313
343
  export type MonitorWorkerResourceGroup = z.infer<typeof monitorWorkerResourceGroupSchema>
344
+
345
+ export type Toleration = z.infer<typeof tolerationSchema>
@@ -1,19 +1,48 @@
1
- import { defineEntity, 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
- schema: z.unknown(),
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: { exposableWorkloadEntity },
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: { exposableWorkloadEntity },
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,20 +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 = z.infer<typeof workloadEntity.schema>
133
- export type Job = z.infer<typeof jobEntity.schema>
134
- export type CronJob = z.infer<typeof cronJobEntity.schema>
135
- export type ExposableWorkload = z.infer<typeof exposableWorkloadEntity.schema>
136
- export type Deployment = z.infer<typeof deploymentEntity.schema>
137
- export type StatefulSet = z.infer<typeof statefulSetEntity.schema>
138
- export type NetworkInterface = z.infer<typeof networkInterfaceEntity.schema>
150
+ export type Workload = EntityValue<typeof workloadEntity>
151
+ export type WorkloadInput = EntityInput<typeof workloadEntity>
152
+ export type Job = EntityValue<typeof jobEntity>
153
+ export type JobInput = EntityInput<typeof jobEntity>
154
+ export type CronJob = EntityValue<typeof cronJobEntity>
155
+ export type CronJobInput = EntityInput<typeof cronJobEntity>
156
+ export type Deployment = EntityValue<typeof deploymentEntity>
157
+ export type DeploymentInput = EntityInput<typeof deploymentEntity>
158
+ export type StatefulSet = EntityValue<typeof statefulSetEntity>
159
+ export type StatefulSetInput = EntityInput<typeof statefulSetEntity>
160
+ export type NetworkInterface = EntityValue<typeof networkInterfaceEntity>
161
+ export type NetworkInterfaceInput = EntityInput<typeof networkInterfaceEntity>