@highstate/k8s 0.9.4 → 0.9.5
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-DQSCJM5S.js +183 -0
- package/dist/chunk-DQSCJM5S.js.map +1 -0
- package/dist/chunk-FKNHHKOL.js +260 -0
- package/dist/chunk-FKNHHKOL.js.map +1 -0
- package/dist/chunk-HW3NS3MC.js +347 -0
- package/dist/chunk-HW3NS3MC.js.map +1 -0
- package/dist/chunk-OQ7UXASD.js +193 -0
- package/dist/chunk-OQ7UXASD.js.map +1 -0
- package/dist/chunk-QGHMLKTW.js +1123 -0
- package/dist/chunk-QGHMLKTW.js.map +1 -0
- package/dist/chunk-UNVSWG6D.js +214 -0
- package/dist/chunk-UNVSWG6D.js.map +1 -0
- package/dist/deployment-ZP3ASKPT.js +10 -0
- package/dist/deployment-ZP3ASKPT.js.map +1 -0
- package/dist/highstate.manifest.json +8 -6
- package/dist/index.js +291 -954
- package/dist/index.js.map +1 -1
- package/dist/stateful-set-2AH7RAF7.js +10 -0
- package/dist/stateful-set-2AH7RAF7.js.map +1 -0
- package/dist/units/access-point/index.js +6 -1
- package/dist/units/access-point/index.js.map +1 -1
- package/dist/units/cert-manager/index.js +19 -24
- package/dist/units/cert-manager/index.js.map +1 -1
- package/dist/units/cluster-dns/index.js +36 -0
- package/dist/units/cluster-dns/index.js.map +1 -0
- package/dist/units/cluster-patch/index.js +34 -0
- package/dist/units/cluster-patch/index.js.map +1 -0
- package/dist/units/dns01-issuer/index.js +2 -2
- package/dist/units/dns01-issuer/index.js.map +1 -1
- package/dist/units/existing-cluster/index.js +22 -14
- package/dist/units/existing-cluster/index.js.map +1 -1
- package/dist/units/gateway-api/index.js +1 -1
- package/package.json +12 -10
- package/src/access-point.ts +44 -39
- package/src/container.ts +54 -5
- package/src/cron-job.ts +14 -30
- package/src/deployment.ts +170 -127
- package/src/gateway/http-route.ts +7 -5
- package/src/helm.ts +57 -8
- package/src/index.ts +11 -4
- package/src/job.ts +14 -32
- package/src/namespace.ts +241 -0
- package/src/network-policy.ts +371 -87
- package/src/network.ts +41 -0
- package/src/pvc.ts +43 -25
- package/src/scripting/bundle.ts +125 -22
- package/src/scripting/container.ts +16 -11
- package/src/scripting/environment.ts +56 -6
- package/src/secret.ts +195 -0
- package/src/service.ts +209 -89
- package/src/shared.ts +42 -51
- package/src/stateful-set.ts +193 -88
- package/src/units/access-point/index.ts +8 -1
- package/src/units/cert-manager/index.ts +15 -20
- package/src/units/cluster-dns/index.ts +37 -0
- package/src/units/cluster-patch/index.ts +35 -0
- package/src/units/dns01-issuer/index.ts +1 -1
- package/src/units/existing-cluster/index.ts +24 -14
- package/src/workload.ts +342 -44
- package/dist/chunk-K4WKJ4L5.js +0 -455
- package/dist/chunk-K4WKJ4L5.js.map +0 -1
- package/dist/chunk-T5Z2M4JE.js +0 -103
- package/dist/chunk-T5Z2M4JE.js.map +0 -1
package/src/namespace.ts
ADDED
@@ -0,0 +1,241 @@
|
|
1
|
+
import type { k8s } from "@highstate/library"
|
2
|
+
import { core, type types } from "@pulumi/kubernetes"
|
3
|
+
import {
|
4
|
+
ComponentResource,
|
5
|
+
output,
|
6
|
+
Output,
|
7
|
+
type ComponentResourceOptions,
|
8
|
+
type Input,
|
9
|
+
type Inputs,
|
10
|
+
} from "@pulumi/pulumi"
|
11
|
+
import { getProvider, mapMetadata, type CommonArgs } from "./shared"
|
12
|
+
|
13
|
+
export type NamespaceArgs = Omit<CommonArgs, "namespace"> & {
|
14
|
+
/**
|
15
|
+
* Whether to apply "pod-security.kubernetes.io/enforce=privileged" label to the namespace.
|
16
|
+
*/
|
17
|
+
privileged?: boolean
|
18
|
+
}
|
19
|
+
|
20
|
+
export type CreateOrPatchNamespaceArgs = NamespaceArgs & {
|
21
|
+
/**
|
22
|
+
* The resource to use to determine the name of the namespace.
|
23
|
+
*
|
24
|
+
* If not provided, the namespace will be created, otherwise it will be retrieved/patched.
|
25
|
+
*/
|
26
|
+
resource: Input<k8s.Resource> | undefined
|
27
|
+
}
|
28
|
+
|
29
|
+
export abstract class Namespace extends ComponentResource {
|
30
|
+
protected constructor(
|
31
|
+
type: string,
|
32
|
+
name: string,
|
33
|
+
args: Inputs,
|
34
|
+
opts: ComponentResourceOptions | undefined,
|
35
|
+
|
36
|
+
/**
|
37
|
+
* The cluster where the namespace is created.
|
38
|
+
*/
|
39
|
+
readonly cluster: Output<k8s.Cluster>,
|
40
|
+
|
41
|
+
/*
|
42
|
+
* The metadata of the underlying Kubernetes namespace.
|
43
|
+
*/
|
44
|
+
readonly metadata: Output<types.output.meta.v1.ObjectMeta>,
|
45
|
+
|
46
|
+
/**
|
47
|
+
* The spec of the underlying Kubernetes namespace.
|
48
|
+
*/
|
49
|
+
readonly spec: Output<types.output.core.v1.NamespaceSpec>,
|
50
|
+
|
51
|
+
/**
|
52
|
+
* The status of the underlying Kubernetes namespace.
|
53
|
+
*/
|
54
|
+
readonly status: Output<types.output.core.v1.NamespaceStatus>,
|
55
|
+
) {
|
56
|
+
super(type, name, args, opts)
|
57
|
+
}
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Creates a new namespace.
|
61
|
+
*/
|
62
|
+
static create(name: string, args: NamespaceArgs, opts?: ComponentResourceOptions): Namespace {
|
63
|
+
return new CreatedNamespace(name, args, opts)
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Creates a new namespace or patches an existing one.
|
68
|
+
*
|
69
|
+
* Will throw an error if the namespace does not exist when `args.resource` is provided.
|
70
|
+
*/
|
71
|
+
static createOrPatch(
|
72
|
+
name: string,
|
73
|
+
args: CreateOrPatchNamespaceArgs,
|
74
|
+
opts?: ComponentResourceOptions,
|
75
|
+
): Namespace {
|
76
|
+
if (!args.resource) {
|
77
|
+
return new CreatedNamespace(name, args, opts)
|
78
|
+
}
|
79
|
+
|
80
|
+
return new NamespacePatch(
|
81
|
+
name,
|
82
|
+
{
|
83
|
+
...args,
|
84
|
+
name: output(args).apply(args => {
|
85
|
+
if (args.resource!.clusterId !== args.cluster.id) {
|
86
|
+
throw new Error(
|
87
|
+
`Cluster mismatch when patching namespace "${name}": "${args.resource!.clusterId}" != "${args.cluster.id}"`,
|
88
|
+
)
|
89
|
+
}
|
90
|
+
|
91
|
+
return args.resource!.metadata.namespace
|
92
|
+
}),
|
93
|
+
},
|
94
|
+
opts,
|
95
|
+
)
|
96
|
+
}
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Creates a new namespace or gets an existing one.
|
100
|
+
*
|
101
|
+
* Will throw an error if the namespace does not exist when `args.resource` is provided.
|
102
|
+
*/
|
103
|
+
static createOrGet(
|
104
|
+
name: string,
|
105
|
+
args: CreateOrPatchNamespaceArgs,
|
106
|
+
opts?: ComponentResourceOptions,
|
107
|
+
): Namespace {
|
108
|
+
if (!args.resource) {
|
109
|
+
return new CreatedNamespace(name, args, opts)
|
110
|
+
}
|
111
|
+
|
112
|
+
return new ExternalNamespace(
|
113
|
+
name,
|
114
|
+
output(args).apply(args => {
|
115
|
+
if (args.resource!.clusterId !== args.cluster.id) {
|
116
|
+
throw new Error(
|
117
|
+
`Cluster mismatch when receiving namespace "${name}": "${args.resource!.clusterId}" != "${args.cluster.id}"`,
|
118
|
+
)
|
119
|
+
}
|
120
|
+
|
121
|
+
return args.resource!.metadata.namespace
|
122
|
+
}),
|
123
|
+
args.cluster,
|
124
|
+
opts,
|
125
|
+
)
|
126
|
+
}
|
127
|
+
|
128
|
+
/**
|
129
|
+
* Patches an existing namespace.
|
130
|
+
*
|
131
|
+
* Will throw an error if the namespace does not exist.
|
132
|
+
*/
|
133
|
+
static patch(name: string, args: NamespaceArgs, opts?: ComponentResourceOptions): Namespace {
|
134
|
+
return new NamespacePatch(name, args, opts)
|
135
|
+
}
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Gets an existing namespace.
|
139
|
+
*
|
140
|
+
* Will throw an error if the namespace does not exist.
|
141
|
+
*/
|
142
|
+
static get(
|
143
|
+
name: string,
|
144
|
+
id: Input<string>,
|
145
|
+
cluster: Input<k8s.Cluster>,
|
146
|
+
opts?: ComponentResourceOptions,
|
147
|
+
): Namespace {
|
148
|
+
return new ExternalNamespace(name, id, cluster, opts)
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
class CreatedNamespace extends Namespace {
|
153
|
+
constructor(name: string, args: NamespaceArgs, opts?: ComponentResourceOptions) {
|
154
|
+
const namespace = output(args).apply(async args => {
|
155
|
+
return new core.v1.Namespace(
|
156
|
+
name,
|
157
|
+
{
|
158
|
+
metadata: mapMetadata(args, name),
|
159
|
+
},
|
160
|
+
{
|
161
|
+
...opts,
|
162
|
+
parent: this,
|
163
|
+
provider: await getProvider(args.cluster),
|
164
|
+
},
|
165
|
+
)
|
166
|
+
})
|
167
|
+
|
168
|
+
super(
|
169
|
+
"highstate:k8s:Namespace",
|
170
|
+
name,
|
171
|
+
args,
|
172
|
+
opts,
|
173
|
+
output(args.cluster),
|
174
|
+
namespace.metadata,
|
175
|
+
namespace.spec,
|
176
|
+
namespace.status,
|
177
|
+
)
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
class NamespacePatch extends Namespace {
|
182
|
+
constructor(name: string, args: NamespaceArgs, opts?: ComponentResourceOptions) {
|
183
|
+
const namespace = output(args).apply(async args => {
|
184
|
+
return new core.v1.NamespacePatch(
|
185
|
+
name,
|
186
|
+
{
|
187
|
+
metadata: mapMetadata(args, name),
|
188
|
+
},
|
189
|
+
{
|
190
|
+
...opts,
|
191
|
+
parent: this,
|
192
|
+
provider: await getProvider(args.cluster),
|
193
|
+
},
|
194
|
+
)
|
195
|
+
})
|
196
|
+
|
197
|
+
super(
|
198
|
+
"highstate:k8s:NamespacePatch",
|
199
|
+
name,
|
200
|
+
args,
|
201
|
+
opts,
|
202
|
+
output(args.cluster),
|
203
|
+
namespace.metadata,
|
204
|
+
namespace.spec,
|
205
|
+
namespace.status,
|
206
|
+
)
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
class ExternalNamespace extends Namespace {
|
211
|
+
constructor(
|
212
|
+
name: string,
|
213
|
+
id: Input<string>,
|
214
|
+
cluster: Input<k8s.Cluster>,
|
215
|
+
opts?: ComponentResourceOptions,
|
216
|
+
) {
|
217
|
+
const namespace = output(id).apply(async realName => {
|
218
|
+
return core.v1.Namespace.get(
|
219
|
+
//
|
220
|
+
name,
|
221
|
+
realName,
|
222
|
+
{
|
223
|
+
...opts,
|
224
|
+
parent: this,
|
225
|
+
provider: await getProvider(cluster),
|
226
|
+
},
|
227
|
+
)
|
228
|
+
})
|
229
|
+
|
230
|
+
super(
|
231
|
+
"highstate:k8s:ExternalNamespace",
|
232
|
+
name,
|
233
|
+
{ id, cluster },
|
234
|
+
opts,
|
235
|
+
output(cluster),
|
236
|
+
namespace.metadata,
|
237
|
+
namespace.spec,
|
238
|
+
namespace.status,
|
239
|
+
)
|
240
|
+
}
|
241
|
+
}
|