@highstate/k8s 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/chunk-23vn2rdc.js +11 -0
- package/dist/chunk-2pfx13ay.js +11 -0
- package/dist/chunk-46ntav0c.js +299 -0
- package/dist/chunk-556pc9e6.js +155 -0
- package/dist/chunk-7kgjgcft.js +170 -0
- package/dist/{chunk-LGHFSXNT.js → chunk-9hs97f1q.js} +23 -17
- package/dist/chunk-aame3x1b.js +11 -0
- package/dist/chunk-b05q6fm2.js +37 -0
- package/dist/chunk-bmvc9d2d.js +11 -0
- package/dist/chunk-de82bbp2.js +7 -0
- package/dist/chunk-facs31cb.js +624 -0
- package/dist/chunk-h1b79v66.js +1425 -0
- package/dist/chunk-k4w9zpn5.js +215 -0
- package/dist/chunk-pqc6w52f.js +352 -0
- package/dist/chunk-qyshvz32.js +176 -0
- package/dist/chunk-tpfyj6fe.js +199 -0
- package/dist/chunk-z6bmpnm7.js +180 -0
- package/dist/highstate.manifest.json +3 -2
- package/dist/impl/dynamic-endpoint-resolver.js +91 -0
- package/dist/impl/gateway-route.js +226 -166
- package/dist/impl/tls-certificate.js +31 -31
- package/dist/index.js +293 -166
- package/dist/units/cert-manager/index.js +19 -14
- package/dist/units/cluster-patch/index.js +14 -13
- package/dist/units/dns01-issuer/index.js +82 -42
- package/dist/units/existing-cluster/index.js +59 -26
- package/dist/units/gateway-api/index.js +15 -16
- package/dist/units/reduced-access-cluster/index.js +32 -36
- package/package.json +23 -21
- package/src/cluster.ts +12 -8
- package/src/config-map.ts +15 -5
- package/src/container.ts +4 -2
- package/src/cron-job.ts +51 -5
- package/src/deployment.ts +49 -18
- package/src/gateway/backend.ts +3 -3
- package/src/gateway/gateway.ts +12 -56
- package/src/helm.ts +354 -22
- package/src/impl/dynamic-endpoint-resolver.ts +109 -0
- package/src/impl/gateway-route.ts +231 -57
- package/src/impl/tls-certificate.ts +8 -3
- package/src/index.ts +1 -0
- package/src/job.ts +38 -6
- package/src/kubectl.ts +166 -0
- package/src/namespace.ts +47 -3
- package/src/network-policy.ts +1 -1
- package/src/pvc.ts +12 -2
- package/src/rbac.ts +28 -5
- package/src/scripting/bundle.ts +21 -98
- package/src/scripting/environment.ts +4 -10
- package/src/secret.ts +15 -5
- package/src/service.ts +28 -6
- package/src/shared.ts +31 -3
- package/src/stateful-set.ts +49 -18
- package/src/tls.ts +31 -5
- package/src/units/cluster-patch/index.ts +5 -5
- package/src/units/dns01-issuer/index.ts +56 -12
- package/src/units/existing-cluster/index.ts +36 -15
- package/src/units/reduced-access-cluster/index.ts +6 -3
- package/src/worker.ts +4 -2
- package/src/workload.ts +474 -217
- package/LICENSE +0 -21
- package/dist/chunk-4G6LLC2X.js +0 -240
- package/dist/chunk-4G6LLC2X.js.map +0 -1
- package/dist/chunk-BR2CLUUD.js +0 -230
- package/dist/chunk-BR2CLUUD.js.map +0 -1
- package/dist/chunk-DCUMJSO6.js +0 -427
- package/dist/chunk-DCUMJSO6.js.map +0 -1
- package/dist/chunk-FE4SHRAJ.js +0 -286
- package/dist/chunk-FE4SHRAJ.js.map +0 -1
- package/dist/chunk-HH2JJELM.js +0 -13
- package/dist/chunk-HH2JJELM.js.map +0 -1
- package/dist/chunk-KMLRI5UZ.js +0 -155
- package/dist/chunk-KMLRI5UZ.js.map +0 -1
- package/dist/chunk-LGHFSXNT.js.map +0 -1
- package/dist/chunk-MIC2BHGS.js +0 -301
- package/dist/chunk-MIC2BHGS.js.map +0 -1
- package/dist/chunk-OBDQONMV.js +0 -401
- package/dist/chunk-OBDQONMV.js.map +0 -1
- package/dist/chunk-P2VOUU7E.js +0 -1626
- package/dist/chunk-P2VOUU7E.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -9
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-RVB4WWZZ.js +0 -267
- package/dist/chunk-RVB4WWZZ.js.map +0 -1
- package/dist/chunk-TWBMG6TD.js +0 -315
- package/dist/chunk-TWBMG6TD.js.map +0 -1
- package/dist/chunk-VCXWCZ43.js +0 -279
- package/dist/chunk-VCXWCZ43.js.map +0 -1
- package/dist/chunk-YIJUVPU2.js +0 -297
- package/dist/chunk-YIJUVPU2.js.map +0 -1
- package/dist/cron-job-NX4HD4FI.js +0 -8
- package/dist/cron-job-NX4HD4FI.js.map +0 -1
- package/dist/deployment-O2LJ5WR5.js +0 -8
- package/dist/deployment-O2LJ5WR5.js.map +0 -1
- package/dist/impl/gateway-route.js.map +0 -1
- package/dist/impl/tls-certificate.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/job-SYME6Y43.js +0 -8
- package/dist/job-SYME6Y43.js.map +0 -1
- package/dist/stateful-set-VJYKTQ72.js +0 -8
- package/dist/stateful-set-VJYKTQ72.js.map +0 -1
- package/dist/units/cert-manager/index.js.map +0 -1
- package/dist/units/cluster-patch/index.js.map +0 -1
- package/dist/units/dns01-issuer/index.js.map +0 -1
- package/dist/units/existing-cluster/index.js.map +0 -1
- package/dist/units/gateway-api/index.js.map +0 -1
- package/dist/units/reduced-access-cluster/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,29 +1,173 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
import {
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
Gateway,
|
|
4
|
+
HttpRoute,
|
|
5
|
+
TcpRoute,
|
|
6
|
+
UdpRoute,
|
|
7
|
+
mapHttpRouteRuleMatch,
|
|
8
|
+
resolveBackendRef
|
|
9
|
+
} from "./chunk-46ntav0c.js";
|
|
10
|
+
import {
|
|
11
|
+
Certificate
|
|
12
|
+
} from "./chunk-556pc9e6.js";
|
|
13
|
+
import {
|
|
14
|
+
Job
|
|
15
|
+
} from "./chunk-qyshvz32.js";
|
|
16
|
+
import {
|
|
17
|
+
CronJob
|
|
18
|
+
} from "./chunk-tpfyj6fe.js";
|
|
19
|
+
import {
|
|
20
|
+
Chart,
|
|
21
|
+
RenderedChart,
|
|
22
|
+
getChartService,
|
|
23
|
+
getChartServiceOutput,
|
|
24
|
+
resolveHelmChart
|
|
25
|
+
} from "./chunk-pqc6w52f.js";
|
|
26
|
+
import {
|
|
27
|
+
Deployment
|
|
28
|
+
} from "./chunk-7kgjgcft.js";
|
|
29
|
+
import {
|
|
30
|
+
StatefulSet
|
|
31
|
+
} from "./chunk-z6bmpnm7.js";
|
|
32
|
+
import {
|
|
33
|
+
ConfigMap,
|
|
34
|
+
NativeNetworkPolicy,
|
|
35
|
+
NetworkPolicy,
|
|
36
|
+
PersistentVolumeClaim,
|
|
37
|
+
Workload,
|
|
38
|
+
filterPatchOwnedContainersInTemplate,
|
|
39
|
+
getAutoVolumeName,
|
|
40
|
+
getBestEndpoint,
|
|
41
|
+
getFallbackContainerName,
|
|
42
|
+
getWorkloadComponents,
|
|
43
|
+
getWorkloadServiceComponents,
|
|
44
|
+
getWorkloadVolumeResourceUuid,
|
|
45
|
+
mapContainerEnvironment,
|
|
46
|
+
mapContainerToRaw,
|
|
47
|
+
mapEnvironmentSource,
|
|
48
|
+
mapVolumeMount,
|
|
49
|
+
mapWorkloadVolume,
|
|
50
|
+
networkPolicyMediator,
|
|
51
|
+
podSpecDefaults,
|
|
52
|
+
requireBestEndpoint,
|
|
53
|
+
workloadExtraArgs,
|
|
54
|
+
workloadServiceExtraArgs
|
|
55
|
+
} from "./chunk-h1b79v66.js";
|
|
56
|
+
import {
|
|
57
|
+
dns01SolverMediator
|
|
58
|
+
} from "./chunk-de82bbp2.js";
|
|
59
|
+
import {
|
|
60
|
+
createK8sTerminal,
|
|
61
|
+
detectExternalIps
|
|
62
|
+
} from "./chunk-9hs97f1q.js";
|
|
63
|
+
import {
|
|
64
|
+
Service,
|
|
65
|
+
createServiceSpec,
|
|
66
|
+
getServiceType,
|
|
67
|
+
isEndpointFromCluster,
|
|
68
|
+
l4EndpointToServicePort,
|
|
69
|
+
mapContainerPortToServicePort,
|
|
70
|
+
mapServiceToLabelSelector
|
|
71
|
+
} from "./chunk-k4w9zpn5.js";
|
|
72
|
+
import {
|
|
73
|
+
ClusterAccessScope,
|
|
74
|
+
Namespace,
|
|
75
|
+
NamespacedResource,
|
|
76
|
+
Resource,
|
|
77
|
+
Secret,
|
|
78
|
+
commonExtraArgs,
|
|
79
|
+
getClusterKubeconfigContent,
|
|
80
|
+
getEmbeddedSecretFileContent,
|
|
81
|
+
getNamespaceName,
|
|
82
|
+
getProvider,
|
|
83
|
+
getProviderAsync,
|
|
84
|
+
images_default,
|
|
85
|
+
mapMetadata,
|
|
86
|
+
mapNamespaceNameToSelector,
|
|
87
|
+
mapSelectorLikeToSelector,
|
|
88
|
+
validateCluster
|
|
89
|
+
} from "./chunk-facs31cb.js";
|
|
90
|
+
import"./chunk-b05q6fm2.js";
|
|
91
|
+
// src/kubectl.ts
|
|
92
|
+
import { Command, MaterializedFile } from "@highstate/common";
|
|
93
|
+
import {
|
|
94
|
+
ComponentResource,
|
|
95
|
+
output
|
|
96
|
+
} from "@pulumi/pulumi";
|
|
97
|
+
function createCommand(command) {
|
|
98
|
+
if (Array.isArray(command)) {
|
|
99
|
+
return command.join(" ");
|
|
100
|
+
}
|
|
101
|
+
return command;
|
|
102
|
+
}
|
|
103
|
+
function buildKubeCommand(command, namespace) {
|
|
104
|
+
if (namespace) {
|
|
105
|
+
return output([command, namespace]).apply(([cmd, ns]) => `kubectl -n ${ns} ${createCommand(cmd)}`);
|
|
106
|
+
}
|
|
107
|
+
return output(command).apply((cmd) => `kubectl ${createCommand(cmd)}`);
|
|
108
|
+
}
|
|
109
|
+
function buildWorkloadExecCommand(command, workload) {
|
|
110
|
+
return output({
|
|
111
|
+
command,
|
|
112
|
+
kind: output(workload).kind,
|
|
113
|
+
name: output(workload).metadata.name
|
|
114
|
+
}).apply(({ command: command2, kind, name }) => {
|
|
115
|
+
const type = kind.toLowerCase();
|
|
116
|
+
return `exec -it ${type}/${name} -- ${createCommand(command2)}`;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
class KubeCommand extends ComponentResource {
|
|
121
|
+
command;
|
|
122
|
+
stdout;
|
|
123
|
+
stderr;
|
|
124
|
+
constructor(name, args, opts) {
|
|
125
|
+
super("highstate:k8s:KubeCommand", name, args, opts);
|
|
126
|
+
this.command = output(args.cluster).apply((cluster) => {
|
|
127
|
+
const kubeconfig = MaterializedFile.for(cluster.kubeconfig);
|
|
128
|
+
return new Command(`kubectl-${name}`, {
|
|
129
|
+
host: "local",
|
|
130
|
+
create: buildKubeCommand(args.create, args.namespace),
|
|
131
|
+
update: args.update ? buildKubeCommand(args.update, args.namespace) : undefined,
|
|
132
|
+
delete: args.delete ? buildKubeCommand(args.delete, args.namespace) : undefined,
|
|
133
|
+
files: [kubeconfig],
|
|
134
|
+
image: images_default["terminal-kubectl"].image,
|
|
135
|
+
containerShell: "bash",
|
|
136
|
+
environment: {
|
|
137
|
+
KUBECONFIG: kubeconfig.path
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
this.stdout = this.command.stdout;
|
|
142
|
+
this.stderr = this.command.stderr;
|
|
143
|
+
}
|
|
144
|
+
static forNamespace(name, args, opts) {
|
|
145
|
+
return new KubeCommand(name, {
|
|
146
|
+
cluster: output(args.namespace).cluster,
|
|
147
|
+
create: args.create,
|
|
148
|
+
update: args.update,
|
|
149
|
+
delete: args.delete,
|
|
150
|
+
namespace: output(args.namespace).metadata.name
|
|
151
|
+
}, opts);
|
|
152
|
+
}
|
|
153
|
+
static execInto(name, args, opts) {
|
|
154
|
+
return KubeCommand.forNamespace(name, {
|
|
155
|
+
namespace: output(args.workload).namespace,
|
|
156
|
+
create: buildWorkloadExecCommand(args.create, args.workload),
|
|
157
|
+
update: args.update ? buildWorkloadExecCommand(args.update, args.workload) : undefined,
|
|
158
|
+
delete: args.delete ? buildWorkloadExecCommand(args.delete, args.workload) : undefined
|
|
159
|
+
}, opts);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// src/scripting/bundle.ts
|
|
163
|
+
import { parseEndpoint } from "@highstate/common";
|
|
164
|
+
import { text, trimIndentation } from "@highstate/contract";
|
|
165
|
+
import { normalize } from "@highstate/pulumi";
|
|
166
|
+
import {
|
|
167
|
+
ComponentResource as ComponentResource2,
|
|
168
|
+
output as output2
|
|
169
|
+
} from "@pulumi/pulumi";
|
|
170
|
+
import { deepmerge } from "deepmerge-ts";
|
|
27
171
|
|
|
28
172
|
// src/scripting/environment.ts
|
|
29
173
|
var emptyDistributionEnvironment = {
|
|
@@ -34,18 +178,16 @@ var emptyDistributionEnvironment = {
|
|
|
34
178
|
var emptyScriptEnvironment = {
|
|
35
179
|
alpine: {
|
|
36
180
|
...emptyDistributionEnvironment,
|
|
37
|
-
image:
|
|
181
|
+
image: images_default.alpine.image,
|
|
38
182
|
allowedEndpoints: [
|
|
39
|
-
//
|
|
40
183
|
"tcp://dl-cdn.alpinelinux.org:443",
|
|
41
184
|
"tcp://dl-cdn.alpinelinux.org:80"
|
|
42
185
|
]
|
|
43
186
|
},
|
|
44
187
|
ubuntu: {
|
|
45
188
|
...emptyDistributionEnvironment,
|
|
46
|
-
image:
|
|
189
|
+
image: images_default.ubuntu.image,
|
|
47
190
|
allowedEndpoints: [
|
|
48
|
-
//
|
|
49
191
|
"tcp://archive.ubuntu.com:80",
|
|
50
192
|
"tcp://archive.ubuntu.com:443",
|
|
51
193
|
"tcp://security.ubuntu.com:80",
|
|
@@ -60,158 +202,68 @@ var emptyScriptEnvironment = {
|
|
|
60
202
|
environment: {},
|
|
61
203
|
allowedEndpoints: []
|
|
62
204
|
};
|
|
63
|
-
var functionScriptImages = {
|
|
64
|
-
alpine: "oven/bun@sha256:6b14922b0885c3890cdb0b396090af1da486ba941df5ee94391eef64f7113c61",
|
|
65
|
-
ubuntu: "oven/bun@sha256:66b431441dc4c36d7e8164bfc61e6348ec1d7ce2862fc3a29f5dc9856e8205e4"
|
|
66
|
-
};
|
|
67
205
|
|
|
68
206
|
// src/scripting/bundle.ts
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* The config map containing the scripts.
|
|
72
|
-
*/
|
|
207
|
+
class ScriptBundle extends ComponentResource2 {
|
|
73
208
|
configMap;
|
|
74
|
-
/**
|
|
75
|
-
* The volumes that should be included in the workload.
|
|
76
|
-
*/
|
|
77
209
|
volumes;
|
|
78
|
-
/**
|
|
79
|
-
* The volume mounts that should be defined in the container.
|
|
80
|
-
*/
|
|
81
210
|
volumeMounts;
|
|
82
|
-
/**
|
|
83
|
-
* The environment variables that should be defined in the container.
|
|
84
|
-
*/
|
|
85
211
|
environment;
|
|
86
|
-
/**
|
|
87
|
-
* The image to use for the scripts.
|
|
88
|
-
*/
|
|
89
212
|
image;
|
|
90
|
-
/**
|
|
91
|
-
* The distribution to use for the scripts.
|
|
92
|
-
*/
|
|
93
213
|
distribution;
|
|
94
|
-
/**
|
|
95
|
-
* The list of endpoints that the script is allowed to access.
|
|
96
|
-
*/
|
|
97
214
|
allowedEndpoints;
|
|
98
215
|
constructor(name, args, opts) {
|
|
99
216
|
super("highstate:k8s:ScriptBundle", name, args, opts);
|
|
100
|
-
const scriptEnvironment =
|
|
101
|
-
const hasFunctionScripts = scriptEnvironment.apply((scriptEnvironment2) => {
|
|
102
|
-
return Object.values(scriptEnvironment2.files).some((file) => typeof file === "function");
|
|
103
|
-
});
|
|
217
|
+
const scriptEnvironment = output2(args).apply((args2) => normalize(args2.environment, args2.environments)).apply((args2) => deepmerge(emptyScriptEnvironment, ...args2));
|
|
104
218
|
this.distribution = args.distribution;
|
|
105
219
|
this.environment = scriptEnvironment.environment;
|
|
106
|
-
this.image =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
(
|
|
113
|
-
const allowedEndpoints = [
|
|
114
|
-
...scriptEnvironment2.allowedEndpoints,
|
|
115
|
-
...scriptEnvironment2[args.distribution].allowedEndpoints
|
|
116
|
-
];
|
|
117
|
-
if (hasFunctionScripts2) {
|
|
118
|
-
allowedEndpoints.push("tcp://registry.npmjs.org:443");
|
|
119
|
-
}
|
|
120
|
-
return allowedEndpoints.map((endpoint) => parseEndpoint(endpoint));
|
|
121
|
-
}
|
|
122
|
-
);
|
|
123
|
-
this.configMap = output({ scriptEnvironment, args }).apply(({ scriptEnvironment: scriptEnvironment2, args: args2 }) => {
|
|
124
|
-
return ConfigMap.create(
|
|
125
|
-
name,
|
|
126
|
-
{
|
|
127
|
-
namespace: args2.namespace,
|
|
128
|
-
data: createScriptData(this.distribution, scriptEnvironment2)
|
|
129
|
-
},
|
|
130
|
-
{ ...opts, parent: this }
|
|
131
|
-
);
|
|
220
|
+
this.image = scriptEnvironment[args.distribution].image;
|
|
221
|
+
this.allowedEndpoints = scriptEnvironment.apply((scriptEnvironment2) => {
|
|
222
|
+
const allowedEndpoints = [
|
|
223
|
+
...scriptEnvironment2.allowedEndpoints,
|
|
224
|
+
...scriptEnvironment2[args.distribution].allowedEndpoints
|
|
225
|
+
];
|
|
226
|
+
return allowedEndpoints.map((endpoint) => parseEndpoint(endpoint));
|
|
132
227
|
});
|
|
133
|
-
this.
|
|
134
|
-
(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
228
|
+
this.configMap = output2({ scriptEnvironment, args }).apply(({ scriptEnvironment: scriptEnvironment2, args: args2 }) => {
|
|
229
|
+
return ConfigMap.create(name, {
|
|
230
|
+
namespace: args2.namespace,
|
|
231
|
+
data: createScriptData(this.distribution, scriptEnvironment2)
|
|
232
|
+
}, { ...opts, parent: this });
|
|
233
|
+
});
|
|
234
|
+
this.volumes = scriptEnvironment.volumes.apply((volumes) => {
|
|
235
|
+
return [
|
|
236
|
+
...volumes,
|
|
237
|
+
{
|
|
238
|
+
name: this.configMap.metadata.name,
|
|
239
|
+
configMap: {
|
|
138
240
|
name: this.configMap.metadata.name,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
...hasFunctionScripts2 ? [{ name: "node-modules", emptyDir: {} }] : []
|
|
146
|
-
];
|
|
147
|
-
}
|
|
148
|
-
);
|
|
149
|
-
this.volumeMounts = output({
|
|
150
|
-
hasFunctionScripts,
|
|
151
|
-
volumeMounts: scriptEnvironment.volumeMounts
|
|
152
|
-
}).apply(({ hasFunctionScripts: hasFunctionScripts2, volumeMounts }) => {
|
|
241
|
+
defaultMode: 360
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
];
|
|
245
|
+
});
|
|
246
|
+
this.volumeMounts = scriptEnvironment.volumeMounts.apply((volumeMounts) => {
|
|
153
247
|
return [
|
|
154
248
|
...volumeMounts,
|
|
155
249
|
{
|
|
156
250
|
volume: this.configMap,
|
|
157
251
|
mountPath: "/scripts"
|
|
158
|
-
}
|
|
159
|
-
...hasFunctionScripts2 ? [{ name: "node-modules", mountPath: "/scripts/node_modules" }] : []
|
|
252
|
+
}
|
|
160
253
|
];
|
|
161
254
|
});
|
|
162
255
|
}
|
|
163
|
-
};
|
|
164
|
-
function stripWorkspacePrefix(value) {
|
|
165
|
-
if (value.startsWith("workspace:")) {
|
|
166
|
-
return value.replace("workspace:", "");
|
|
167
|
-
}
|
|
168
|
-
return value;
|
|
169
256
|
}
|
|
170
257
|
async function createScriptData(distribution, environment) {
|
|
171
258
|
const scriptData = {};
|
|
172
259
|
const actions = [];
|
|
173
260
|
const distributionEnvironment = environment[distribution];
|
|
174
261
|
const setupScripts = { ...environment.setupScripts };
|
|
175
|
-
let hasFunctionScripts = false;
|
|
176
262
|
for (const key in environment.files) {
|
|
177
|
-
|
|
178
|
-
const serialized = await serializeFunction(environment.files[key]);
|
|
179
|
-
scriptData[key] = text`
|
|
180
|
-
#!/usr/local/bin/bun
|
|
181
|
-
|
|
182
|
-
${serialized.text}
|
|
183
|
-
|
|
184
|
-
exports.${serialized.exportName}()
|
|
185
|
-
`;
|
|
186
|
-
hasFunctionScripts = true;
|
|
187
|
-
} else {
|
|
188
|
-
scriptData[key] = environment.files[key];
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
if (hasFunctionScripts) {
|
|
192
|
-
const packageJson = await readPackageJSON();
|
|
193
|
-
packageJson.dependencies = omitBy(
|
|
194
|
-
mapValues(packageJson.dependencies ?? {}, stripWorkspacePrefix),
|
|
195
|
-
(_, key) => key.startsWith("@highstate/")
|
|
196
|
-
);
|
|
197
|
-
packageJson.devDependencies = omitBy(
|
|
198
|
-
mapValues(packageJson.devDependencies ?? {}, stripWorkspacePrefix),
|
|
199
|
-
(_, key) => key.startsWith("@highstate/")
|
|
200
|
-
);
|
|
201
|
-
scriptData["package.json"] = JSON.stringify(packageJson, null, 2);
|
|
202
|
-
setupScripts["resolve-dependencies.sh"] = text`
|
|
203
|
-
#!/usr/local/bin/bun
|
|
204
|
-
set -e
|
|
205
|
-
|
|
206
|
-
cd /scripts
|
|
207
|
-
bun install --production
|
|
208
|
-
`;
|
|
263
|
+
scriptData[key] = environment.files[key];
|
|
209
264
|
}
|
|
210
265
|
if (distributionEnvironment.preInstallPackages.length > 0) {
|
|
211
|
-
scriptData["pre-install-packages.sh"] = getInstallPackagesScript(
|
|
212
|
-
distribution,
|
|
213
|
-
distributionEnvironment.preInstallPackages
|
|
214
|
-
);
|
|
266
|
+
scriptData["pre-install-packages.sh"] = getInstallPackagesScript(distribution, distributionEnvironment.preInstallPackages);
|
|
215
267
|
actions.push(`
|
|
216
268
|
echo "+ Installing pre-install packages..."
|
|
217
269
|
/scripts/pre-install-packages.sh
|
|
@@ -229,10 +281,7 @@ async function createScriptData(distribution, environment) {
|
|
|
229
281
|
}
|
|
230
282
|
}
|
|
231
283
|
if (distributionEnvironment.packages.length > 0) {
|
|
232
|
-
scriptData["install-packages.sh"] = getInstallPackagesScript(
|
|
233
|
-
distribution,
|
|
234
|
-
distributionEnvironment.packages
|
|
235
|
-
);
|
|
284
|
+
scriptData["install-packages.sh"] = getInstallPackagesScript(distribution, distributionEnvironment.packages);
|
|
236
285
|
actions.push(`
|
|
237
286
|
echo "+ Installing packages..."
|
|
238
287
|
/scripts/install-packages.sh
|
|
@@ -261,7 +310,9 @@ async function createScriptData(distribution, environment) {
|
|
|
261
310
|
}
|
|
262
311
|
actions.push(`
|
|
263
312
|
function cleanup() {
|
|
264
|
-
${cleanupActions.map((s) => s.trim()).join(
|
|
313
|
+
${cleanupActions.map((s) => s.trim()).join(`
|
|
314
|
+
|
|
315
|
+
`)}
|
|
265
316
|
}
|
|
266
317
|
|
|
267
318
|
trap cleanup EXIT
|
|
@@ -277,7 +328,9 @@ async function createScriptData(distribution, environment) {
|
|
|
277
328
|
exit 1
|
|
278
329
|
fi
|
|
279
330
|
|
|
280
|
-
${actions.map((s) => s.trim()).join(
|
|
331
|
+
${actions.map((s) => s.trim()).join(`
|
|
332
|
+
|
|
333
|
+
`)}
|
|
281
334
|
|
|
282
335
|
echo "+ Running main script..."
|
|
283
336
|
$@
|
|
@@ -303,9 +356,12 @@ function getInstallPackagesScript(distribution, packages) {
|
|
|
303
356
|
`;
|
|
304
357
|
}
|
|
305
358
|
}
|
|
359
|
+
// src/scripting/container.ts
|
|
360
|
+
import { output as output3 } from "@pulumi/pulumi";
|
|
361
|
+
import { merge } from "remeda";
|
|
306
362
|
function createScriptContainer(options) {
|
|
307
|
-
const bundle =
|
|
308
|
-
return
|
|
363
|
+
const bundle = output3(options.bundle);
|
|
364
|
+
return output3({
|
|
309
365
|
options,
|
|
310
366
|
image: bundle.image,
|
|
311
367
|
volumeMounts: bundle.volumeMounts,
|
|
@@ -324,24 +380,95 @@ function createScriptContainer(options) {
|
|
|
324
380
|
};
|
|
325
381
|
});
|
|
326
382
|
}
|
|
383
|
+
// src/worker.ts
|
|
384
|
+
import { output as output4 } from "@pulumi/pulumi";
|
|
327
385
|
async function createMonitorWorker(namespace, resources) {
|
|
328
386
|
const scope = new ClusterAccessScope("monitor", {
|
|
329
387
|
rule: {
|
|
388
|
+
apiGroups: ["", "apps"],
|
|
389
|
+
resources: ["deployments", "statefulsets", "services", "pods"],
|
|
330
390
|
verbs: ["get", "list", "watch"]
|
|
331
391
|
},
|
|
332
392
|
namespace,
|
|
333
393
|
resources
|
|
334
394
|
});
|
|
335
|
-
return
|
|
395
|
+
return output4({
|
|
336
396
|
name: "monitor",
|
|
337
|
-
image:
|
|
397
|
+
image: images_default["worker.k8s-monitor"].image,
|
|
338
398
|
params: {
|
|
339
|
-
kubeconfig: scope.cluster
|
|
340
|
-
resources:
|
|
399
|
+
kubeconfig: getClusterKubeconfigContent(scope.cluster),
|
|
400
|
+
resources: output4(resources).apply((resources2) => resources2.map((r) => r.entity))
|
|
341
401
|
}
|
|
342
402
|
});
|
|
343
403
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
404
|
+
export {
|
|
405
|
+
workloadServiceExtraArgs,
|
|
406
|
+
workloadExtraArgs,
|
|
407
|
+
validateCluster,
|
|
408
|
+
resolveHelmChart,
|
|
409
|
+
resolveBackendRef,
|
|
410
|
+
requireBestEndpoint,
|
|
411
|
+
podSpecDefaults,
|
|
412
|
+
networkPolicyMediator,
|
|
413
|
+
mapWorkloadVolume,
|
|
414
|
+
mapVolumeMount,
|
|
415
|
+
mapServiceToLabelSelector,
|
|
416
|
+
mapSelectorLikeToSelector,
|
|
417
|
+
mapNamespaceNameToSelector,
|
|
418
|
+
mapMetadata,
|
|
419
|
+
mapHttpRouteRuleMatch,
|
|
420
|
+
mapEnvironmentSource,
|
|
421
|
+
mapContainerToRaw,
|
|
422
|
+
mapContainerPortToServicePort,
|
|
423
|
+
mapContainerEnvironment,
|
|
424
|
+
l4EndpointToServicePort,
|
|
425
|
+
isEndpointFromCluster,
|
|
426
|
+
images_default as images,
|
|
427
|
+
getWorkloadVolumeResourceUuid,
|
|
428
|
+
getWorkloadServiceComponents,
|
|
429
|
+
getWorkloadComponents,
|
|
430
|
+
getServiceType,
|
|
431
|
+
getProviderAsync,
|
|
432
|
+
getProvider,
|
|
433
|
+
getNamespaceName,
|
|
434
|
+
getFallbackContainerName,
|
|
435
|
+
getEmbeddedSecretFileContent,
|
|
436
|
+
getClusterKubeconfigContent,
|
|
437
|
+
getChartServiceOutput,
|
|
438
|
+
getChartService,
|
|
439
|
+
getBestEndpoint,
|
|
440
|
+
getAutoVolumeName,
|
|
441
|
+
filterPatchOwnedContainersInTemplate,
|
|
442
|
+
emptyScriptEnvironment,
|
|
443
|
+
dns01SolverMediator,
|
|
444
|
+
detectExternalIps,
|
|
445
|
+
createServiceSpec,
|
|
446
|
+
createScriptContainer,
|
|
447
|
+
createMonitorWorker,
|
|
448
|
+
createK8sTerminal,
|
|
449
|
+
commonExtraArgs,
|
|
450
|
+
Workload,
|
|
451
|
+
UdpRoute,
|
|
452
|
+
TcpRoute,
|
|
453
|
+
StatefulSet,
|
|
454
|
+
Service,
|
|
455
|
+
Secret,
|
|
456
|
+
ScriptBundle,
|
|
457
|
+
Resource,
|
|
458
|
+
RenderedChart,
|
|
459
|
+
PersistentVolumeClaim,
|
|
460
|
+
NetworkPolicy,
|
|
461
|
+
NativeNetworkPolicy,
|
|
462
|
+
NamespacedResource,
|
|
463
|
+
Namespace,
|
|
464
|
+
KubeCommand,
|
|
465
|
+
Job,
|
|
466
|
+
HttpRoute,
|
|
467
|
+
Gateway,
|
|
468
|
+
Deployment,
|
|
469
|
+
CronJob,
|
|
470
|
+
ConfigMap,
|
|
471
|
+
ClusterAccessScope,
|
|
472
|
+
Chart,
|
|
473
|
+
Certificate
|
|
474
|
+
};
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
Chart
|
|
4
|
+
} from "../../chunk-pqc6w52f.js";
|
|
5
|
+
import"../../chunk-7kgjgcft.js";
|
|
6
|
+
import"../../chunk-z6bmpnm7.js";
|
|
7
|
+
import"../../chunk-h1b79v66.js";
|
|
8
|
+
import"../../chunk-k4w9zpn5.js";
|
|
9
|
+
import {
|
|
10
|
+
Namespace
|
|
11
|
+
} from "../../chunk-facs31cb.js";
|
|
12
|
+
import"../../chunk-b05q6fm2.js";
|
|
13
|
+
|
|
14
|
+
// src/units/cert-manager/index.ts
|
|
15
|
+
import { k8s } from "@highstate/library";
|
|
16
|
+
import { forUnit } from "@highstate/pulumi";
|
|
11
17
|
|
|
12
18
|
// assets/charts.json
|
|
13
19
|
var charts_default = {
|
|
@@ -39,7 +45,6 @@ new Chart("cert-manager", {
|
|
|
39
45
|
var cert_manager_default = outputs({
|
|
40
46
|
k8sCluster: inputs.k8sCluster
|
|
41
47
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
//# sourceMappingURL=index.js.map
|
|
48
|
+
export {
|
|
49
|
+
cert_manager_default as default
|
|
50
|
+
};
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { k8s } from '@highstate/library';
|
|
4
|
-
import { forUnit, toPromise } from '@highstate/pulumi';
|
|
1
|
+
// @bun
|
|
2
|
+
import"../../chunk-b05q6fm2.js";
|
|
5
3
|
|
|
4
|
+
// src/units/cluster-patch/index.ts
|
|
5
|
+
import { l3EndpointToString, l4EndpointToString, parseEndpoints } from "@highstate/common";
|
|
6
|
+
import { k8s } from "@highstate/library";
|
|
7
|
+
import { forUnit, toPromise } from "@highstate/pulumi";
|
|
6
8
|
var { args, inputs, outputs } = forUnit(k8s.clusterPatch);
|
|
7
9
|
var cluster = await toPromise(inputs.k8sCluster);
|
|
8
|
-
var endpoints =
|
|
9
|
-
var apiEndpoints =
|
|
10
|
+
var endpoints = parseEndpoints([...args.endpoints, ...inputs.endpoints], 3);
|
|
11
|
+
var apiEndpoints = parseEndpoints([...args.apiEndpoints, ...inputs.apiEndpoints], 4);
|
|
10
12
|
var newEndpoints = endpoints.length > 0 ? endpoints : cluster.endpoints;
|
|
11
13
|
var newApiEndpoints = apiEndpoints.length > 0 ? apiEndpoints : cluster.apiEndpoints;
|
|
12
14
|
var cluster_patch_default = outputs({
|
|
13
|
-
k8sCluster:
|
|
14
|
-
...k8sCluster,
|
|
15
|
+
k8sCluster: {
|
|
16
|
+
...inputs.k8sCluster,
|
|
15
17
|
endpoints: newEndpoints,
|
|
16
18
|
apiEndpoints: newApiEndpoints
|
|
17
|
-
}
|
|
19
|
+
},
|
|
18
20
|
$statusFields: {
|
|
19
21
|
endpoints: endpoints.map(l3EndpointToString),
|
|
20
22
|
apiEndpoints: apiEndpoints.map(l4EndpointToString)
|
|
21
23
|
}
|
|
22
24
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=index.js.map
|
|
25
|
+
export {
|
|
26
|
+
cluster_patch_default as default
|
|
27
|
+
};
|