@highstate/k8s 0.20.0 → 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-ADHZK6V2.js → chunk-9hs97f1q.js} +13 -11
- 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 -3
- package/dist/impl/dynamic-endpoint-resolver.js +82 -81
- package/dist/impl/gateway-route.js +131 -168
- package/dist/impl/tls-certificate.js +31 -32
- package/dist/index.js +245 -201
- package/dist/units/cert-manager/index.js +19 -13
- package/dist/units/cluster-patch/index.js +9 -8
- package/dist/units/dns01-issuer/index.js +44 -41
- package/dist/units/existing-cluster/index.js +25 -13
- package/dist/units/gateway-api/index.js +15 -16
- package/dist/units/reduced-access-cluster/index.js +28 -32
- package/package.json +21 -21
- package/src/cron-job.ts +26 -1
- package/src/deployment.ts +17 -1
- package/src/job.ts +15 -1
- package/src/scripting/bundle.ts +21 -98
- package/src/scripting/environment.ts +2 -9
- package/src/shared.ts +1 -1
- package/src/stateful-set.ts +17 -1
- package/src/workload.ts +31 -14
- package/LICENSE +0 -21
- package/dist/chunk-23X5SXQG.js +0 -301
- package/dist/chunk-23X5SXQG.js.map +0 -1
- package/dist/chunk-ADHZK6V2.js.map +0 -1
- package/dist/chunk-BTAEFJ5N.js +0 -291
- package/dist/chunk-BTAEFJ5N.js.map +0 -1
- package/dist/chunk-HH2JJELM.js +0 -13
- package/dist/chunk-HH2JJELM.js.map +0 -1
- package/dist/chunk-IXE3OKB4.js +0 -249
- package/dist/chunk-IXE3OKB4.js.map +0 -1
- package/dist/chunk-OG2OPX7B.js +0 -333
- package/dist/chunk-OG2OPX7B.js.map +0 -1
- package/dist/chunk-P26SQ2ZB.js +0 -393
- package/dist/chunk-P26SQ2ZB.js.map +0 -1
- package/dist/chunk-PG27ZY2H.js +0 -319
- package/dist/chunk-PG27ZY2H.js.map +0 -1
- package/dist/chunk-PZYGZSN5.js +0 -54
- package/dist/chunk-PZYGZSN5.js.map +0 -1
- package/dist/chunk-S77TE7UC.js +0 -309
- package/dist/chunk-S77TE7UC.js.map +0 -1
- package/dist/chunk-SZKOAHNX.js +0 -1804
- package/dist/chunk-SZKOAHNX.js.map +0 -1
- package/dist/chunk-TOLFVF4S.js +0 -889
- package/dist/chunk-TOLFVF4S.js.map +0 -1
- package/dist/chunk-TVKT3ZYX.js +0 -423
- package/dist/chunk-TVKT3ZYX.js.map +0 -1
- package/dist/cron-job-RKB2HYTO.js +0 -7
- package/dist/cron-job-RKB2HYTO.js.map +0 -1
- package/dist/deployment-T35TUOL2.js +0 -7
- package/dist/deployment-T35TUOL2.js.map +0 -1
- package/dist/impl/dynamic-endpoint-resolver.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-PE4AKOHB.js +0 -7
- package/dist/job-PE4AKOHB.js.map +0 -1
- package/dist/stateful-set-LUIRHQJY.js +0 -7
- package/dist/stateful-set-LUIRHQJY.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
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
Service
|
|
4
|
+
} from "./chunk-k4w9zpn5.js";
|
|
5
|
+
import {
|
|
6
|
+
Namespace,
|
|
7
|
+
NamespacedResource,
|
|
8
|
+
commonExtraArgs,
|
|
9
|
+
getProvider,
|
|
10
|
+
mapMetadata
|
|
11
|
+
} from "./chunk-facs31cb.js";
|
|
12
|
+
|
|
13
|
+
// src/gateway/backend.ts
|
|
14
|
+
import { output } from "@highstate/pulumi";
|
|
15
|
+
function resolveBackendRef(ref) {
|
|
16
|
+
if (Service.isInstance(ref)) {
|
|
17
|
+
return output({
|
|
18
|
+
name: ref.metadata.name,
|
|
19
|
+
namespace: ref.metadata.namespace,
|
|
20
|
+
port: ref.spec.ports[0].port
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if ("service" in ref) {
|
|
24
|
+
const service = output(ref.service);
|
|
25
|
+
return output({
|
|
26
|
+
name: service.metadata.name,
|
|
27
|
+
namespace: service.metadata.namespace,
|
|
28
|
+
port: ref.port ?? service.spec.ports[0].port
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return output({
|
|
32
|
+
name: ref.name,
|
|
33
|
+
namespace: ref.namespace,
|
|
34
|
+
port: ref.port
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/gateway/gateway.ts
|
|
39
|
+
import { parseEndpoint } from "@highstate/common";
|
|
40
|
+
import { getOrCreate } from "@highstate/contract";
|
|
41
|
+
import { gateway } from "@highstate/gateway-api";
|
|
42
|
+
import { k8s } from "@highstate/library";
|
|
43
|
+
import {
|
|
44
|
+
interpolate,
|
|
45
|
+
makeEntityOutput,
|
|
46
|
+
output as output2,
|
|
47
|
+
toPromise
|
|
48
|
+
} from "@highstate/pulumi";
|
|
49
|
+
import { omit } from "remeda";
|
|
50
|
+
var gatewayExtraArgs = [...commonExtraArgs, "fqdn", "fqdns"];
|
|
51
|
+
|
|
52
|
+
class Gateway extends NamespacedResource {
|
|
53
|
+
spec;
|
|
54
|
+
status;
|
|
55
|
+
static apiVersion = "gateway.networking.k8s.io/v1";
|
|
56
|
+
static kind = "Gateway";
|
|
57
|
+
constructor(type, name, args, opts, metadata, namespace, spec, status) {
|
|
58
|
+
super(type, name, args, opts, metadata, namespace);
|
|
59
|
+
this.spec = spec;
|
|
60
|
+
this.status = status;
|
|
61
|
+
}
|
|
62
|
+
get entity() {
|
|
63
|
+
return makeEntityOutput({
|
|
64
|
+
entity: k8s.gatewayEntity,
|
|
65
|
+
identity: this.metadata.uid,
|
|
66
|
+
meta: {
|
|
67
|
+
title: this.metadata.name
|
|
68
|
+
},
|
|
69
|
+
value: {
|
|
70
|
+
...this.entityBase
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
get endpoints() {
|
|
75
|
+
return this.status.addresses.apply((addresses) => {
|
|
76
|
+
if (!addresses) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
return addresses.map((address) => parseEndpoint(address.value));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
static create(name, args, opts) {
|
|
83
|
+
return new CreatedGateway(name, args, opts);
|
|
84
|
+
}
|
|
85
|
+
static createOrPatch(name, args, opts) {
|
|
86
|
+
if (args.existing) {
|
|
87
|
+
return new GatewayPatch(name, {
|
|
88
|
+
...args,
|
|
89
|
+
name: output2(args.existing).metadata.name,
|
|
90
|
+
namespace: Namespace.forResourceAsync(args.existing, output2(args.namespace).cluster)
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return new CreatedGateway(name, args, opts);
|
|
94
|
+
}
|
|
95
|
+
static async createOrGet(name, args, opts) {
|
|
96
|
+
if (args.existing) {
|
|
97
|
+
return await Gateway.forAsync(args.existing, output2(args.namespace).cluster);
|
|
98
|
+
}
|
|
99
|
+
return new CreatedGateway(name, args, opts);
|
|
100
|
+
}
|
|
101
|
+
static patch(name, args, opts) {
|
|
102
|
+
return new GatewayPatch(name, args, opts);
|
|
103
|
+
}
|
|
104
|
+
static wrap(name, args, opts) {
|
|
105
|
+
return new WrappedGateway(name, args, opts);
|
|
106
|
+
}
|
|
107
|
+
static get(name, args, opts) {
|
|
108
|
+
return new ExternalGateway(name, args, opts);
|
|
109
|
+
}
|
|
110
|
+
static gatewayCache = new Map;
|
|
111
|
+
static for(entity, cluster) {
|
|
112
|
+
return getOrCreate(Gateway.gatewayCache, `${entity.clusterName}.${entity.metadata.namespace}.${entity.metadata.name}.${entity.clusterId}`, (name) => {
|
|
113
|
+
return Gateway.get(name, {
|
|
114
|
+
name: entity.metadata.name,
|
|
115
|
+
namespace: Namespace.forResourceAsync(entity, cluster)
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
static async forAsync(entity, cluster) {
|
|
120
|
+
const resolvedEntity = await toPromise(entity);
|
|
121
|
+
return Gateway.for(resolvedEntity, output2(cluster));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
class CreatedGateway extends Gateway {
|
|
126
|
+
constructor(name, args, opts) {
|
|
127
|
+
const gatewayResource = output2(args.namespace).cluster.apply((cluster) => {
|
|
128
|
+
return new gateway.v1.Gateway(name, {
|
|
129
|
+
metadata: mapMetadata(args, name),
|
|
130
|
+
spec: omit(args, gatewayExtraArgs)
|
|
131
|
+
}, { ...opts, parent: this, provider: getProvider(cluster) });
|
|
132
|
+
});
|
|
133
|
+
super("highstate:k8s:Gateway", name, args, opts, gatewayResource.metadata, output2(args.namespace), gatewayResource.spec, gatewayResource.status);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
class GatewayPatch extends Gateway {
|
|
138
|
+
constructor(name, args, opts) {
|
|
139
|
+
const gatewayResource = output2(args.namespace).cluster.apply((cluster) => {
|
|
140
|
+
return new gateway.v1.GatewayPatch(name, {
|
|
141
|
+
metadata: mapMetadata(args, name),
|
|
142
|
+
spec: omit(args, gatewayExtraArgs)
|
|
143
|
+
}, { ...opts, parent: this, provider: getProvider(cluster) });
|
|
144
|
+
});
|
|
145
|
+
super("highstate:k8s:GatewayPatch", name, args, opts, gatewayResource.metadata, output2(args.namespace), gatewayResource.spec, gatewayResource.status);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
class WrappedGateway extends Gateway {
|
|
150
|
+
constructor(name, args, opts) {
|
|
151
|
+
super("highstate:k8s:WrappedGateway", name, args, opts, output2(args.gateway).metadata, output2(args.namespace), output2(args.gateway).spec, output2(args.gateway).status);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
class ExternalGateway extends Gateway {
|
|
156
|
+
constructor(name, args, opts) {
|
|
157
|
+
const gatewayResource = output2(args.namespace).cluster.apply((cluster) => {
|
|
158
|
+
return gateway.v1.Gateway.get(name, interpolate`${output2(args.namespace).metadata.name}/${args.name}`, { ...opts, parent: this, provider: getProvider(cluster) });
|
|
159
|
+
});
|
|
160
|
+
super("highstate:k8s:ExternalGateway", name, args, opts, gatewayResource.metadata, output2(args.namespace), gatewayResource.spec, gatewayResource.status);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/gateway/http-route.ts
|
|
165
|
+
import { gateway as gateway2 } from "@highstate/gateway-api";
|
|
166
|
+
import {
|
|
167
|
+
ComponentResource,
|
|
168
|
+
normalize,
|
|
169
|
+
normalizeInputs,
|
|
170
|
+
normalizeInputsAndMap,
|
|
171
|
+
output as output3
|
|
172
|
+
} from "@highstate/pulumi";
|
|
173
|
+
import { map, pipe } from "remeda";
|
|
174
|
+
class HttpRoute extends ComponentResource {
|
|
175
|
+
route;
|
|
176
|
+
constructor(name, args, opts) {
|
|
177
|
+
super("highstate:k8s:HttpRoute", name, args, opts);
|
|
178
|
+
this.route = output3(args.gateway).cluster.apply((cluster) => {
|
|
179
|
+
return new gateway2.v1.HTTPRoute(name, {
|
|
180
|
+
metadata: mapMetadata(args, name).apply((metadata) => ({
|
|
181
|
+
...metadata,
|
|
182
|
+
namespace: output3(args.gateway).namespace.metadata.name
|
|
183
|
+
})),
|
|
184
|
+
spec: {
|
|
185
|
+
hostnames: normalizeInputs(args.hostname, args.hostnames),
|
|
186
|
+
parentRefs: [
|
|
187
|
+
{
|
|
188
|
+
name: output3(args.gateway).metadata.name
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
rules: normalizeInputsAndMap(args.rule, args.rules, (rule) => ({
|
|
192
|
+
timeouts: rule.timeouts,
|
|
193
|
+
matches: pipe(normalize(rule.match, rule.matches), map(mapHttpRouteRuleMatch), addDefaultPathMatch),
|
|
194
|
+
filters: normalize(rule.filter, rule.filters),
|
|
195
|
+
backendRefs: normalizeInputsAndMap(rule.backend, rule.backends, resolveBackendRef)
|
|
196
|
+
}))
|
|
197
|
+
}
|
|
198
|
+
}, { ...opts, parent: this, provider: getProvider(cluster) });
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function addDefaultPathMatch(matches) {
|
|
203
|
+
return matches.length ? matches : [{ path: { type: "PathPrefix", value: "/" } }];
|
|
204
|
+
}
|
|
205
|
+
function mapHttpRouteRuleMatch(match) {
|
|
206
|
+
if (typeof match === "string") {
|
|
207
|
+
return { path: { type: "PathPrefix", value: match } };
|
|
208
|
+
}
|
|
209
|
+
return match;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// src/gateway/tcp-route.ts
|
|
213
|
+
import { gateway as gateway3 } from "@highstate/gateway-api";
|
|
214
|
+
import {
|
|
215
|
+
ComponentResource as ComponentResource2,
|
|
216
|
+
normalizeInputsAndMap as normalizeInputsAndMap2,
|
|
217
|
+
output as output4
|
|
218
|
+
} from "@highstate/pulumi";
|
|
219
|
+
class TcpRoute extends ComponentResource2 {
|
|
220
|
+
route;
|
|
221
|
+
constructor(name, args, opts) {
|
|
222
|
+
super("highstate:k8s:TcpRoute", name, args, opts);
|
|
223
|
+
const gatewayOutput = output4(args.gateway);
|
|
224
|
+
const parentRefs = output4({
|
|
225
|
+
gateway: gatewayOutput,
|
|
226
|
+
listenerName: args.listenerName
|
|
227
|
+
}).apply(({ gateway: gateway4, listenerName }) => [
|
|
228
|
+
{
|
|
229
|
+
group: "gateway.networking.k8s.io",
|
|
230
|
+
kind: "Gateway",
|
|
231
|
+
name: gateway4.metadata.name,
|
|
232
|
+
namespace: gateway4.namespace.metadata.name,
|
|
233
|
+
sectionName: listenerName
|
|
234
|
+
}
|
|
235
|
+
]);
|
|
236
|
+
const backendRefs = normalizeInputsAndMap2(args.backend, args.backends, resolveBackendRef);
|
|
237
|
+
this.route = gatewayOutput.cluster.apply((cluster) => {
|
|
238
|
+
return new gateway3.v1alpha2.TCPRoute(name, {
|
|
239
|
+
metadata: mapMetadata(args, name).apply((metadata) => ({
|
|
240
|
+
...metadata,
|
|
241
|
+
namespace: gatewayOutput.namespace.metadata.name
|
|
242
|
+
})),
|
|
243
|
+
spec: {
|
|
244
|
+
parentRefs,
|
|
245
|
+
rules: [
|
|
246
|
+
{
|
|
247
|
+
backendRefs
|
|
248
|
+
}
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
}, { ...opts, parent: this, provider: getProvider(cluster) });
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// src/gateway/udp-route.ts
|
|
257
|
+
import { gateway as gateway4 } from "@highstate/gateway-api";
|
|
258
|
+
import {
|
|
259
|
+
ComponentResource as ComponentResource3,
|
|
260
|
+
normalizeInputsAndMap as normalizeInputsAndMap3,
|
|
261
|
+
output as output5
|
|
262
|
+
} from "@highstate/pulumi";
|
|
263
|
+
class UdpRoute extends ComponentResource3 {
|
|
264
|
+
route;
|
|
265
|
+
constructor(name, args, opts) {
|
|
266
|
+
super("highstate:k8s:UdpRoute", name, args, opts);
|
|
267
|
+
const gatewayOutput = output5(args.gateway);
|
|
268
|
+
const parentRefs = output5({
|
|
269
|
+
gateway: gatewayOutput,
|
|
270
|
+
listenerName: args.listenerName
|
|
271
|
+
}).apply(({ gateway: gateway5, listenerName }) => [
|
|
272
|
+
{
|
|
273
|
+
group: "gateway.networking.k8s.io",
|
|
274
|
+
kind: "Gateway",
|
|
275
|
+
name: gateway5.metadata.name,
|
|
276
|
+
namespace: gateway5.namespace.metadata.name,
|
|
277
|
+
sectionName: listenerName
|
|
278
|
+
}
|
|
279
|
+
]);
|
|
280
|
+
const backendRefs = normalizeInputsAndMap3(args.backend, args.backends, resolveBackendRef);
|
|
281
|
+
this.route = gatewayOutput.cluster.apply((cluster) => {
|
|
282
|
+
return new gateway4.v1alpha2.UDPRoute(name, {
|
|
283
|
+
metadata: mapMetadata(args, name).apply((metadata) => ({
|
|
284
|
+
...metadata,
|
|
285
|
+
namespace: gatewayOutput.namespace.metadata.name
|
|
286
|
+
})),
|
|
287
|
+
spec: {
|
|
288
|
+
parentRefs,
|
|
289
|
+
rules: [
|
|
290
|
+
{
|
|
291
|
+
backendRefs
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
}
|
|
295
|
+
}, { ...opts, parent: this, provider: getProvider(cluster) });
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
export { resolveBackendRef, Gateway, HttpRoute, mapHttpRouteRuleMatch, TcpRoute, UdpRoute };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
Namespace,
|
|
4
|
+
NamespacedResource,
|
|
5
|
+
Secret,
|
|
6
|
+
commonExtraArgs,
|
|
7
|
+
getProvider,
|
|
8
|
+
mapMetadata
|
|
9
|
+
} from "./chunk-facs31cb.js";
|
|
10
|
+
|
|
11
|
+
// src/tls.ts
|
|
12
|
+
import { cert_manager } from "@highstate/cert-manager";
|
|
13
|
+
import { getOrCreate } from "@highstate/contract";
|
|
14
|
+
import { k8s } from "@highstate/library";
|
|
15
|
+
import {
|
|
16
|
+
interpolate,
|
|
17
|
+
makeEntityOutput,
|
|
18
|
+
output,
|
|
19
|
+
toPromise
|
|
20
|
+
} from "@highstate/pulumi";
|
|
21
|
+
import { omit } from "remeda";
|
|
22
|
+
var certManagerCertificateWaitFor = "condition=Ready";
|
|
23
|
+
function mapCertificateMetadata(args, fallbackName) {
|
|
24
|
+
return mapMetadata(args, fallbackName).apply((metadata) => ({
|
|
25
|
+
...metadata,
|
|
26
|
+
annotations: {
|
|
27
|
+
...metadata.annotations,
|
|
28
|
+
"pulumi.com/waitFor": metadata.annotations?.["pulumi.com/waitFor"] ?? certManagerCertificateWaitFor
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class Certificate extends NamespacedResource {
|
|
34
|
+
name;
|
|
35
|
+
spec;
|
|
36
|
+
status;
|
|
37
|
+
static apiVersion = "cert-manager.io/v1";
|
|
38
|
+
static kind = "Certificate";
|
|
39
|
+
_secret;
|
|
40
|
+
constructor(type, name, args, opts, metadata, namespace, spec, status) {
|
|
41
|
+
super(type, name, args, opts, metadata, namespace);
|
|
42
|
+
this.name = name;
|
|
43
|
+
this.spec = spec;
|
|
44
|
+
this.status = status;
|
|
45
|
+
}
|
|
46
|
+
get entity() {
|
|
47
|
+
return makeEntityOutput({
|
|
48
|
+
entity: k8s.certificateEntity,
|
|
49
|
+
identity: this.metadata.uid,
|
|
50
|
+
meta: {
|
|
51
|
+
title: this.metadata.name
|
|
52
|
+
},
|
|
53
|
+
value: {
|
|
54
|
+
...this.entityBase
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
get secret() {
|
|
59
|
+
if (this._secret) {
|
|
60
|
+
return this._secret;
|
|
61
|
+
}
|
|
62
|
+
this._secret = output({
|
|
63
|
+
secretName: this.spec.apply((spec) => spec.secretName),
|
|
64
|
+
namespace: this.namespace
|
|
65
|
+
}).apply(({ secretName, namespace }) => {
|
|
66
|
+
return Secret.get(`${this.name}.secret`, {
|
|
67
|
+
name: secretName,
|
|
68
|
+
namespace
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
return this._secret;
|
|
72
|
+
}
|
|
73
|
+
static create(name, args, opts) {
|
|
74
|
+
return new CreatedCertificate(name, args, opts);
|
|
75
|
+
}
|
|
76
|
+
static createOrPatch(name, args, opts) {
|
|
77
|
+
if (args.existing) {
|
|
78
|
+
return new CertificatePatch(name, {
|
|
79
|
+
...args,
|
|
80
|
+
name: output(args.existing).metadata.name,
|
|
81
|
+
namespace: Namespace.forResourceAsync(args.existing, output(args.namespace).cluster)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return new CreatedCertificate(name, args, opts);
|
|
85
|
+
}
|
|
86
|
+
static async createOrGet(name, args, opts) {
|
|
87
|
+
if (args.existing) {
|
|
88
|
+
return await Certificate.forAsync(args.existing, output(args.namespace).cluster);
|
|
89
|
+
}
|
|
90
|
+
return new CreatedCertificate(name, args, opts);
|
|
91
|
+
}
|
|
92
|
+
static patch(name, args, opts) {
|
|
93
|
+
return new CertificatePatch(name, args, opts);
|
|
94
|
+
}
|
|
95
|
+
static wrap(name, args, opts) {
|
|
96
|
+
return new WrappedCertificate(name, args, opts);
|
|
97
|
+
}
|
|
98
|
+
static get(name, args, opts) {
|
|
99
|
+
return new ExternalCertificate(name, args, opts);
|
|
100
|
+
}
|
|
101
|
+
static certificateCache = new Map;
|
|
102
|
+
static for(entity, cluster) {
|
|
103
|
+
return getOrCreate(Certificate.certificateCache, `${entity.clusterName}.${entity.metadata.namespace}.${entity.metadata.name}.${entity.clusterId}`, (name) => {
|
|
104
|
+
return Certificate.get(name, {
|
|
105
|
+
name: entity.metadata.name,
|
|
106
|
+
namespace: Namespace.forResourceAsync(entity, cluster)
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
static async forAsync(entity, cluster) {
|
|
111
|
+
const resolvedEntity = await toPromise(entity);
|
|
112
|
+
return Certificate.for(resolvedEntity, output(cluster));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
class CreatedCertificate extends Certificate {
|
|
117
|
+
constructor(name, args, opts) {
|
|
118
|
+
const certificate = output(args.namespace).cluster.apply((cluster) => {
|
|
119
|
+
return new cert_manager.v1.Certificate(name, {
|
|
120
|
+
metadata: mapCertificateMetadata(args, name),
|
|
121
|
+
spec: omit(args, commonExtraArgs)
|
|
122
|
+
}, { ...opts, parent: this, provider: getProvider(cluster) });
|
|
123
|
+
});
|
|
124
|
+
super("highstate:k8s:Certificate", name, args, opts, certificate.metadata, output(args.namespace), certificate.spec, certificate.status);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
class CertificatePatch extends Certificate {
|
|
129
|
+
constructor(name, args, opts) {
|
|
130
|
+
const certificate = output(args.namespace).cluster.apply((cluster) => {
|
|
131
|
+
return new cert_manager.v1.CertificatePatch(name, {
|
|
132
|
+
metadata: mapCertificateMetadata(args, name),
|
|
133
|
+
spec: omit(args, commonExtraArgs)
|
|
134
|
+
}, { ...opts, parent: this, provider: getProvider(cluster) });
|
|
135
|
+
});
|
|
136
|
+
super("highstate:k8s:CertificatePatch", name, args, opts, certificate.metadata, output(args.namespace), certificate.spec, certificate.status);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
class WrappedCertificate extends Certificate {
|
|
141
|
+
constructor(name, args, opts) {
|
|
142
|
+
super("highstate:k8s:WrappedCertificate", name, args, opts, output(args.certificate).metadata, output(args.namespace), output(args.certificate).spec, output(args.certificate).status);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
class ExternalCertificate extends Certificate {
|
|
147
|
+
constructor(name, args, opts) {
|
|
148
|
+
const certificate = output(args.namespace).cluster.apply((cluster) => {
|
|
149
|
+
return cert_manager.v1.Certificate.get(name, interpolate`${output(args.namespace).metadata.name}/${args.name}`, { ...opts, parent: this, provider: getProvider(cluster) });
|
|
150
|
+
});
|
|
151
|
+
super("highstate:k8s:ExternalCertificate", name, args, opts, certificate.metadata, output(args.namespace), certificate.spec, certificate.status);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export { Certificate };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
Workload,
|
|
4
|
+
filterPatchOwnedContainersInTemplate,
|
|
5
|
+
getWorkloadServiceComponents,
|
|
6
|
+
workloadServiceExtraArgs
|
|
7
|
+
} from "./chunk-h1b79v66.js";
|
|
8
|
+
import {
|
|
9
|
+
Namespace,
|
|
10
|
+
getProvider,
|
|
11
|
+
mapMetadata
|
|
12
|
+
} from "./chunk-facs31cb.js";
|
|
13
|
+
|
|
14
|
+
// src/deployment.ts
|
|
15
|
+
import { getOrCreate } from "@highstate/contract";
|
|
16
|
+
import { k8s } from "@highstate/library";
|
|
17
|
+
import {
|
|
18
|
+
interpolate,
|
|
19
|
+
makeEntityOutput,
|
|
20
|
+
output,
|
|
21
|
+
toPromise
|
|
22
|
+
} from "@highstate/pulumi";
|
|
23
|
+
import { apps } from "@pulumi/kubernetes";
|
|
24
|
+
import { deepmerge } from "deepmerge-ts";
|
|
25
|
+
import { omit } from "remeda";
|
|
26
|
+
class Deployment extends Workload {
|
|
27
|
+
spec;
|
|
28
|
+
status;
|
|
29
|
+
static apiVersion = "apps/v1";
|
|
30
|
+
static kind = "Deployment";
|
|
31
|
+
constructor(type, name, args, opts, metadata, namespace, terminalArgs, containers, networkPolicy, service, routes, spec, status) {
|
|
32
|
+
super(type, name, args, opts, metadata, namespace, terminalArgs, containers, spec.template, networkPolicy, service, routes);
|
|
33
|
+
this.spec = spec;
|
|
34
|
+
this.status = status;
|
|
35
|
+
}
|
|
36
|
+
get templateMetadata() {
|
|
37
|
+
return this.spec.template.metadata;
|
|
38
|
+
}
|
|
39
|
+
getTerminalMeta() {
|
|
40
|
+
return output({
|
|
41
|
+
title: "Deployment",
|
|
42
|
+
globalTitle: interpolate`Deployment | ${this.metadata.name}`,
|
|
43
|
+
description: "The shell inside the deployment.",
|
|
44
|
+
icon: "devicon:kubernetes"
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
get entity() {
|
|
48
|
+
const service = this._service.apply((service2) => service2?.entity);
|
|
49
|
+
return makeEntityOutput({
|
|
50
|
+
entity: k8s.deploymentEntity,
|
|
51
|
+
identity: this.metadata.uid,
|
|
52
|
+
meta: {
|
|
53
|
+
title: this.metadata.name
|
|
54
|
+
},
|
|
55
|
+
value: {
|
|
56
|
+
...this.entityBase,
|
|
57
|
+
service,
|
|
58
|
+
spec: this.spec
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
static create(name, args, opts) {
|
|
63
|
+
return new CreatedDeployment(name, args, opts);
|
|
64
|
+
}
|
|
65
|
+
static createOrPatch(name, args, opts) {
|
|
66
|
+
if (args.existing) {
|
|
67
|
+
return new DeploymentPatch(name, {
|
|
68
|
+
...args,
|
|
69
|
+
name: output(args.existing).metadata.name,
|
|
70
|
+
namespace: Namespace.forResourceAsync(args.existing, output(args.namespace).cluster)
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return new CreatedDeployment(name, args, opts);
|
|
74
|
+
}
|
|
75
|
+
static async createOrGet(name, args, opts) {
|
|
76
|
+
if (args.existing) {
|
|
77
|
+
return await Deployment.forAsync(args.existing, output(args.namespace).cluster);
|
|
78
|
+
}
|
|
79
|
+
return new CreatedDeployment(name, args, opts);
|
|
80
|
+
}
|
|
81
|
+
static patch(name, args, opts) {
|
|
82
|
+
return new DeploymentPatch(name, args, opts);
|
|
83
|
+
}
|
|
84
|
+
static wrap(name, args, opts) {
|
|
85
|
+
return new WrappedDeployment(name, args, opts);
|
|
86
|
+
}
|
|
87
|
+
static get(name, args, opts) {
|
|
88
|
+
return new ExternalDeployment(name, args, opts);
|
|
89
|
+
}
|
|
90
|
+
static deploymentCache = new Map;
|
|
91
|
+
static for(entity, cluster) {
|
|
92
|
+
return getOrCreate(Deployment.deploymentCache, `${entity.clusterName}.${entity.metadata.namespace}.${entity.metadata.name}.${entity.clusterId}`, (name) => {
|
|
93
|
+
return Deployment.get(name, {
|
|
94
|
+
name: entity.metadata.name,
|
|
95
|
+
namespace: Namespace.forResource(entity, cluster)
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
static async forAsync(entity, cluster) {
|
|
100
|
+
const resolvedEntity = await toPromise(entity);
|
|
101
|
+
return Deployment.for(resolvedEntity, cluster);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
class CreatedDeployment extends Deployment {
|
|
106
|
+
constructor(name, args, opts) {
|
|
107
|
+
const { labels, podTemplate, networkPolicy, containers, service, routes } = getWorkloadServiceComponents(name, args, () => this, opts);
|
|
108
|
+
const deployment = output(args.namespace).cluster.apply((cluster) => {
|
|
109
|
+
return new apps.v1.Deployment(name, {
|
|
110
|
+
metadata: mapMetadata(args, name),
|
|
111
|
+
spec: output({ args, podTemplate, labels }).apply(({ args: args2, podTemplate: podTemplate2, labels: labels2 }) => {
|
|
112
|
+
return deepmerge({
|
|
113
|
+
template: podTemplate2,
|
|
114
|
+
selector: { matchLabels: labels2 }
|
|
115
|
+
}, omit(args2, workloadServiceExtraArgs));
|
|
116
|
+
})
|
|
117
|
+
}, { ...opts, parent: this, provider: getProvider(cluster) });
|
|
118
|
+
});
|
|
119
|
+
super("highstate:k8s:Deployment", name, args, opts, deployment.metadata, output(args.namespace), output(args.terminal ?? {}), containers, networkPolicy, service, routes, deployment.spec, deployment.status);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
class DeploymentPatch extends Deployment {
|
|
124
|
+
constructor(name, args, opts) {
|
|
125
|
+
const { podTemplate, networkPolicy, containers, service, routes } = getWorkloadServiceComponents(name, args, () => this, opts, true);
|
|
126
|
+
const deployment = output(args.namespace).cluster.apply((cluster) => {
|
|
127
|
+
return new apps.v1.DeploymentPatch(name, {
|
|
128
|
+
metadata: mapMetadata(args, name),
|
|
129
|
+
spec: output({ args, podTemplate }).apply(({ args: args2, podTemplate: podTemplate2 }) => {
|
|
130
|
+
const spec = deepmerge({ template: podTemplate2 }, omit(args2, workloadServiceExtraArgs));
|
|
131
|
+
if (spec.template) {
|
|
132
|
+
spec.template = filterPatchOwnedContainersInTemplate(spec.template, podTemplate2);
|
|
133
|
+
}
|
|
134
|
+
return spec;
|
|
135
|
+
})
|
|
136
|
+
}, {
|
|
137
|
+
...opts,
|
|
138
|
+
parent: this,
|
|
139
|
+
provider: getProvider(cluster)
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
const filteredSpec = output({ spec: deployment.spec, podTemplate }).apply(({ spec, podTemplate: podTemplate2 }) => {
|
|
143
|
+
if (!spec.template) {
|
|
144
|
+
return spec;
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
...spec,
|
|
148
|
+
template: filterPatchOwnedContainersInTemplate(spec.template, podTemplate2)
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
super("highstate:k8s:DeploymentPatch", name, args, opts, deployment.metadata, output(args.namespace), output(args.terminal ?? {}), containers, networkPolicy, service, routes, filteredSpec, deployment.status);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
class WrappedDeployment extends Deployment {
|
|
156
|
+
constructor(name, args, opts) {
|
|
157
|
+
super("highstate:k8s:WrappedDeployment", name, args, opts, output(args.deployment).metadata, output(args.namespace), output(args.terminal ?? {}), output([]), output(undefined), output(undefined), output([]), output(args.deployment).spec, output(args.deployment).status);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
class ExternalDeployment extends Deployment {
|
|
162
|
+
constructor(name, args, opts) {
|
|
163
|
+
const deployment = output(args.namespace).cluster.apply((cluster) => {
|
|
164
|
+
return apps.v1.Deployment.get(name, interpolate`${output(args.namespace).metadata.name}/${args.name}`, { ...opts, parent: this, provider: getProvider(cluster) });
|
|
165
|
+
});
|
|
166
|
+
super("highstate:k8s:ExternalDeployment", name, args, opts, deployment.metadata, output(args.namespace), output({}), output([]), output(undefined), output(undefined), output([]), deployment.spec, deployment.status);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export { Deployment };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { CoreV1Api } from '@kubernetes/client-node';
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
images_default
|
|
4
|
+
} from "./chunk-facs31cb.js";
|
|
6
5
|
|
|
6
|
+
// src/cluster.ts
|
|
7
|
+
import { isPrivateAddress, parseAddress } from "@highstate/common";
|
|
8
|
+
import { text } from "@highstate/contract";
|
|
9
|
+
import { makeFileOutput, output } from "@highstate/pulumi";
|
|
10
|
+
import { CoreV1Api } from "@kubernetes/client-node";
|
|
7
11
|
async function detectExternalIps(kubeConfig, internalIpsPolicy) {
|
|
8
12
|
const nodeApi = kubeConfig.makeApiClient(CoreV1Api);
|
|
9
13
|
const nodes = await nodeApi.listNode();
|
|
@@ -11,8 +15,8 @@ async function detectExternalIps(kubeConfig, internalIpsPolicy) {
|
|
|
11
15
|
const addresses = node.status?.addresses ?? [];
|
|
12
16
|
const externalIp = addresses.find((address) => address.type === "ExternalIP");
|
|
13
17
|
const internalIp = addresses.find((address) => address.type === "InternalIP");
|
|
14
|
-
const externalAddress = externalIp ? parseAddress(externalIp.address) :
|
|
15
|
-
const internalAddress = internalIp ? parseAddress(internalIp.address) :
|
|
18
|
+
const externalAddress = externalIp ? parseAddress(externalIp.address) : undefined;
|
|
19
|
+
const internalAddress = internalIp ? parseAddress(internalIp.address) : undefined;
|
|
16
20
|
const result = [];
|
|
17
21
|
if (externalAddress) {
|
|
18
22
|
result.push(externalAddress);
|
|
@@ -35,7 +39,7 @@ function createK8sTerminal(kubeconfig) {
|
|
|
35
39
|
icon: "devicon:kubernetes"
|
|
36
40
|
},
|
|
37
41
|
spec: {
|
|
38
|
-
image:
|
|
42
|
+
image: images_default["terminal-kubectl"].image,
|
|
39
43
|
command: ["bash", "/welcome.sh"],
|
|
40
44
|
files: {
|
|
41
45
|
"/kubeconfig": makeFileOutput({
|
|
@@ -63,6 +67,4 @@ function createK8sTerminal(kubeconfig) {
|
|
|
63
67
|
});
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
export {
|
|
67
|
-
//# sourceMappingURL=chunk-ADHZK6V2.js.map
|
|
68
|
-
//# sourceMappingURL=chunk-ADHZK6V2.js.map
|
|
70
|
+
export { detectExternalIps, createK8sTerminal };
|