@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/shared.ts
CHANGED
@@ -1,47 +1,44 @@
|
|
1
1
|
import type { PartialKeys } from "@highstate/contract"
|
2
2
|
import type { k8s } from "@highstate/library"
|
3
|
-
import {
|
4
|
-
|
3
|
+
import {
|
4
|
+
ComponentResource,
|
5
|
+
type ComponentResourceOptions,
|
6
|
+
type Input,
|
7
|
+
type Inputs,
|
8
|
+
type Output,
|
9
|
+
output,
|
10
|
+
secret,
|
11
|
+
toPromise,
|
12
|
+
type Unwrap,
|
13
|
+
} from "@highstate/pulumi"
|
14
|
+
import { core, Provider, type types } from "@pulumi/kubernetes"
|
5
15
|
import * as images from "../assets/images.json"
|
6
16
|
import { Namespace } from "./namespace"
|
7
17
|
|
8
|
-
const providers = new Map
|
18
|
+
const providers = new Map<`${string}.${string}`, Provider>()
|
9
19
|
|
10
|
-
export function getProvider(cluster:
|
11
|
-
const
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
const provider = new Provider(`${cluster.name}-${cluster.id}`, {
|
18
|
-
kubeconfig: cluster.kubeconfig,
|
19
|
-
})
|
20
|
-
providers.set(cluster.id, provider)
|
20
|
+
export function getProvider(cluster: k8s.Cluster): Provider {
|
21
|
+
const name = `${cluster.name}.${cluster.connectionId}` as const
|
22
|
+
const existing = providers.get(name)
|
23
|
+
if (existing) {
|
24
|
+
return existing
|
25
|
+
}
|
21
26
|
|
22
|
-
|
23
|
-
|
27
|
+
const provider = new Provider(name, { kubeconfig: secret(cluster.kubeconfig) })
|
28
|
+
providers.set(name, provider)
|
24
29
|
|
25
|
-
return
|
30
|
+
return provider
|
26
31
|
}
|
27
32
|
|
28
|
-
export function
|
29
|
-
const
|
30
|
-
if (existingProvider) {
|
31
|
-
return existingProvider
|
32
|
-
}
|
33
|
-
|
34
|
-
const provider = new Provider(`${cluster.name}-${cluster.id}`, {
|
35
|
-
kubeconfig: cluster.kubeconfig,
|
36
|
-
})
|
37
|
-
providers.set(cluster.id, provider)
|
33
|
+
export async function getProviderAsync(cluster: Input<k8s.Cluster>): Promise<Provider> {
|
34
|
+
const resolvedCluster = await toPromise(cluster)
|
38
35
|
|
39
|
-
return
|
36
|
+
return getProvider(resolvedCluster)
|
40
37
|
}
|
41
38
|
|
42
39
|
export type NamespaceLike = core.v1.Namespace | Namespace | string
|
43
40
|
|
44
|
-
export type
|
41
|
+
export type ScopedResourceArgs = {
|
45
42
|
/**
|
46
43
|
* The name of the resource.
|
47
44
|
*/
|
@@ -50,12 +47,7 @@ export type CommonArgs = {
|
|
50
47
|
/**
|
51
48
|
* The namespace to create the resource in.
|
52
49
|
*/
|
53
|
-
namespace: Input<
|
54
|
-
|
55
|
-
/**
|
56
|
-
* The cluster to create the resource in.
|
57
|
-
*/
|
58
|
-
cluster: Input<k8s.Cluster>
|
50
|
+
namespace: Input<Namespace>
|
59
51
|
|
60
52
|
/**
|
61
53
|
* The metadata to apply to the resource.
|
@@ -63,17 +55,20 @@ export type CommonArgs = {
|
|
63
55
|
metadata?: Input<types.input.meta.v1.ObjectMeta>
|
64
56
|
}
|
65
57
|
|
66
|
-
export const commonExtraArgs = ["name", "namespace", "
|
58
|
+
export const commonExtraArgs = ["name", "namespace", "metadata"] as const
|
67
59
|
|
68
60
|
export function mapMetadata(
|
69
|
-
args: PartialKeys<
|
61
|
+
args: PartialKeys<ScopedResourceArgs, "namespace">,
|
70
62
|
fallbackName?: string,
|
71
|
-
): types.input.meta.v1.ObjectMeta {
|
72
|
-
return
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
63
|
+
): Output<Unwrap<types.input.meta.v1.ObjectMeta>> {
|
64
|
+
return output(args.metadata).apply(metadata =>
|
65
|
+
output({
|
66
|
+
...metadata,
|
67
|
+
name: args.name ?? metadata?.name ?? fallbackName,
|
68
|
+
namespace:
|
69
|
+
metadata?.namespace ?? (args.namespace ? output(args.namespace).metadata.name : undefined),
|
70
|
+
}),
|
71
|
+
)
|
77
72
|
}
|
78
73
|
|
79
74
|
export type SelectorLike = types.input.meta.v1.LabelSelector | Record<string, Input<string>>
|
@@ -90,7 +85,7 @@ export function mapSelectorLikeToSelector(
|
|
90
85
|
}
|
91
86
|
}
|
92
87
|
|
93
|
-
export function
|
88
|
+
export function getNamespaceName(namespace: NamespaceLike): Output<string> {
|
94
89
|
if (Namespace.isInstance(namespace)) {
|
95
90
|
return namespace.metadata.name
|
96
91
|
}
|
@@ -112,35 +107,67 @@ export function mapNamespaceNameToSelector(
|
|
112
107
|
}
|
113
108
|
}
|
114
109
|
|
115
|
-
export
|
116
|
-
|
117
|
-
namespace?: Input<NamespaceLike | undefined>
|
118
|
-
}
|
119
|
-
|
120
|
-
export function resourceIdToString(id: Input<ResourceId>): Output<string> {
|
121
|
-
return output(id).apply(metadata => {
|
122
|
-
const namespaceName = metadata.namespace
|
123
|
-
? mapNamespaceLikeToNamespaceName(metadata.namespace)
|
124
|
-
: undefined
|
125
|
-
|
126
|
-
return output(namespaceName ? interpolate`${namespaceName}/${metadata.name}` : metadata.name)
|
127
|
-
})
|
128
|
-
}
|
129
|
-
|
130
|
-
export function withPatchName(
|
131
|
-
resourceType: string,
|
132
|
-
resource: Input<k8s.Resource>,
|
110
|
+
export function validateCluster(
|
111
|
+
entity: Input<k8s.Resource>,
|
133
112
|
cluster: Input<k8s.Cluster>,
|
134
|
-
):
|
135
|
-
return output({
|
136
|
-
if (
|
113
|
+
): Input<k8s.Cluster> {
|
114
|
+
return output({ entity, cluster }).apply(({ entity, cluster }) => {
|
115
|
+
if (entity.clusterId !== cluster.id) {
|
137
116
|
throw new Error(
|
138
|
-
`Cluster mismatch
|
117
|
+
`Cluster mismatch for ${entity.type} "${entity.metadata.name}": "${entity.clusterId}" != "${cluster.id}"`,
|
139
118
|
)
|
140
119
|
}
|
141
120
|
|
142
|
-
return
|
121
|
+
return cluster
|
143
122
|
})
|
144
123
|
}
|
145
124
|
|
146
125
|
export { images }
|
126
|
+
|
127
|
+
/**
|
128
|
+
* Base class for all Kubernetes scoped resources.
|
129
|
+
*
|
130
|
+
* Provides common functionality for resources that have a cluster, namespace, metadata, and entity.
|
131
|
+
*/
|
132
|
+
export abstract class ScopedResource extends ComponentResource {
|
133
|
+
protected constructor(
|
134
|
+
type: string,
|
135
|
+
name: string,
|
136
|
+
args: Inputs,
|
137
|
+
opts: ComponentResourceOptions | undefined,
|
138
|
+
|
139
|
+
/**
|
140
|
+
* The Kubernetes API version (e.g., "v1", "apps/v1", "batch/v1").
|
141
|
+
*/
|
142
|
+
readonly apiVersion: Output<string>,
|
143
|
+
|
144
|
+
/**
|
145
|
+
* The Kubernetes kind (e.g., "ConfigMap", "Deployment", "CronJob").
|
146
|
+
*/
|
147
|
+
readonly kind: Output<string>,
|
148
|
+
|
149
|
+
/**
|
150
|
+
* The namespace where the resource is located.
|
151
|
+
*/
|
152
|
+
readonly namespace: Output<Namespace>,
|
153
|
+
|
154
|
+
/**
|
155
|
+
* The metadata of the underlying Kubernetes resource.
|
156
|
+
*/
|
157
|
+
readonly metadata: Output<types.output.meta.v1.ObjectMeta>,
|
158
|
+
) {
|
159
|
+
super(type, name, args, opts)
|
160
|
+
}
|
161
|
+
|
162
|
+
/**
|
163
|
+
* The cluster where the resource is located.
|
164
|
+
*/
|
165
|
+
get cluster(): Output<k8s.Cluster> {
|
166
|
+
return this.namespace.cluster
|
167
|
+
}
|
168
|
+
|
169
|
+
/**
|
170
|
+
* The Highstate resource entity.
|
171
|
+
*/
|
172
|
+
abstract get entity(): Output<k8s.ScopedResource>
|
173
|
+
}
|