@highstate/k8s 0.9.16 → 0.9.19
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-2EEHJZPD.js +13 -0
- package/dist/chunk-2EEHJZPD.js.map +1 -0
- package/dist/{chunk-OFFSHGC6.js → chunk-4JGXGN2L.js} +66 -48
- package/dist/chunk-4JGXGN2L.js.map +1 -0
- package/dist/chunk-A3XGSDIW.js +306 -0
- package/dist/chunk-A3XGSDIW.js.map +1 -0
- package/dist/chunk-IMTXUK2U.js +244 -0
- package/dist/chunk-IMTXUK2U.js.map +1 -0
- package/dist/chunk-JYNXQ3I3.js +287 -0
- package/dist/chunk-JYNXQ3I3.js.map +1 -0
- package/dist/{chunk-5C2BJGES.js → chunk-KDD6XUWM.js} +30 -23
- package/dist/chunk-KDD6XUWM.js.map +1 -0
- package/dist/chunk-NOFJC3EM.js +236 -0
- package/dist/chunk-NOFJC3EM.js.map +1 -0
- package/dist/chunk-NXSYCA3V.js +337 -0
- package/dist/chunk-NXSYCA3V.js.map +1 -0
- package/dist/chunk-SBC3TUIN.js +1513 -0
- package/dist/chunk-SBC3TUIN.js.map +1 -0
- package/dist/chunk-SI7X6N46.js +338 -0
- package/dist/chunk-SI7X6N46.js.map +1 -0
- package/dist/chunk-WGMJCZSK.js +360 -0
- package/dist/chunk-WGMJCZSK.js.map +1 -0
- package/dist/deployment-752P6JIT.js +8 -0
- package/dist/{deployment-XK3CDJOE.js.map → deployment-752P6JIT.js.map} +1 -1
- package/dist/highstate.manifest.json +8 -7
- package/dist/impl/gateway-route.js +123 -0
- package/dist/impl/gateway-route.js.map +1 -0
- package/dist/impl/tls-certificate.js +32 -0
- package/dist/impl/tls-certificate.js.map +1 -0
- package/dist/index.js +736 -208
- package/dist/index.js.map +1 -1
- package/dist/stateful-set-N64YVKR7.js +8 -0
- package/dist/{stateful-set-7CAQWTV2.js.map → stateful-set-N64YVKR7.js.map} +1 -1
- package/dist/units/cert-manager/index.js +11 -10
- package/dist/units/cert-manager/index.js.map +1 -1
- package/dist/units/cluster-dns/index.js.map +1 -1
- package/dist/units/cluster-patch/index.js.map +1 -1
- package/dist/units/dns01-issuer/index.js +27 -23
- package/dist/units/dns01-issuer/index.js.map +1 -1
- package/dist/units/existing-cluster/index.js +11 -8
- 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/package.json +40 -14
- package/src/cluster.ts +30 -22
- package/src/config-map.ts +195 -57
- package/src/container.ts +5 -5
- package/src/cron-job.ts +403 -31
- package/src/deployment.ts +260 -120
- package/src/dns01-solver.ts +10 -0
- package/src/gateway/backend.ts +2 -2
- package/src/gateway/gateway.ts +383 -0
- package/src/gateway/http-route.ts +17 -24
- package/src/gateway/index.ts +1 -0
- package/src/helm.ts +83 -53
- package/src/impl/gateway-route.ts +155 -0
- package/src/impl/tls-certificate.ts +33 -0
- package/src/index.ts +22 -67
- package/src/job.ts +393 -28
- package/src/namespace.ts +236 -99
- package/src/network-policy.ts +216 -165
- package/src/network.ts +2 -2
- package/src/pvc.ts +266 -65
- package/src/rbac.ts +218 -0
- package/src/scripting/bundle.ts +9 -20
- package/src/scripting/container.ts +1 -1
- package/src/scripting/environment.ts +5 -5
- package/src/secret.ts +200 -62
- package/src/service.ts +288 -158
- package/src/shared.ts +94 -67
- package/src/stateful-set.ts +270 -117
- package/src/tls.ts +344 -0
- package/src/units/cert-manager/index.ts +2 -3
- package/src/units/dns01-issuer/index.ts +30 -14
- package/src/units/existing-cluster/index.ts +10 -7
- package/src/units/gateway-api/index.ts +2 -2
- package/src/worker.ts +26 -0
- package/src/workload.ts +275 -171
- package/dist/chunk-5C2BJGES.js.map +0 -1
- package/dist/chunk-5TLC5BXR.js +0 -256
- package/dist/chunk-5TLC5BXR.js.map +0 -1
- package/dist/chunk-BBIY3KUN.js +0 -1557
- package/dist/chunk-BBIY3KUN.js.map +0 -1
- package/dist/chunk-OFFSHGC6.js.map +0 -1
- package/dist/chunk-TZHOUJRC.js +0 -202
- package/dist/chunk-TZHOUJRC.js.map +0 -1
- package/dist/chunk-YWRJ4EZM.js +0 -192
- package/dist/chunk-YWRJ4EZM.js.map +0 -1
- package/dist/deployment-XK3CDJOE.js +0 -6
- package/dist/stateful-set-7CAQWTV2.js +0 -6
- package/dist/units/access-point/index.js +0 -21
- package/dist/units/access-point/index.js.map +0 -1
- package/src/access-point.ts +0 -191
- package/src/units/access-point/index.ts +0 -19
- package/src/units/dns01-issuer/solver.ts +0 -23
package/src/helm.ts
CHANGED
@@ -1,26 +1,33 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
3
|
-
import {
|
1
|
+
import type { UnitTerminal } from "@highstate/contract"
|
2
|
+
import type { Namespace } from "./namespace"
|
3
|
+
import type { Workload, WorkloadTerminalArgs } from "./workload"
|
4
4
|
import { mkdir, readFile, unlink } from "node:fs/promises"
|
5
|
-
import {
|
6
|
-
import {
|
5
|
+
import { resolve } from "node:path"
|
6
|
+
import { AccessPointRoute, type AccessPointRouteArgs } from "@highstate/common"
|
7
|
+
import {
|
8
|
+
type InputArray,
|
9
|
+
type InputRecord,
|
10
|
+
normalize,
|
11
|
+
normalizeInputs,
|
12
|
+
toPromise,
|
13
|
+
} from "@highstate/pulumi"
|
14
|
+
import { local } from "@pulumi/command"
|
15
|
+
import { apps, core, helm, type types } from "@pulumi/kubernetes"
|
7
16
|
import {
|
8
17
|
ComponentResource,
|
9
|
-
output,
|
10
18
|
type ComponentResourceOptions,
|
11
19
|
type Input,
|
12
20
|
type Output,
|
21
|
+
output,
|
13
22
|
} from "@pulumi/pulumi"
|
14
|
-
import spawn from "nano-spawn"
|
15
23
|
import { sha256 } from "crypto-hash"
|
16
|
-
import { omit } from "remeda"
|
17
|
-
import { local } from "@pulumi/command"
|
18
24
|
import { glob } from "glob"
|
25
|
+
import spawn from "nano-spawn"
|
26
|
+
import { isNonNullish, omit } from "remeda"
|
27
|
+
import { Deployment } from "./deployment"
|
19
28
|
import { NetworkPolicy, type NetworkPolicyArgs } from "./network-policy"
|
20
|
-
import { HttpRoute, type HttpRouteArgs } from "./gateway"
|
21
|
-
import { getProvider, mapNamespaceLikeToNamespaceName, type NamespaceLike } from "./shared"
|
22
29
|
import { getServiceType, Service, type ServiceArgs } from "./service"
|
23
|
-
import {
|
30
|
+
import { getNamespaceName, getProvider, type NamespaceLike } from "./shared"
|
24
31
|
import { StatefulSet } from "./stateful-set"
|
25
32
|
|
26
33
|
export type ChartArgs = Omit<
|
@@ -30,7 +37,7 @@ export type ChartArgs = Omit<
|
|
30
37
|
/**
|
31
38
|
* The namespace to deploy the chart into.
|
32
39
|
*/
|
33
|
-
namespace
|
40
|
+
namespace: Input<Namespace>
|
34
41
|
|
35
42
|
/**
|
36
43
|
* The custom name of the primary service exposed by the chart.
|
@@ -52,14 +59,21 @@ export type ChartArgs = Omit<
|
|
52
59
|
chart: ChartManifest
|
53
60
|
|
54
61
|
/**
|
55
|
-
* The
|
62
|
+
* The args for the terminal to use.
|
63
|
+
*
|
64
|
+
* Will be applied to all workloads created by the chart.
|
65
|
+
*/
|
66
|
+
terminal?: Input<WorkloadTerminalArgs>
|
67
|
+
|
68
|
+
/**
|
69
|
+
* The configuration for the access point route to create.
|
56
70
|
*/
|
57
|
-
|
71
|
+
route?: Input<Omit<AccessPointRouteArgs, "endpoints" | "customData">>
|
58
72
|
|
59
73
|
/**
|
60
|
-
* The
|
74
|
+
* The configuration for the access point routes to create.
|
61
75
|
*/
|
62
|
-
|
76
|
+
routes?: InputArray<Omit<AccessPointRouteArgs, "endpoints" | "customData">>
|
63
77
|
|
64
78
|
/**
|
65
79
|
* The network policy to apply to the chart.
|
@@ -79,9 +93,9 @@ export class Chart extends ComponentResource {
|
|
79
93
|
public readonly chart: Output<helm.v4.Chart>
|
80
94
|
|
81
95
|
/**
|
82
|
-
* The
|
96
|
+
* The access point routes created for the chart.
|
83
97
|
*/
|
84
|
-
public readonly
|
98
|
+
public readonly routes: Output<AccessPointRoute[]>
|
85
99
|
|
86
100
|
/**
|
87
101
|
* The network policies applied to the chart.
|
@@ -101,10 +115,10 @@ export class Chart extends ComponentResource {
|
|
101
115
|
super("highstate:k8s:Chart", name, args, opts)
|
102
116
|
|
103
117
|
const namespace = output(args.namespace).apply(namespace =>
|
104
|
-
output(namespace ?
|
118
|
+
output(namespace ? getNamespaceName(namespace) : "default"),
|
105
119
|
)
|
106
120
|
|
107
|
-
this.chart = output(
|
121
|
+
this.chart = output(args.namespace).cluster.apply(cluster => {
|
108
122
|
return new helm.v4.Chart(
|
109
123
|
name,
|
110
124
|
omit(
|
@@ -113,17 +127,19 @@ export class Chart extends ComponentResource {
|
|
113
127
|
chart: resolveHelmChart(args.chart),
|
114
128
|
namespace,
|
115
129
|
},
|
116
|
-
["
|
130
|
+
["route", "routes"],
|
117
131
|
),
|
118
132
|
{
|
119
133
|
...opts,
|
120
134
|
parent: this,
|
121
|
-
provider:
|
135
|
+
provider: getProvider(cluster),
|
122
136
|
|
123
137
|
transforms: [
|
124
138
|
...(opts?.transforms ?? []),
|
125
139
|
|
126
|
-
resourceArgs => {
|
140
|
+
async resourceArgs => {
|
141
|
+
const namespace = await toPromise(output(args.namespace).metadata.name)
|
142
|
+
|
127
143
|
const serviceName = args.serviceName ?? name
|
128
144
|
const expectedName = `${name}:${namespace}/${serviceName}`
|
129
145
|
|
@@ -140,10 +156,10 @@ export class Chart extends ComponentResource {
|
|
140
156
|
...spec,
|
141
157
|
...(args.service ?? {}),
|
142
158
|
|
143
|
-
type: getServiceType(args.service,
|
159
|
+
type: getServiceType(args.service, cluster),
|
144
160
|
|
145
161
|
externalIPs:
|
146
|
-
args.service?.externalIPs ??
|
162
|
+
args.service?.externalIPs ?? cluster.externalIps ?? spec.externalIPs,
|
147
163
|
},
|
148
164
|
},
|
149
165
|
opts: resourceArgs.opts,
|
@@ -157,21 +173,27 @@ export class Chart extends ComponentResource {
|
|
157
173
|
)
|
158
174
|
})
|
159
175
|
|
160
|
-
this.
|
161
|
-
if (
|
162
|
-
return
|
176
|
+
this.routes = output(normalizeInputs(args.route, args.routes)).apply(async routes => {
|
177
|
+
if (routes.length === 0) {
|
178
|
+
return []
|
163
179
|
}
|
164
180
|
|
165
|
-
return
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
181
|
+
return await Promise.all(
|
182
|
+
routes.map(async route => {
|
183
|
+
return new AccessPointRoute(
|
184
|
+
name,
|
185
|
+
{
|
186
|
+
...route,
|
187
|
+
|
188
|
+
endpoints: this.service.endpoints,
|
189
|
+
|
190
|
+
// pass the native data to the route to allow implementation to use it
|
191
|
+
gatewayNativeData: await toPromise(this.service),
|
192
|
+
tlsCertificateNativeData: await toPromise(args.namespace),
|
193
|
+
},
|
194
|
+
{ ...opts, parent: this },
|
195
|
+
)
|
196
|
+
}),
|
175
197
|
)
|
176
198
|
})
|
177
199
|
|
@@ -180,13 +202,12 @@ export class Chart extends ComponentResource {
|
|
180
202
|
|
181
203
|
return output(
|
182
204
|
policies.map(policy => {
|
183
|
-
return NetworkPolicy
|
205
|
+
return new NetworkPolicy(
|
184
206
|
name,
|
185
207
|
{
|
186
208
|
...policy,
|
187
|
-
|
188
|
-
cluster: args.cluster,
|
189
209
|
namespace: args.namespace,
|
210
|
+
description: `Network policy for Helm chart "${name}"`,
|
190
211
|
},
|
191
212
|
{ ...opts, parent: this },
|
192
213
|
)
|
@@ -201,19 +222,32 @@ export class Chart extends ComponentResource {
|
|
201
222
|
.map(resource => {
|
202
223
|
if (apps.v1.Deployment.isInstance(resource)) {
|
203
224
|
return resource.metadata.name.apply(name => {
|
204
|
-
return Deployment.wrap(
|
225
|
+
return Deployment.wrap(
|
226
|
+
name,
|
227
|
+
{ namespace: args.namespace, deployment: resource, terminal: args.terminal },
|
228
|
+
this.opts,
|
229
|
+
)
|
205
230
|
})
|
206
231
|
}
|
207
232
|
|
208
233
|
if (apps.v1.StatefulSet.isInstance(resource)) {
|
209
234
|
return resource.metadata.name.apply(name => {
|
210
|
-
return StatefulSet.wrap(
|
235
|
+
return StatefulSet.wrap(
|
236
|
+
name,
|
237
|
+
{
|
238
|
+
namespace: args.namespace,
|
239
|
+
statefulSet: resource,
|
240
|
+
service: this.getServiceOutput(name),
|
241
|
+
terminal: args.terminal,
|
242
|
+
},
|
243
|
+
this.opts,
|
244
|
+
)
|
211
245
|
})
|
212
246
|
}
|
213
247
|
|
214
248
|
return undefined
|
215
249
|
})
|
216
|
-
.filter(
|
250
|
+
.filter(isNonNullish)
|
217
251
|
}),
|
218
252
|
)
|
219
253
|
})
|
@@ -223,7 +257,7 @@ export class Chart extends ComponentResource {
|
|
223
257
|
return this.getServiceOutput(undefined)
|
224
258
|
}
|
225
259
|
|
226
|
-
get terminals(): Output<
|
260
|
+
get terminals(): Output<UnitTerminal[]> {
|
227
261
|
return this.workloads.apply(workloads => output(workloads.map(workload => workload.terminal)))
|
228
262
|
}
|
229
263
|
|
@@ -241,10 +275,8 @@ export class Chart extends ComponentResource {
|
|
241
275
|
const service = getChartServiceOutput(chart, resolvedName)
|
242
276
|
|
243
277
|
const wrappedService = Service.wrap(
|
244
|
-
//
|
245
278
|
resolvedName,
|
246
|
-
service,
|
247
|
-
args.cluster,
|
279
|
+
{ namespace: args.namespace, service },
|
248
280
|
{ ...this.opts, parent: this },
|
249
281
|
)
|
250
282
|
|
@@ -272,7 +304,7 @@ export type RenderedChartArgs = {
|
|
272
304
|
/**
|
273
305
|
* The values to pass to the chart.
|
274
306
|
*/
|
275
|
-
values?:
|
307
|
+
values?: InputRecord<string>
|
276
308
|
}
|
277
309
|
|
278
310
|
export class RenderedChart extends ComponentResource {
|
@@ -302,9 +334,7 @@ export class RenderedChart extends ComponentResource {
|
|
302
334
|
"template",
|
303
335
|
resolveHelmChart(args.chart),
|
304
336
|
|
305
|
-
...(args.namespace
|
306
|
-
? ["--namespace", mapNamespaceLikeToNamespaceName(args.namespace)]
|
307
|
-
: []),
|
337
|
+
...(args.namespace ? ["--namespace", getNamespaceName(args.namespace)] : []),
|
308
338
|
|
309
339
|
...values,
|
310
340
|
]).apply(command => command.join(" ")),
|
@@ -0,0 +1,155 @@
|
|
1
|
+
import type { Secret } from "../secret"
|
2
|
+
import { filterEndpoints, gatewayRouteMediator, type TlsCertificate } from "@highstate/common"
|
3
|
+
import { k8s } from "@highstate/library"
|
4
|
+
import { type Input, toPromise } from "@highstate/pulumi"
|
5
|
+
import { core } from "@pulumi/kubernetes"
|
6
|
+
import { Gateway, HttpRoute } from "../gateway"
|
7
|
+
import { Namespace } from "../namespace"
|
8
|
+
import { l4EndpointToServicePort, Service } from "../service"
|
9
|
+
import { getProvider, mapMetadata } from "../shared"
|
10
|
+
import { Certificate } from "../tls"
|
11
|
+
|
12
|
+
export const createGatewayRoute = gatewayRouteMediator.implement(
|
13
|
+
k8s.gatewayDataSchema,
|
14
|
+
async ({ name, spec, opts }, data) => {
|
15
|
+
const namespace =
|
16
|
+
spec.nativeData instanceof Service
|
17
|
+
? await toPromise(spec.nativeData.namespace)
|
18
|
+
: Namespace.for(data.namespace, data.cluster)
|
19
|
+
|
20
|
+
const certSecret = await getCertificateSecret(name, namespace, spec.tlsCertificate)
|
21
|
+
|
22
|
+
const certificateRef = certSecret
|
23
|
+
? {
|
24
|
+
kind: "Secret",
|
25
|
+
group: "",
|
26
|
+
name: certSecret.metadata.name,
|
27
|
+
}
|
28
|
+
: undefined
|
29
|
+
|
30
|
+
const gateway = await Gateway.createOnce(
|
31
|
+
{
|
32
|
+
name,
|
33
|
+
namespace,
|
34
|
+
gatewayClassName: data.className,
|
35
|
+
listeners: [
|
36
|
+
{
|
37
|
+
name: "https",
|
38
|
+
port: data.httpsPort,
|
39
|
+
protocol: "HTTPS",
|
40
|
+
tls: {
|
41
|
+
mode: "Terminate",
|
42
|
+
certificateRefs: certificateRef ? [certificateRef] : undefined,
|
43
|
+
},
|
44
|
+
},
|
45
|
+
],
|
46
|
+
},
|
47
|
+
opts,
|
48
|
+
)
|
49
|
+
|
50
|
+
// 1. short path - just create an HTTP route backed by a service
|
51
|
+
if (spec.nativeData instanceof Service) {
|
52
|
+
const httpRoute = new HttpRoute(
|
53
|
+
name,
|
54
|
+
{
|
55
|
+
gateway,
|
56
|
+
rule: { backend: spec.nativeData },
|
57
|
+
},
|
58
|
+
opts,
|
59
|
+
)
|
60
|
+
|
61
|
+
return {
|
62
|
+
resource: httpRoute,
|
63
|
+
endpoints: await toPromise(gateway.endpoints),
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
// 2. long path - create a virtual service with provided endpoints
|
68
|
+
const endpoints = await toPromise(spec.endpoints)
|
69
|
+
const hostnameEndpoints = filterEndpoints(endpoints, undefined, ["hostname"])
|
70
|
+
const ipEndpoints = filterEndpoints(endpoints, undefined, ["ipv4", "ipv6"])
|
71
|
+
|
72
|
+
let service: Service
|
73
|
+
|
74
|
+
if (
|
75
|
+
hostnameEndpoints.length > 0 &&
|
76
|
+
hostnameEndpoints[0].visibility > ipEndpoints[0]?.visibility
|
77
|
+
) {
|
78
|
+
// if the hostname endpoints are more visible, create a service for the first hostname with ExternalName
|
79
|
+
service = Service.create(`hs-backend-${name}`, {
|
80
|
+
namespace,
|
81
|
+
type: "ExternalName",
|
82
|
+
externalName: hostnameEndpoints[0].hostname,
|
83
|
+
ports: hostnameEndpoints.map(l4EndpointToServicePort),
|
84
|
+
})
|
85
|
+
} else {
|
86
|
+
// otherwise, create a headless service and populate it with IPs
|
87
|
+
service = Service.create(`hs-backend-${name}`, {
|
88
|
+
namespace,
|
89
|
+
type: "ClusterIP",
|
90
|
+
ports: ipEndpoints.map(l4EndpointToServicePort),
|
91
|
+
})
|
92
|
+
|
93
|
+
const endpointsName = `hs-backend-${name}`
|
94
|
+
|
95
|
+
new core.v1.Endpoints(
|
96
|
+
endpointsName,
|
97
|
+
{
|
98
|
+
metadata: mapMetadata({ namespace }, endpointsName),
|
99
|
+
subsets: ipEndpoints.map(endpoint => ({
|
100
|
+
addresses: [{ ip: endpoint.address }],
|
101
|
+
ports: [l4EndpointToServicePort(endpoint)],
|
102
|
+
})),
|
103
|
+
},
|
104
|
+
{ ...opts, provider: getProvider(data.cluster), parent: service },
|
105
|
+
)
|
106
|
+
}
|
107
|
+
|
108
|
+
const httpRoute = new HttpRoute(
|
109
|
+
name,
|
110
|
+
{
|
111
|
+
gateway,
|
112
|
+
rule: {
|
113
|
+
backend: service,
|
114
|
+
},
|
115
|
+
},
|
116
|
+
opts,
|
117
|
+
)
|
118
|
+
|
119
|
+
return {
|
120
|
+
resource: httpRoute,
|
121
|
+
endpoints: await toPromise(gateway.endpoints),
|
122
|
+
}
|
123
|
+
},
|
124
|
+
)
|
125
|
+
|
126
|
+
async function getCertificateSecret(
|
127
|
+
_name: string,
|
128
|
+
namespace: Namespace,
|
129
|
+
tlsCertificate: Input<TlsCertificate | undefined> | undefined,
|
130
|
+
): Promise<Secret | undefined> {
|
131
|
+
const resolvedCertificate = await toPromise(tlsCertificate)
|
132
|
+
if (!resolvedCertificate) {
|
133
|
+
return undefined
|
134
|
+
}
|
135
|
+
|
136
|
+
const resource = await toPromise(resolvedCertificate.resource)
|
137
|
+
|
138
|
+
if (resource instanceof Certificate) {
|
139
|
+
const certNamespace = await toPromise(resource.namespace.metadata.name)
|
140
|
+
const certClusterId = await toPromise(resource.namespace.cluster.id)
|
141
|
+
|
142
|
+
const targetNamespace = await toPromise(namespace.metadata.name)
|
143
|
+
const targetClusterId = await toPromise(namespace.cluster.id)
|
144
|
+
|
145
|
+
if (certNamespace === targetNamespace && certClusterId === targetClusterId) {
|
146
|
+
// 1. short path - same namespace and cluster, just return the secret
|
147
|
+
return await toPromise(resource.secret)
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
// 2. long path - create a new secret in the target namespace with the certificate data
|
152
|
+
throw new Error(
|
153
|
+
"Not implemented: copying certificate secret across namespaces/clusters/different systems",
|
154
|
+
)
|
155
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { tlsCertificateMediator } from "@highstate/common"
|
2
|
+
import { k8s } from "@highstate/library"
|
3
|
+
import { getProvider } from "../shared"
|
4
|
+
import { Namespace } from "../namespace"
|
5
|
+
import { Certificate } from "../tls"
|
6
|
+
|
7
|
+
export const createCertificate = tlsCertificateMediator.implement(
|
8
|
+
k8s.tlsIssuerDataSchema,
|
9
|
+
({ name, spec, opts }, data) => {
|
10
|
+
const provider = getProvider(data.cluster)
|
11
|
+
|
12
|
+
const namespace =
|
13
|
+
spec.nativeData instanceof Namespace
|
14
|
+
? spec.nativeData
|
15
|
+
: Namespace.get("cert-manager", { name: "cert-manager", cluster: data.cluster })
|
16
|
+
|
17
|
+
return Certificate.create(
|
18
|
+
name,
|
19
|
+
{
|
20
|
+
namespace,
|
21
|
+
|
22
|
+
commonName: spec.commonName,
|
23
|
+
dnsNames: spec.dnsNames,
|
24
|
+
issuerRef: {
|
25
|
+
name: data.clusterIssuerName,
|
26
|
+
kind: "ClusterIssuer",
|
27
|
+
},
|
28
|
+
secretName: `hs.certificate.${name}`,
|
29
|
+
},
|
30
|
+
{ ...opts, provider },
|
31
|
+
)
|
32
|
+
},
|
33
|
+
)
|
package/src/index.ts
CHANGED
@@ -1,67 +1,22 @@
|
|
1
|
-
export
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
export
|
12
|
-
export
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
export { type SecretArgs, type CreateOrPatchSecretArgs, Secret } from "./secret"
|
24
|
-
export { type ConfigMapArgs, type CreateOrPatchConfigMapArgs, ConfigMap } from "./config-map"
|
25
|
-
export { type StatefulSetArgs, StatefulSet } from "./stateful-set"
|
26
|
-
export {
|
27
|
-
type NetworkPolicyArgs,
|
28
|
-
type NormalizedNetworkPolicyArgs,
|
29
|
-
type NormalizedRuleArgs,
|
30
|
-
type NetworkPolicyPort,
|
31
|
-
NetworkPolicy,
|
32
|
-
} from "./network-policy"
|
33
|
-
export { useAccessPoint, useStandardAcessPoint } from "./access-point"
|
34
|
-
export {
|
35
|
-
type ScriptBundleArgs,
|
36
|
-
type ScriptContainer,
|
37
|
-
type ScriptEnvironment,
|
38
|
-
type ScriptDistribution,
|
39
|
-
ScriptBundle,
|
40
|
-
createScriptContainer,
|
41
|
-
} from "./scripting"
|
42
|
-
export { type JobArgs, Job } from "./job"
|
43
|
-
export { type CronJobArgs, CronJob } from "./cron-job"
|
44
|
-
export {
|
45
|
-
type Container,
|
46
|
-
type ContainerEnvironment,
|
47
|
-
type ContainerEnvironmentSource,
|
48
|
-
type ContainerEnvironmentVariable,
|
49
|
-
type ContainerVolumeMount,
|
50
|
-
type WorkloadVolume,
|
51
|
-
} from "./container"
|
52
|
-
export {
|
53
|
-
type ChartArgs,
|
54
|
-
type ChartManifest,
|
55
|
-
type RenderedChartArgs,
|
56
|
-
Chart,
|
57
|
-
RenderedChart,
|
58
|
-
getChartServiceOutput,
|
59
|
-
getChartService,
|
60
|
-
resolveHelmChart,
|
61
|
-
} from "./helm"
|
62
|
-
export { type HttpRouteArgs, HttpRoute } from "./gateway"
|
63
|
-
export { type PersistentVolumeClaimArgs, PersistentVolumeClaim } from "./pvc"
|
64
|
-
export { detectExternalIps, createK8sTerminal } from "./cluster"
|
65
|
-
export { getBestEndpoint, requireBestEndpoint } from "./network"
|
66
|
-
export { Workload, ExposableWorkload } from "./workload"
|
67
|
-
export { type NamespaceArgs, type CreateOrPatchNamespaceArgs, Namespace } from "./namespace"
|
1
|
+
export * from "./cluster"
|
2
|
+
export * from "./config-map"
|
3
|
+
export * from "./container"
|
4
|
+
export * from "./cron-job"
|
5
|
+
export * from "./deployment"
|
6
|
+
export * from "./dns01-solver"
|
7
|
+
export * from "./gateway"
|
8
|
+
export * from "./helm"
|
9
|
+
export * from "./job"
|
10
|
+
export * from "./namespace"
|
11
|
+
export * from "./network"
|
12
|
+
export * from "./network-policy"
|
13
|
+
export * from "./pod"
|
14
|
+
export * from "./pvc"
|
15
|
+
export * from "./rbac"
|
16
|
+
export * from "./scripting"
|
17
|
+
export * from "./secret"
|
18
|
+
export * from "./service"
|
19
|
+
export * from "./shared"
|
20
|
+
export * from "./stateful-set"
|
21
|
+
export * from "./worker"
|
22
|
+
export * from "./workload"
|