@highstate/k8s 0.14.2 → 0.16.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/chunk-22GOWZQP.js +286 -0
- package/dist/chunk-22GOWZQP.js.map +1 -0
- package/dist/{chunk-VJL2BFKO.js → chunk-4G6LLC2X.js} +13 -24
- package/dist/chunk-4G6LLC2X.js.map +1 -0
- package/dist/{chunk-C6WHUOC3.js → chunk-BR2CLUUD.js} +15 -26
- package/dist/chunk-BR2CLUUD.js.map +1 -0
- package/dist/{chunk-EACAK6W4.js → chunk-DCUMJSO6.js} +17 -28
- package/dist/chunk-DCUMJSO6.js.map +1 -0
- package/dist/{chunk-NWXKLVBC.js → chunk-HJKJHTJM.js} +20 -30
- package/dist/chunk-HJKJHTJM.js.map +1 -0
- package/dist/{chunk-7H4L3DFC.js → chunk-KMLRI5UZ.js} +57 -70
- package/dist/chunk-KMLRI5UZ.js.map +1 -0
- package/dist/{chunk-6ACIPGW4.js → chunk-LGHFSXNT.js} +12 -13
- package/dist/chunk-LGHFSXNT.js.map +1 -0
- package/dist/{chunk-SEWB4FUB.js → chunk-OBDQONMV.js} +64 -23
- package/dist/chunk-OBDQONMV.js.map +1 -0
- package/dist/chunk-SL5CBM3A.js +301 -0
- package/dist/chunk-SL5CBM3A.js.map +1 -0
- package/dist/{chunk-3CKMDTYK.js → chunk-TWBMG6TD.js} +68 -91
- package/dist/chunk-TWBMG6TD.js.map +1 -0
- package/dist/{chunk-YTRQ6JRU.js → chunk-XRIC6EJ3.js} +159 -94
- package/dist/chunk-XRIC6EJ3.js.map +1 -0
- package/dist/{chunk-O64YZLA4.js → chunk-ZBFWQHE4.js} +21 -30
- package/dist/chunk-ZBFWQHE4.js.map +1 -0
- package/dist/{chunk-4VGISFL4.js → chunk-ZHVKK2U6.js} +12 -11
- package/dist/chunk-ZHVKK2U6.js.map +1 -0
- package/dist/cron-job-LX35I6HG.js +8 -0
- package/dist/cron-job-LX35I6HG.js.map +1 -0
- package/dist/deployment-HRJGAEJR.js +8 -0
- package/dist/{deployment-THUD5QUH.js.map → deployment-HRJGAEJR.js.map} +1 -1
- package/dist/highstate.manifest.json +2 -3
- package/dist/impl/gateway-route.js +10 -10
- package/dist/impl/gateway-route.js.map +1 -1
- package/dist/impl/tls-certificate.js +3 -3
- package/dist/index.js +39 -627
- package/dist/index.js.map +1 -1
- package/dist/job-J4BKBVQD.js +8 -0
- package/dist/job-J4BKBVQD.js.map +1 -0
- package/dist/stateful-set-LAJR5RL4.js +8 -0
- package/dist/{stateful-set-ABCZML4L.js.map → stateful-set-LAJR5RL4.js.map} +1 -1
- package/dist/units/cert-manager/index.js +7 -7
- package/dist/units/cluster-patch/index.js +9 -18
- package/dist/units/cluster-patch/index.js.map +1 -1
- package/dist/units/dns01-issuer/index.js +6 -6
- package/dist/units/dns01-issuer/index.js.map +1 -1
- package/dist/units/existing-cluster/index.js +19 -9
- package/dist/units/existing-cluster/index.js.map +1 -1
- package/dist/units/gateway-api/index.js +2 -2
- package/dist/units/gateway-api/index.js.map +1 -1
- package/dist/units/reduced-access-cluster/index.js +18 -25
- package/dist/units/reduced-access-cluster/index.js.map +1 -1
- package/package.json +7 -12
- package/src/cluster.ts +14 -14
- package/src/config-map.ts +16 -30
- package/src/container.ts +1 -1
- package/src/cron-job.ts +23 -41
- package/src/deployment.ts +23 -30
- package/src/gateway/gateway.ts +21 -29
- package/src/helm.ts +7 -8
- package/src/impl/gateway-route.ts +5 -13
- package/src/job.ts +20 -38
- package/src/namespace.ts +18 -22
- package/src/network-policy.ts +37 -36
- package/src/network.ts +18 -10
- package/src/pvc.ts +12 -28
- package/src/rbac.ts +75 -97
- package/src/scripting/bundle.ts +3 -3
- package/src/scripting/environment.ts +3 -3
- package/src/secret.ts +16 -30
- package/src/service.ts +86 -105
- package/src/shared.ts +82 -20
- package/src/stateful-set.ts +17 -28
- package/src/tls.ts +20 -31
- package/src/units/cluster-patch/index.ts +9 -19
- package/src/units/dns01-issuer/index.ts +6 -6
- package/src/units/existing-cluster/index.ts +28 -10
- package/src/units/gateway-api/index.ts +1 -1
- package/src/units/reduced-access-cluster/index.ts +16 -24
- package/src/worker.ts +7 -5
- package/src/workload.ts +172 -28
- package/dist/chunk-3CKMDTYK.js.map +0 -1
- package/dist/chunk-4VGISFL4.js.map +0 -1
- package/dist/chunk-6ACIPGW4.js.map +0 -1
- package/dist/chunk-7H4L3DFC.js.map +0 -1
- package/dist/chunk-C6WHUOC3.js.map +0 -1
- package/dist/chunk-EACAK6W4.js.map +0 -1
- package/dist/chunk-NWXKLVBC.js.map +0 -1
- package/dist/chunk-O64YZLA4.js.map +0 -1
- package/dist/chunk-SEWB4FUB.js.map +0 -1
- package/dist/chunk-VJL2BFKO.js.map +0 -1
- package/dist/chunk-YTRQ6JRU.js.map +0 -1
- package/dist/deployment-THUD5QUH.js +0 -8
- package/dist/stateful-set-ABCZML4L.js +0 -8
- package/dist/units/cluster-dns/index.js +0 -37
- package/dist/units/cluster-dns/index.js.map +0 -1
- package/src/units/cluster-dns/index.ts +0 -37
package/dist/index.js
CHANGED
|
@@ -1,618 +1,29 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { Chart, RenderedChart, getChartService, getChartServiceOutput, resolveHelmChart } from './chunk-
|
|
1
|
+
export { Job } from './chunk-22GOWZQP.js';
|
|
2
|
+
export { CronJob } from './chunk-SL5CBM3A.js';
|
|
3
|
+
export { Chart, RenderedChart, getChartService, getChartServiceOutput, resolveHelmChart } from './chunk-ZHVKK2U6.js';
|
|
4
|
+
export { Deployment } from './chunk-ZBFWQHE4.js';
|
|
5
|
+
export { StatefulSet } from './chunk-HJKJHTJM.js';
|
|
6
|
+
import { ConfigMap } from './chunk-XRIC6EJ3.js';
|
|
7
|
+
export { ConfigMap, ExposableWorkload, NativeNetworkPolicy, NetworkPolicy, PersistentVolumeClaim, Workload, exposableWorkloadExtraArgs, getAutoVolumeName, getBestEndpoint, getExposableWorkloadComponents, getFallbackContainerName, getWorkloadComponents, getWorkloadVolumeResourceUuid, mapContainerEnvironment, mapContainerToRaw, mapEnvironmentSource, mapVolumeMount, mapWorkloadVolume, networkPolicyMediator, podSpecDefaults, requireBestEndpoint, workloadExtraArgs } from './chunk-XRIC6EJ3.js';
|
|
4
8
|
export { dns01SolverMediator } from './chunk-HH2JJELM.js';
|
|
5
|
-
import { ClusterAccessScope } from './chunk-
|
|
6
|
-
export { ClusterAccessScope } from './chunk-
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
import { commonExtraArgs, Namespace, mapMetadata, getProvider, images_exports } from './chunk-SEWB4FUB.js';
|
|
15
|
-
export { Namespace, ScopedResource, commonExtraArgs, getNamespaceName, getProvider, getProviderAsync, images_exports as images, mapMetadata, mapNamespaceNameToSelector, mapSelectorLikeToSelector, validateCluster } from './chunk-SEWB4FUB.js';
|
|
9
|
+
import { ClusterAccessScope } from './chunk-KMLRI5UZ.js';
|
|
10
|
+
export { ClusterAccessScope } from './chunk-KMLRI5UZ.js';
|
|
11
|
+
export { createK8sTerminal, detectExternalIps } from './chunk-LGHFSXNT.js';
|
|
12
|
+
export { Gateway, HttpRoute, TcpRoute, UdpRoute, mapHttpRouteRuleMatch, resolveBackendRef } from './chunk-DCUMJSO6.js';
|
|
13
|
+
export { Certificate } from './chunk-BR2CLUUD.js';
|
|
14
|
+
export { Service, createServiceSpec, getServiceType, isEndpointFromCluster, l4EndpointToServicePort, mapContainerPortToServicePort, mapServiceToLabelSelector } from './chunk-TWBMG6TD.js';
|
|
15
|
+
export { Secret } from './chunk-4G6LLC2X.js';
|
|
16
|
+
import { images_exports } from './chunk-OBDQONMV.js';
|
|
17
|
+
export { Namespace, NamespacedResource, Resource, commonExtraArgs, getNamespaceName, getProvider, getProviderAsync, images_exports as images, mapMetadata, mapNamespaceNameToSelector, mapSelectorLikeToSelector, validateCluster } from './chunk-OBDQONMV.js';
|
|
16
18
|
import './chunk-PZ5AY32C.js';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { omit, omitBy, mapValues, merge } from 'remeda';
|
|
22
|
-
import { parseL34Endpoint } from '@highstate/common';
|
|
23
|
-
import { ComponentResource, output as output$1 } from '@pulumi/pulumi';
|
|
19
|
+
import { parseEndpoint } from '@highstate/common';
|
|
20
|
+
import { text, trimIndentation } from '@highstate/contract';
|
|
21
|
+
import { normalize } from '@highstate/pulumi';
|
|
22
|
+
import { ComponentResource, output } from '@pulumi/pulumi';
|
|
24
23
|
import { serializeFunction } from '@pulumi/pulumi/runtime/index.js';
|
|
24
|
+
import { deepmerge } from 'deepmerge-ts';
|
|
25
25
|
import { readPackageJSON } from 'pkg-types';
|
|
26
|
-
|
|
27
|
-
var CronJob = class _CronJob extends Workload {
|
|
28
|
-
constructor(type, name, args, opts, apiVersion, kind, terminalArgs, containers, namespace, metadata, networkPolicy, spec, status) {
|
|
29
|
-
super(
|
|
30
|
-
type,
|
|
31
|
-
name,
|
|
32
|
-
args,
|
|
33
|
-
opts,
|
|
34
|
-
apiVersion,
|
|
35
|
-
kind,
|
|
36
|
-
terminalArgs,
|
|
37
|
-
containers,
|
|
38
|
-
namespace,
|
|
39
|
-
metadata,
|
|
40
|
-
spec.jobTemplate.spec.template,
|
|
41
|
-
networkPolicy
|
|
42
|
-
);
|
|
43
|
-
this.spec = spec;
|
|
44
|
-
this.status = status;
|
|
45
|
-
}
|
|
46
|
-
get templateMetadata() {
|
|
47
|
-
return this.spec.jobTemplate.spec.template.metadata;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* The Highstate cron job entity.
|
|
51
|
-
*/
|
|
52
|
-
get entity() {
|
|
53
|
-
return output({
|
|
54
|
-
type: "cron-job",
|
|
55
|
-
clusterId: this.cluster.id,
|
|
56
|
-
clusterName: this.cluster.name,
|
|
57
|
-
metadata: this.metadata
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
getTerminalMeta() {
|
|
61
|
-
return output({
|
|
62
|
-
title: "CronJob",
|
|
63
|
-
globalTitle: interpolate`CronJob | ${this.metadata.name}`,
|
|
64
|
-
description: "The shell inside the cron job.",
|
|
65
|
-
icon: "devicon:kubernetes"
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
get resourceType() {
|
|
69
|
-
return "cronjob";
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Creates a new cron job.
|
|
73
|
-
*/
|
|
74
|
-
static create(name, args, opts) {
|
|
75
|
-
return new CreatedCronJob(name, args, opts);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Creates a new cron job or patches an existing one.
|
|
79
|
-
*
|
|
80
|
-
* @param name The name of the resource. May not be the same as the cron job name.
|
|
81
|
-
* @param args The arguments to create or patch the cron job with.
|
|
82
|
-
* @param opts Optional resource options.
|
|
83
|
-
*/
|
|
84
|
-
static createOrPatch(name, args, opts) {
|
|
85
|
-
if (args.existing) {
|
|
86
|
-
return new CronJobPatch(name, {
|
|
87
|
-
...args,
|
|
88
|
-
name: output(args.existing).metadata.name,
|
|
89
|
-
namespace: Namespace.forResourceAsync(args.existing, output(args.namespace).cluster)
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return new CreatedCronJob(name, args, opts);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Creates a new cron job or gets an existing one.
|
|
96
|
-
*
|
|
97
|
-
* @param name The name of the resource. May not be the same as the cron job name. Will not be used when existing cron job is retrieved.
|
|
98
|
-
* @param args The arguments to create or get the cron job with.
|
|
99
|
-
* @param opts Optional resource options.
|
|
100
|
-
*/
|
|
101
|
-
static async createOrGet(name, args, opts) {
|
|
102
|
-
if (args.existing) {
|
|
103
|
-
return await _CronJob.forAsync(args.existing, output(args.namespace).cluster);
|
|
104
|
-
}
|
|
105
|
-
return new CreatedCronJob(name, args, opts);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Patches an existing cron job.
|
|
109
|
-
*
|
|
110
|
-
* Will throw an error if the cron job does not exist.
|
|
111
|
-
*
|
|
112
|
-
* @param name The name of the resource. May not be the same as the cron job name.
|
|
113
|
-
* @param args The arguments to patch the cron job with.
|
|
114
|
-
* @param opts Optional resource options.
|
|
115
|
-
*/
|
|
116
|
-
static patch(name, args, opts) {
|
|
117
|
-
return new CronJobPatch(name, args, opts);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Wraps an existing Kubernetes cron job.
|
|
121
|
-
*/
|
|
122
|
-
static wrap(name, args, opts) {
|
|
123
|
-
return new WrappedCronJob(name, args, opts);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Gets an existing cron job.
|
|
127
|
-
*
|
|
128
|
-
* Will throw an error if the cron job does not exist.
|
|
129
|
-
*/
|
|
130
|
-
static get(name, args, opts) {
|
|
131
|
-
return new ExternalCronJob(name, args, opts);
|
|
132
|
-
}
|
|
133
|
-
static cronJobCache = /* @__PURE__ */ new Map();
|
|
134
|
-
/**
|
|
135
|
-
* Gets an existing cron job for a given entity.
|
|
136
|
-
* Prefer this method over `get` when possible.
|
|
137
|
-
*
|
|
138
|
-
* It automatically names the resource with the following format: `{clusterName}.{namespace}.{name}.{clusterId}`.
|
|
139
|
-
*
|
|
140
|
-
* This method is idempotent and will return the same instance for the same entity.
|
|
141
|
-
*
|
|
142
|
-
* @param entity The entity to get the cron job for.
|
|
143
|
-
* @param cluster The cluster where the cron job is located.
|
|
144
|
-
*/
|
|
145
|
-
static for(entity, cluster) {
|
|
146
|
-
return getOrCreate(
|
|
147
|
-
_CronJob.cronJobCache,
|
|
148
|
-
`${entity.clusterName}.${entity.metadata.namespace}.${entity.metadata.name}.${entity.clusterId}`,
|
|
149
|
-
(name) => {
|
|
150
|
-
return _CronJob.get(name, {
|
|
151
|
-
name: entity.metadata.name,
|
|
152
|
-
namespace: Namespace.forResource(entity, cluster)
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Gets an existing cron job for a given entity.
|
|
159
|
-
* Prefer this method over `get` when possible.
|
|
160
|
-
*
|
|
161
|
-
* It automatically names the resource with the following format: `{clusterName}.{namespace}.{name}.{clusterId}`.
|
|
162
|
-
*
|
|
163
|
-
* This method is idempotent and will return the same instance for the same entity.
|
|
164
|
-
*
|
|
165
|
-
* @param entity The entity to get the cron job for.
|
|
166
|
-
* @param cluster The cluster where the cron job is located.
|
|
167
|
-
*/
|
|
168
|
-
static async forAsync(entity, cluster) {
|
|
169
|
-
const resolvedEntity = await toPromise(entity);
|
|
170
|
-
return _CronJob.for(resolvedEntity, cluster);
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
var cronJobExtraArgs = [...commonExtraArgs, "container", "containers"];
|
|
174
|
-
var CreatedCronJob = class extends CronJob {
|
|
175
|
-
constructor(name, args, opts) {
|
|
176
|
-
const { podTemplate, containers, networkPolicy } = getWorkloadComponents(
|
|
177
|
-
name,
|
|
178
|
-
args,
|
|
179
|
-
() => this,
|
|
180
|
-
opts
|
|
181
|
-
);
|
|
182
|
-
const cronJob = output(args.namespace).cluster.apply((cluster) => {
|
|
183
|
-
return new batch.v1.CronJob(
|
|
184
|
-
name,
|
|
185
|
-
{
|
|
186
|
-
metadata: mapMetadata(args, name),
|
|
187
|
-
spec: output({ args, podTemplate }).apply(({ args: args2, podTemplate: podTemplate2 }) => {
|
|
188
|
-
return deepmerge(
|
|
189
|
-
{
|
|
190
|
-
jobTemplate: {
|
|
191
|
-
spec: {
|
|
192
|
-
template: deepmerge(
|
|
193
|
-
{
|
|
194
|
-
spec: {
|
|
195
|
-
restartPolicy: "Never"
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
podTemplate2
|
|
199
|
-
)
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
schedule: args2.schedule
|
|
203
|
-
},
|
|
204
|
-
omit(args2, cronJobExtraArgs)
|
|
205
|
-
);
|
|
206
|
-
})
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
...opts,
|
|
210
|
-
parent: this,
|
|
211
|
-
provider: getProvider(cluster)
|
|
212
|
-
}
|
|
213
|
-
);
|
|
214
|
-
});
|
|
215
|
-
super(
|
|
216
|
-
"highstate:k8s:CronJob",
|
|
217
|
-
name,
|
|
218
|
-
args,
|
|
219
|
-
opts,
|
|
220
|
-
cronJob.apiVersion,
|
|
221
|
-
cronJob.kind,
|
|
222
|
-
output(args.terminal ?? {}),
|
|
223
|
-
containers,
|
|
224
|
-
output(args.namespace),
|
|
225
|
-
cronJob.metadata,
|
|
226
|
-
networkPolicy,
|
|
227
|
-
cronJob.spec,
|
|
228
|
-
cronJob.status
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
var CronJobPatch = class extends CronJob {
|
|
233
|
-
constructor(name, args, opts) {
|
|
234
|
-
const { podTemplate, containers, networkPolicy } = getWorkloadComponents(
|
|
235
|
-
name,
|
|
236
|
-
args,
|
|
237
|
-
() => this,
|
|
238
|
-
opts,
|
|
239
|
-
true
|
|
240
|
-
);
|
|
241
|
-
const cronJob = output(args.namespace).cluster.apply((cluster) => {
|
|
242
|
-
return new batch.v1.CronJobPatch(
|
|
243
|
-
name,
|
|
244
|
-
{
|
|
245
|
-
metadata: mapMetadata(args, name),
|
|
246
|
-
spec: output({ args, podTemplate }).apply(({ args: args2, podTemplate: podTemplate2 }) => {
|
|
247
|
-
return deepmerge(
|
|
248
|
-
{
|
|
249
|
-
jobTemplate: {
|
|
250
|
-
spec: {
|
|
251
|
-
template: podTemplate2
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
schedule: args2.schedule
|
|
255
|
-
},
|
|
256
|
-
omit(args2, cronJobExtraArgs)
|
|
257
|
-
);
|
|
258
|
-
})
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
...opts,
|
|
262
|
-
parent: this,
|
|
263
|
-
provider: getProvider(cluster)
|
|
264
|
-
}
|
|
265
|
-
);
|
|
266
|
-
});
|
|
267
|
-
super(
|
|
268
|
-
"highstate:k8s:CronJobPatch",
|
|
269
|
-
name,
|
|
270
|
-
args,
|
|
271
|
-
opts,
|
|
272
|
-
cronJob.apiVersion,
|
|
273
|
-
cronJob.kind,
|
|
274
|
-
output(args.terminal ?? {}),
|
|
275
|
-
containers,
|
|
276
|
-
output(args.namespace),
|
|
277
|
-
cronJob.metadata,
|
|
278
|
-
networkPolicy,
|
|
279
|
-
cronJob.spec,
|
|
280
|
-
cronJob.status
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
var WrappedCronJob = class extends CronJob {
|
|
285
|
-
constructor(name, args, opts) {
|
|
286
|
-
super(
|
|
287
|
-
"highstate:k8s:WrappedCronJob",
|
|
288
|
-
name,
|
|
289
|
-
args,
|
|
290
|
-
opts,
|
|
291
|
-
output(args.cronJob).apiVersion,
|
|
292
|
-
output(args.cronJob).kind,
|
|
293
|
-
output(args.terminal ?? {}),
|
|
294
|
-
output([]),
|
|
295
|
-
output(args.namespace),
|
|
296
|
-
output(args.cronJob).metadata,
|
|
297
|
-
output(void 0),
|
|
298
|
-
output(args.cronJob).spec,
|
|
299
|
-
output(args.cronJob).status
|
|
300
|
-
);
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
var ExternalCronJob = class extends CronJob {
|
|
304
|
-
constructor(name, args, opts) {
|
|
305
|
-
const cronJob = output(args.namespace).cluster.apply((cluster) => {
|
|
306
|
-
return batch.v1.CronJob.get(
|
|
307
|
-
name,
|
|
308
|
-
interpolate`${output(args.namespace).metadata.name}/${args.name}`,
|
|
309
|
-
{ ...opts, parent: this, provider: getProvider(cluster) }
|
|
310
|
-
);
|
|
311
|
-
});
|
|
312
|
-
super(
|
|
313
|
-
"highstate:k8s:ExternalCronJob",
|
|
314
|
-
name,
|
|
315
|
-
args,
|
|
316
|
-
opts,
|
|
317
|
-
cronJob.apiVersion,
|
|
318
|
-
cronJob.kind,
|
|
319
|
-
output({}),
|
|
320
|
-
output([]),
|
|
321
|
-
output(args.namespace),
|
|
322
|
-
cronJob.metadata,
|
|
323
|
-
output(void 0),
|
|
324
|
-
cronJob.spec,
|
|
325
|
-
cronJob.status
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
var Job = class _Job extends Workload {
|
|
330
|
-
constructor(type, name, args, opts, apiVersion, kind, terminalArgs, containers, namespace, metadata, networkPolicy, spec, status) {
|
|
331
|
-
super(
|
|
332
|
-
type,
|
|
333
|
-
name,
|
|
334
|
-
args,
|
|
335
|
-
opts,
|
|
336
|
-
apiVersion,
|
|
337
|
-
kind,
|
|
338
|
-
terminalArgs,
|
|
339
|
-
containers,
|
|
340
|
-
namespace,
|
|
341
|
-
metadata,
|
|
342
|
-
spec.template,
|
|
343
|
-
networkPolicy
|
|
344
|
-
);
|
|
345
|
-
this.spec = spec;
|
|
346
|
-
this.status = status;
|
|
347
|
-
}
|
|
348
|
-
get templateMetadata() {
|
|
349
|
-
return this.spec.template.metadata;
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* The Highstate job entity.
|
|
353
|
-
*/
|
|
354
|
-
get entity() {
|
|
355
|
-
return output({
|
|
356
|
-
type: "job",
|
|
357
|
-
clusterId: this.cluster.id,
|
|
358
|
-
clusterName: this.cluster.name,
|
|
359
|
-
metadata: this.metadata
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
getTerminalMeta() {
|
|
363
|
-
return output({
|
|
364
|
-
title: "Job",
|
|
365
|
-
globalTitle: interpolate`Job | ${this.metadata.name}`,
|
|
366
|
-
description: "The shell inside the job.",
|
|
367
|
-
icon: "devicon:kubernetes"
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
get resourceType() {
|
|
371
|
-
return "job";
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Creates a new job.
|
|
375
|
-
*/
|
|
376
|
-
static create(name, args, opts) {
|
|
377
|
-
return new CreatedJob(name, args, opts);
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Creates a new job or patches an existing one.
|
|
381
|
-
*
|
|
382
|
-
* @param name The name of the resource. May not be the same as the job name.
|
|
383
|
-
* @param args The arguments to create or patch the job with.
|
|
384
|
-
* @param opts Optional resource options.
|
|
385
|
-
*/
|
|
386
|
-
static createOrPatch(name, args, opts) {
|
|
387
|
-
if (args.existing) {
|
|
388
|
-
return new JobPatch(name, {
|
|
389
|
-
...args,
|
|
390
|
-
name: output(args.existing).metadata.name,
|
|
391
|
-
namespace: Namespace.forResourceAsync(args.existing, output(args.namespace).cluster)
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
return new CreatedJob(name, args, opts);
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Creates a new job or gets an existing one.
|
|
398
|
-
*
|
|
399
|
-
* @param name The name of the resource. May not be the same as the job name. Will not be used when existing job is retrieved.
|
|
400
|
-
* @param args The arguments to create or get the job with.
|
|
401
|
-
* @param opts Optional resource options.
|
|
402
|
-
*/
|
|
403
|
-
static async createOrGet(name, args, opts) {
|
|
404
|
-
if (args.existing) {
|
|
405
|
-
return await _Job.forAsync(args.existing, output(args.namespace).cluster);
|
|
406
|
-
}
|
|
407
|
-
return new CreatedJob(name, args, opts);
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Patches an existing job.
|
|
411
|
-
*
|
|
412
|
-
* Will throw an error if the job does not exist.
|
|
413
|
-
*
|
|
414
|
-
* @param name The name of the resource. May not be the same as the job name.
|
|
415
|
-
* @param args The arguments to patch the job with.
|
|
416
|
-
* @param opts Optional resource options.
|
|
417
|
-
*/
|
|
418
|
-
static patch(name, args, opts) {
|
|
419
|
-
return new JobPatch(name, args, opts);
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Wraps an existing Kubernetes job.
|
|
423
|
-
*/
|
|
424
|
-
static wrap(name, args, opts) {
|
|
425
|
-
return new WrappedJob(name, args, opts);
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* Gets an existing job.
|
|
429
|
-
*
|
|
430
|
-
* Will throw an error if the job does not exist.
|
|
431
|
-
*/
|
|
432
|
-
static get(name, args, opts) {
|
|
433
|
-
return new ExternalJob(name, args, opts);
|
|
434
|
-
}
|
|
435
|
-
static jobCache = /* @__PURE__ */ new Map();
|
|
436
|
-
/**
|
|
437
|
-
* Gets an existing job for a given entity.
|
|
438
|
-
* Prefer this method over `get` when possible.
|
|
439
|
-
*
|
|
440
|
-
* It automatically names the resource with the following format: `{clusterName}.{namespace}.{name}.{clusterId}`.
|
|
441
|
-
*
|
|
442
|
-
* This method is idempotent and will return the same instance for the same entity.
|
|
443
|
-
*
|
|
444
|
-
* @param entity The entity to get the job for.
|
|
445
|
-
* @param cluster The cluster where the job is located.
|
|
446
|
-
*/
|
|
447
|
-
static for(entity, cluster) {
|
|
448
|
-
return getOrCreate(
|
|
449
|
-
_Job.jobCache,
|
|
450
|
-
`${entity.clusterName}.${entity.metadata.namespace}.${entity.metadata.name}.${entity.clusterId}`,
|
|
451
|
-
(name) => {
|
|
452
|
-
return _Job.get(name, {
|
|
453
|
-
name: entity.metadata.name,
|
|
454
|
-
namespace: Namespace.forResource(entity, cluster)
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
);
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* Gets an existing job for a given entity.
|
|
461
|
-
* Prefer this method over `get` when possible.
|
|
462
|
-
*
|
|
463
|
-
* It automatically names the resource with the following format: `{clusterName}.{namespace}.{name}.{clusterId}`.
|
|
464
|
-
*
|
|
465
|
-
* This method is idempotent and will return the same instance for the same entity.
|
|
466
|
-
*
|
|
467
|
-
* @param entity The entity to get the job for.
|
|
468
|
-
* @param cluster The cluster where the job is located.
|
|
469
|
-
*/
|
|
470
|
-
static async forAsync(entity, cluster) {
|
|
471
|
-
const resolvedEntity = await toPromise(entity);
|
|
472
|
-
return _Job.for(resolvedEntity, cluster);
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
var jobExtraArgs = [...commonExtraArgs, "container", "containers"];
|
|
476
|
-
var CreatedJob = class extends Job {
|
|
477
|
-
constructor(name, args, opts) {
|
|
478
|
-
const { podTemplate, containers, networkPolicy } = getWorkloadComponents(
|
|
479
|
-
name,
|
|
480
|
-
args,
|
|
481
|
-
() => this,
|
|
482
|
-
opts
|
|
483
|
-
);
|
|
484
|
-
const job = output(args.namespace).cluster.apply((cluster) => {
|
|
485
|
-
return new batch.v1.Job(
|
|
486
|
-
name,
|
|
487
|
-
{
|
|
488
|
-
metadata: mapMetadata(args, name),
|
|
489
|
-
spec: output({ args, podTemplate }).apply(({ args: args2, podTemplate: podTemplate2 }) => {
|
|
490
|
-
return deepmerge(
|
|
491
|
-
{
|
|
492
|
-
template: deepmerge(
|
|
493
|
-
{
|
|
494
|
-
spec: {
|
|
495
|
-
restartPolicy: "Never"
|
|
496
|
-
}
|
|
497
|
-
},
|
|
498
|
-
podTemplate2
|
|
499
|
-
)
|
|
500
|
-
},
|
|
501
|
-
omit(args2, jobExtraArgs)
|
|
502
|
-
);
|
|
503
|
-
})
|
|
504
|
-
},
|
|
505
|
-
{ ...opts, parent: this, provider: getProvider(cluster) }
|
|
506
|
-
);
|
|
507
|
-
});
|
|
508
|
-
super(
|
|
509
|
-
"highstate:k8s:Job",
|
|
510
|
-
name,
|
|
511
|
-
args,
|
|
512
|
-
opts,
|
|
513
|
-
job.apiVersion,
|
|
514
|
-
job.kind,
|
|
515
|
-
output(args.terminal ?? {}),
|
|
516
|
-
containers,
|
|
517
|
-
output(args.namespace),
|
|
518
|
-
job.metadata,
|
|
519
|
-
networkPolicy,
|
|
520
|
-
job.spec,
|
|
521
|
-
job.status
|
|
522
|
-
);
|
|
523
|
-
}
|
|
524
|
-
};
|
|
525
|
-
var JobPatch = class extends Job {
|
|
526
|
-
constructor(name, args, opts) {
|
|
527
|
-
const { podTemplate, containers, networkPolicy } = getWorkloadComponents(
|
|
528
|
-
name,
|
|
529
|
-
args,
|
|
530
|
-
() => this,
|
|
531
|
-
opts,
|
|
532
|
-
true
|
|
533
|
-
);
|
|
534
|
-
const job = output(args.namespace).cluster.apply((cluster) => {
|
|
535
|
-
return new batch.v1.JobPatch(
|
|
536
|
-
name,
|
|
537
|
-
{
|
|
538
|
-
metadata: mapMetadata(args, name),
|
|
539
|
-
spec: output({ args, podTemplate }).apply(({ args: args2, podTemplate: podTemplate2 }) => {
|
|
540
|
-
return deepmerge(
|
|
541
|
-
{ template: podTemplate2 },
|
|
542
|
-
omit(args2, jobExtraArgs)
|
|
543
|
-
);
|
|
544
|
-
})
|
|
545
|
-
},
|
|
546
|
-
{ ...opts, parent: this, provider: getProvider(cluster) }
|
|
547
|
-
);
|
|
548
|
-
});
|
|
549
|
-
super(
|
|
550
|
-
"highstate:k8s:JobPatch",
|
|
551
|
-
name,
|
|
552
|
-
args,
|
|
553
|
-
opts,
|
|
554
|
-
job.apiVersion,
|
|
555
|
-
job.kind,
|
|
556
|
-
output(args.terminal ?? {}),
|
|
557
|
-
containers,
|
|
558
|
-
output(args.namespace),
|
|
559
|
-
job.metadata,
|
|
560
|
-
networkPolicy,
|
|
561
|
-
job.spec,
|
|
562
|
-
job.status
|
|
563
|
-
);
|
|
564
|
-
this.registerOutputs({
|
|
565
|
-
metadata: this.metadata,
|
|
566
|
-
spec: this.spec,
|
|
567
|
-
status: this.status
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
var WrappedJob = class extends Job {
|
|
572
|
-
constructor(name, args, opts) {
|
|
573
|
-
super(
|
|
574
|
-
"highstate:k8s:WrappedJob",
|
|
575
|
-
name,
|
|
576
|
-
args,
|
|
577
|
-
opts,
|
|
578
|
-
output(args.job).apiVersion,
|
|
579
|
-
output(args.job).kind,
|
|
580
|
-
output(args.terminal ?? {}),
|
|
581
|
-
output([]),
|
|
582
|
-
output(args.namespace),
|
|
583
|
-
output(args.job).metadata,
|
|
584
|
-
output(void 0),
|
|
585
|
-
output(args.job).spec,
|
|
586
|
-
output(args.job).status
|
|
587
|
-
);
|
|
588
|
-
}
|
|
589
|
-
};
|
|
590
|
-
var ExternalJob = class extends Job {
|
|
591
|
-
constructor(name, args, opts) {
|
|
592
|
-
const job = output(args.namespace).cluster.apply((cluster) => {
|
|
593
|
-
return batch.v1.Job.get(
|
|
594
|
-
name,
|
|
595
|
-
interpolate`${output(args.namespace).metadata.name}/${args.name}`,
|
|
596
|
-
{ ...opts, parent: this, provider: getProvider(cluster) }
|
|
597
|
-
);
|
|
598
|
-
});
|
|
599
|
-
super(
|
|
600
|
-
"highstate:k8s:ExternalJob",
|
|
601
|
-
name,
|
|
602
|
-
args,
|
|
603
|
-
opts,
|
|
604
|
-
job.apiVersion,
|
|
605
|
-
job.kind,
|
|
606
|
-
output({}),
|
|
607
|
-
output([]),
|
|
608
|
-
output(args.namespace),
|
|
609
|
-
job.metadata,
|
|
610
|
-
output(void 0),
|
|
611
|
-
job.spec,
|
|
612
|
-
job.status
|
|
613
|
-
);
|
|
614
|
-
}
|
|
615
|
-
};
|
|
26
|
+
import { omitBy, mapValues, merge } from 'remeda';
|
|
616
27
|
|
|
617
28
|
// src/scripting/environment.ts
|
|
618
29
|
var emptyDistributionEnvironment = {
|
|
@@ -686,18 +97,18 @@ var ScriptBundle = class extends ComponentResource {
|
|
|
686
97
|
allowedEndpoints;
|
|
687
98
|
constructor(name, args, opts) {
|
|
688
99
|
super("highstate:k8s:ScriptBundle", name, args, opts);
|
|
689
|
-
const scriptEnvironment = output
|
|
100
|
+
const scriptEnvironment = output(args).apply((args2) => normalize(args2.environment, args2.environments)).apply((args2) => deepmerge(emptyScriptEnvironment, ...args2));
|
|
690
101
|
const hasFunctionScripts = scriptEnvironment.apply((scriptEnvironment2) => {
|
|
691
102
|
return Object.values(scriptEnvironment2.files).some((file) => typeof file === "function");
|
|
692
103
|
});
|
|
693
104
|
this.distribution = args.distribution;
|
|
694
105
|
this.environment = scriptEnvironment.environment;
|
|
695
106
|
this.image = hasFunctionScripts.apply(
|
|
696
|
-
(hasFunctionScripts2) => output
|
|
107
|
+
(hasFunctionScripts2) => output(
|
|
697
108
|
hasFunctionScripts2 ? functionScriptImages[args.distribution] : scriptEnvironment[args.distribution].image
|
|
698
109
|
)
|
|
699
110
|
);
|
|
700
|
-
this.allowedEndpoints = output
|
|
111
|
+
this.allowedEndpoints = output({ scriptEnvironment, hasFunctionScripts }).apply(
|
|
701
112
|
({ scriptEnvironment: scriptEnvironment2, hasFunctionScripts: hasFunctionScripts2 }) => {
|
|
702
113
|
const allowedEndpoints = [
|
|
703
114
|
...scriptEnvironment2.allowedEndpoints,
|
|
@@ -706,10 +117,10 @@ var ScriptBundle = class extends ComponentResource {
|
|
|
706
117
|
if (hasFunctionScripts2) {
|
|
707
118
|
allowedEndpoints.push("tcp://registry.npmjs.org:443");
|
|
708
119
|
}
|
|
709
|
-
return allowedEndpoints.map(
|
|
120
|
+
return allowedEndpoints.map((endpoint) => parseEndpoint(endpoint));
|
|
710
121
|
}
|
|
711
122
|
);
|
|
712
|
-
this.configMap = output
|
|
123
|
+
this.configMap = output({ scriptEnvironment, args }).apply(({ scriptEnvironment: scriptEnvironment2, args: args2 }) => {
|
|
713
124
|
return ConfigMap.create(
|
|
714
125
|
name,
|
|
715
126
|
{
|
|
@@ -719,7 +130,7 @@ var ScriptBundle = class extends ComponentResource {
|
|
|
719
130
|
{ ...opts, parent: this }
|
|
720
131
|
);
|
|
721
132
|
});
|
|
722
|
-
this.volumes = output
|
|
133
|
+
this.volumes = output({ hasFunctionScripts, volumes: scriptEnvironment.volumes }).apply(
|
|
723
134
|
({ hasFunctionScripts: hasFunctionScripts2, volumes }) => {
|
|
724
135
|
return [
|
|
725
136
|
...volumes,
|
|
@@ -735,7 +146,7 @@ var ScriptBundle = class extends ComponentResource {
|
|
|
735
146
|
];
|
|
736
147
|
}
|
|
737
148
|
);
|
|
738
|
-
this.volumeMounts = output
|
|
149
|
+
this.volumeMounts = output({
|
|
739
150
|
hasFunctionScripts,
|
|
740
151
|
volumeMounts: scriptEnvironment.volumeMounts
|
|
741
152
|
}).apply(({ hasFunctionScripts: hasFunctionScripts2, volumeMounts }) => {
|
|
@@ -893,8 +304,8 @@ function getInstallPackagesScript(distribution, packages) {
|
|
|
893
304
|
}
|
|
894
305
|
}
|
|
895
306
|
function createScriptContainer(options) {
|
|
896
|
-
const bundle = output
|
|
897
|
-
return output
|
|
307
|
+
const bundle = output(options.bundle);
|
|
308
|
+
return output({
|
|
898
309
|
options,
|
|
899
310
|
image: bundle.image,
|
|
900
311
|
volumeMounts: bundle.volumeMounts,
|
|
@@ -914,22 +325,23 @@ function createScriptContainer(options) {
|
|
|
914
325
|
});
|
|
915
326
|
}
|
|
916
327
|
async function createMonitorWorker(namespace, resources) {
|
|
917
|
-
const scope =
|
|
328
|
+
const scope = new ClusterAccessScope("monitor", {
|
|
329
|
+
rule: {
|
|
330
|
+
verbs: ["get", "list", "watch"]
|
|
331
|
+
},
|
|
918
332
|
namespace,
|
|
919
|
-
resources
|
|
920
|
-
verbs: ["get", "list", "watch"],
|
|
921
|
-
collectionAccess: true
|
|
333
|
+
resources
|
|
922
334
|
});
|
|
923
|
-
return output
|
|
335
|
+
return output({
|
|
924
336
|
name: "monitor",
|
|
925
337
|
image: images_exports["worker.k8s-monitor"].image,
|
|
926
338
|
params: {
|
|
927
339
|
kubeconfig: scope.cluster.kubeconfig,
|
|
928
|
-
resources: output
|
|
340
|
+
resources: output(resources).apply((resources2) => resources2.map((r) => r.entity))
|
|
929
341
|
}
|
|
930
342
|
});
|
|
931
343
|
}
|
|
932
344
|
|
|
933
|
-
export {
|
|
345
|
+
export { ScriptBundle, createMonitorWorker, createScriptContainer, emptyScriptEnvironment, functionScriptImages };
|
|
934
346
|
//# sourceMappingURL=index.js.map
|
|
935
347
|
//# sourceMappingURL=index.js.map
|