@mrsimpson/homelab-core-components 0.1.0
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/README.md +47 -0
- package/dist/ExposedWebApp.d.ts +242 -0
- package/dist/ExposedWebApp.d.ts.map +1 -0
- package/dist/ExposedWebApp.js +723 -0
- package/dist/ExposedWebApp.js.map +1 -0
- package/dist/createHomelabContextFromStack.d.ts +82 -0
- package/dist/createHomelabContextFromStack.d.ts.map +1 -0
- package/dist/createHomelabContextFromStack.js +75 -0
- package/dist/createHomelabContextFromStack.js.map +1 -0
- package/dist/homelab-context.d.ts +26 -0
- package/dist/homelab-context.d.ts.map +1 -0
- package/dist/homelab-context.js +24 -0
- package/dist/homelab-context.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/registry-secrets.d.ts +66 -0
- package/dist/registry-secrets.d.ts.map +1 -0
- package/dist/registry-secrets.js +178 -0
- package/dist/registry-secrets.js.map +1 -0
- package/package.json +52 -0
- package/src/ExposedWebApp.ts +918 -0
- package/src/createHomelabContextFromStack.ts +120 -0
- package/src/homelab-context.ts +49 -0
- package/src/index.ts +24 -0
- package/src/registry-secrets.ts +173 -0
|
@@ -0,0 +1,918 @@
|
|
|
1
|
+
import * as cloudflare from "@pulumi/cloudflare";
|
|
2
|
+
import * as k8s from "@pulumi/kubernetes";
|
|
3
|
+
import * as pulumi from "@pulumi/pulumi";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ExposedWebApp — reusable Pulumi component for deploying web apps with secure internet exposure.
|
|
7
|
+
*
|
|
8
|
+
* Handles the full stack: Deployment → Service → HTTPRoute/IngressRoute → TLS → DNS.
|
|
9
|
+
*
|
|
10
|
+
* ## Authentication modes
|
|
11
|
+
* - `AuthType.NONE` — no auth, public access
|
|
12
|
+
* - `AuthType.FORWARD` — Authelia forward-auth via Traefik ForwardAuth middleware
|
|
13
|
+
* - `AuthType.OAUTH2_PROXY` — GitHub OAuth via the shared oauth2-proxy IngressRoute
|
|
14
|
+
*
|
|
15
|
+
* ## What gets created automatically
|
|
16
|
+
* - `Namespace` (with Pod Security Standards labels, unless you pass your own)
|
|
17
|
+
* - `Deployment` + `Service` (ClusterIP)
|
|
18
|
+
* - `HTTPRoute` or `IngressRoute[]` depending on auth mode
|
|
19
|
+
* - Optional `PersistentVolumeClaim` (when `storage` is set)
|
|
20
|
+
* - Optional Cloudflare DNS `Record` (when `cloudflare` is set)
|
|
21
|
+
* - Optional `ExternalSecret` for GHCR pull credentials (when `imagePullSecrets` references `ghcr-pull-secret`)
|
|
22
|
+
*
|
|
23
|
+
* ## Key options
|
|
24
|
+
*
|
|
25
|
+
* ### Container overrides
|
|
26
|
+
* - `command` / `args` — override entrypoint / arguments (e.g. `args: ["web", "--port", "4096"]`)
|
|
27
|
+
*
|
|
28
|
+
* ### Extra volumes
|
|
29
|
+
* - `extraVolumes` / `extraVolumeMounts` — inject additional volumes (ConfigMaps, hostPath, etc.)
|
|
30
|
+
* alongside the built-in storage PVC mount.
|
|
31
|
+
*
|
|
32
|
+
* ### Node pinning
|
|
33
|
+
* - `nodeSelector` — pin the pod to specific node(s) by label.
|
|
34
|
+
* **Required when using hostPath volumes**, which are node-local by definition.
|
|
35
|
+
* Example: `{ "kubernetes.io/hostname": "flinker" }`
|
|
36
|
+
*
|
|
37
|
+
* ### Security context
|
|
38
|
+
* - `securityContext.runAsUser/Group/fsGroup` — UID/GID for the container and volume ownership.
|
|
39
|
+
* - `securityContext.allowRoot` — set to `true` only when the image genuinely requires UID 0.
|
|
40
|
+
* Automatically relaxes the namespace Pod Security Standard from `restricted` to `baseline`.
|
|
41
|
+
* Also disables `runAsNonRoot` on the pod and container security contexts.
|
|
42
|
+
* Prefer fixing the image to run as non-root instead of using this flag.
|
|
43
|
+
* - `extraVolumes` with `hostPath` — automatically relaxes the namespace PSS to `privileged`
|
|
44
|
+
* (the only level that permits hostPath volumes per the Kubernetes PSS spec).
|
|
45
|
+
* The pod itself still runs as non-root with all capabilities dropped.
|
|
46
|
+
*
|
|
47
|
+
* ### Service account
|
|
48
|
+
* - `serviceAccountName` — set the pod's ServiceAccount (must already exist in the namespace).
|
|
49
|
+
* Useful when the app needs RBAC permissions (e.g. managing pods via the K8s API).
|
|
50
|
+
*
|
|
51
|
+
* ### Health probes
|
|
52
|
+
* - `probes.readinessProbe` / `probes.livenessProbe` — standard Kubernetes probe objects
|
|
53
|
+
* applied to the main app container. Omit to use no probes (Kubernetes default).
|
|
54
|
+
*
|
|
55
|
+
* ## OAuth2-Proxy middleware naming
|
|
56
|
+
*
|
|
57
|
+
* When `auth` is `AuthType.OAUTH2_PROXY`, three Traefik middlewares are created in the
|
|
58
|
+
* app's namespace with deterministic names:
|
|
59
|
+
* - `<name>-oauth2-forwardauth` — ForwardAuth check against oauth2-proxy
|
|
60
|
+
* - `<name>-oauth2-errors` — 401 → redirect to sign-in
|
|
61
|
+
* - `<name>-oauth2-chain` — chains errors + forwardauth
|
|
62
|
+
*
|
|
63
|
+
* Apps that need **additional IngressRoutes** (e.g. wildcard subdomain routes) can
|
|
64
|
+
* reference the chain middleware by name to share the same auth flow:
|
|
65
|
+
* ```yaml
|
|
66
|
+
* middlewares:
|
|
67
|
+
* - name: <name>-oauth2-chain
|
|
68
|
+
* namespace: <app-namespace>
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* ## Example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* homelab.createExposedWebApp("blog", {
|
|
74
|
+
* image: "ghost:5",
|
|
75
|
+
* domain: pulumi.interpolate`blog.${homelabConfig.domain}`,
|
|
76
|
+
* port: 2368,
|
|
77
|
+
* auth: AuthType.OAUTH2_PROXY,
|
|
78
|
+
* storage: { size: "10Gi", mountPath: "/var/lib/ghost/content" },
|
|
79
|
+
* nodeSelector: { "kubernetes.io/hostname": "flinker" },
|
|
80
|
+
* extraVolumes: [{ name: "cfg", configMap: { name: "blog-config" } }],
|
|
81
|
+
* extraVolumeMounts: [{ name: "cfg", mountPath: "/etc/blog" }],
|
|
82
|
+
* });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Authentication type for ExposedWebApp
|
|
88
|
+
*/
|
|
89
|
+
export enum AuthType {
|
|
90
|
+
/** No authentication required */
|
|
91
|
+
NONE = "none",
|
|
92
|
+
/** Authelia forward authentication via Traefik ForwardAuth middleware */
|
|
93
|
+
FORWARD = "forward",
|
|
94
|
+
/** OAuth2-Proxy authentication via GitHub OAuth (uses IngressRoute instead of HTTPRoute) */
|
|
95
|
+
OAUTH2_PROXY = "oauth2",
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface StorageConfig {
|
|
99
|
+
size: string;
|
|
100
|
+
mountPath: string;
|
|
101
|
+
storageClass?: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface CloudflareConfig {
|
|
105
|
+
/** Cloudflare Zone ID for creating DNS records */
|
|
106
|
+
zoneId: string | pulumi.Output<string>;
|
|
107
|
+
/** CNAME value for DNS record (usually the Cloudflare Tunnel hostname) */
|
|
108
|
+
tunnelCname: string | pulumi.Output<string>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface TLSConfig {
|
|
112
|
+
/** ClusterIssuer resource for automatic TLS certificate provisioning */
|
|
113
|
+
clusterIssuer?: k8s.apiextensions.CustomResource;
|
|
114
|
+
/** Name of the ClusterIssuer (if not providing the resource) */
|
|
115
|
+
clusterIssuerName?: string | pulumi.Output<string>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface GatewayApiConfig {
|
|
119
|
+
/** Gateway class name (defaults to "traefik") */
|
|
120
|
+
gatewayClass?: string;
|
|
121
|
+
/** Gateway name (defaults to "homelab-gateway") */
|
|
122
|
+
gatewayName?: string;
|
|
123
|
+
/** Gateway namespace (defaults to "traefik-system") */
|
|
124
|
+
gatewayNamespace?: string;
|
|
125
|
+
/** ForwardAuth middleware name for authentication (defaults to "authelia-forwardauth") */
|
|
126
|
+
forwardAuthMiddleware?: string;
|
|
127
|
+
/** Gateway controller resource to depend on */
|
|
128
|
+
controller?: pulumi.Resource;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface ExternalSecretsConfig {
|
|
132
|
+
/** External Secrets Operator resource to depend on */
|
|
133
|
+
operator?: pulumi.Resource;
|
|
134
|
+
/** ClusterSecretStore name (defaults to "pulumi-esc") */
|
|
135
|
+
storeName?: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface OAuth2ProxyConfig {
|
|
139
|
+
/** Which oauth2-proxy group to use (defaults to "users") */
|
|
140
|
+
group?: string;
|
|
141
|
+
/** Namespace where oauth2-proxy is deployed (defaults to "oauth2-proxy") */
|
|
142
|
+
namespace?: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface ExposedWebAppArgs {
|
|
146
|
+
/** Container image to deploy */
|
|
147
|
+
image: string | pulumi.Output<string>;
|
|
148
|
+
/** Fully qualified domain name */
|
|
149
|
+
domain: string | pulumi.Output<string>;
|
|
150
|
+
/** Container port */
|
|
151
|
+
port: number;
|
|
152
|
+
/** Number of replicas (defaults to 1) */
|
|
153
|
+
replicas?: number;
|
|
154
|
+
/** Override the container entrypoint (maps to K8s container.command) */
|
|
155
|
+
command?: string[];
|
|
156
|
+
/** Container arguments (maps to K8s container.args) */
|
|
157
|
+
args?: string[];
|
|
158
|
+
/** Environment variables */
|
|
159
|
+
env?: Array<{ name: string; value: string | pulumi.Output<string> }>;
|
|
160
|
+
/** Authentication type (defaults to "none") */
|
|
161
|
+
auth?: AuthType;
|
|
162
|
+
/** Persistent storage configuration */
|
|
163
|
+
storage?: StorageConfig;
|
|
164
|
+
/** Resource requests and limits */
|
|
165
|
+
resources?: {
|
|
166
|
+
requests?: { cpu?: string; memory?: string };
|
|
167
|
+
limits?: { cpu?: string; memory?: string };
|
|
168
|
+
};
|
|
169
|
+
/** Tags for organizing resources */
|
|
170
|
+
tags?: string[];
|
|
171
|
+
/** ImagePullSecrets for private container registries (e.g., GHCR, ECR) */
|
|
172
|
+
imagePullSecrets?: Array<{ name: string }>;
|
|
173
|
+
/** Security context configuration for pod and container */
|
|
174
|
+
securityContext?: {
|
|
175
|
+
runAsUser?: number;
|
|
176
|
+
runAsGroup?: number;
|
|
177
|
+
fsGroup?: number;
|
|
178
|
+
/**
|
|
179
|
+
* Set to true only when the container image requires root (UID 0) to function.
|
|
180
|
+
* This disables the `runAsNonRoot` enforcement on both the pod and container security
|
|
181
|
+
* contexts, and relaxes the namespace Pod Security Standard to "baseline".
|
|
182
|
+
* Use with caution — prefer fixing the image to run as non-root instead.
|
|
183
|
+
*/
|
|
184
|
+
allowRoot?: boolean;
|
|
185
|
+
};
|
|
186
|
+
/** Optional pre-created namespace (if not provided, will create one) */
|
|
187
|
+
namespace?: k8s.core.v1.Namespace;
|
|
188
|
+
/**
|
|
189
|
+
* Pin the pod to specific node(s) using Kubernetes nodeSelector labels.
|
|
190
|
+
* Required when using hostPath volumes (which are node-local by definition).
|
|
191
|
+
* Example: { "kubernetes.io/hostname": "flinker" }
|
|
192
|
+
*/
|
|
193
|
+
nodeSelector?: Record<string, string>;
|
|
194
|
+
/** Extra volumes to add to the pod spec (in addition to the optional storage PVC) */
|
|
195
|
+
extraVolumes?: object[];
|
|
196
|
+
/** Extra volume mounts to add to the app container (in addition to the optional storage mount) */
|
|
197
|
+
extraVolumeMounts?: object[];
|
|
198
|
+
/**
|
|
199
|
+
* Init containers to run before the main app container starts.
|
|
200
|
+
* Useful for seeding files into emptyDir volumes or other pre-start setup.
|
|
201
|
+
* Each entry is a full Kubernetes container spec object.
|
|
202
|
+
*/
|
|
203
|
+
initContainers?: object[];
|
|
204
|
+
/**
|
|
205
|
+
* Additional sidecar containers to run alongside the main app container.
|
|
206
|
+
* Each entry is a full Kubernetes container spec object.
|
|
207
|
+
* Sidecars share the pod's ServiceAccount, imagePullSecrets, and network namespace.
|
|
208
|
+
* Useful for operator sidecars, log shippers, proxies, etc.
|
|
209
|
+
*/
|
|
210
|
+
extraContainers?: object[];
|
|
211
|
+
/** ServiceAccount name to set on the pod spec (must already exist in the namespace) */
|
|
212
|
+
serviceAccountName?: string;
|
|
213
|
+
/** Container probes for the main app container */
|
|
214
|
+
probes?: {
|
|
215
|
+
readinessProbe?: object;
|
|
216
|
+
livenessProbe?: object;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// Infrastructure dependencies (all optional)
|
|
220
|
+
/** Cloudflare DNS configuration */
|
|
221
|
+
cloudflare?: CloudflareConfig;
|
|
222
|
+
/** TLS/cert-manager configuration */
|
|
223
|
+
tls?: TLSConfig;
|
|
224
|
+
/** Gateway API configuration */
|
|
225
|
+
gatewayApi?: GatewayApiConfig;
|
|
226
|
+
/** External Secrets Operator configuration */
|
|
227
|
+
externalSecrets?: ExternalSecretsConfig;
|
|
228
|
+
/** OAuth2-Proxy configuration (required when auth is OAUTH2_PROXY) */
|
|
229
|
+
oauth2Proxy?: OAuth2ProxyConfig;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export class ExposedWebApp extends pulumi.ComponentResource {
|
|
233
|
+
public readonly namespace: k8s.core.v1.Namespace;
|
|
234
|
+
public readonly deployment: k8s.apps.v1.Deployment;
|
|
235
|
+
public readonly service: k8s.core.v1.Service;
|
|
236
|
+
/** Route resource(s): single HTTPRoute (Authelia/NONE) or IngressRoute[] (OAuth2-Proxy) */
|
|
237
|
+
public readonly route: k8s.apiextensions.CustomResource | k8s.apiextensions.CustomResource[];
|
|
238
|
+
public readonly forwardAuthMiddleware?: k8s.apiextensions.CustomResource;
|
|
239
|
+
public readonly dnsRecord?: cloudflare.Record;
|
|
240
|
+
public readonly pvc?: k8s.core.v1.PersistentVolumeClaim;
|
|
241
|
+
|
|
242
|
+
constructor(name: string, args: ExposedWebAppArgs, opts?: pulumi.ComponentResourceOptions) {
|
|
243
|
+
super("homelab:ExposedWebApp", name, {}, opts);
|
|
244
|
+
|
|
245
|
+
const childOpts = { parent: this };
|
|
246
|
+
|
|
247
|
+
// Use provided namespace or create a new one
|
|
248
|
+
const isCreatingNamespace = !args.namespace;
|
|
249
|
+
// Pod Security Standard level for the namespace:
|
|
250
|
+
// - "restricted": default, enforces non-root, no hostPath, etc.
|
|
251
|
+
// - "baseline": required when allowRoot is set (permits running as UID 0)
|
|
252
|
+
// - "privileged": required when hostPath volumes are present (hostPath is
|
|
253
|
+
// forbidden even in baseline per the K8s PSS spec)
|
|
254
|
+
const hasHostPath = args.extraVolumes?.some(
|
|
255
|
+
(v) => typeof v === "object" && v !== null && "hostPath" in v
|
|
256
|
+
);
|
|
257
|
+
const podSecurityLevel = hasHostPath
|
|
258
|
+
? "privileged"
|
|
259
|
+
: args.securityContext?.allowRoot
|
|
260
|
+
? "baseline"
|
|
261
|
+
: "restricted";
|
|
262
|
+
const namespace =
|
|
263
|
+
args.namespace ||
|
|
264
|
+
new k8s.core.v1.Namespace(
|
|
265
|
+
`${name}-ns`,
|
|
266
|
+
{
|
|
267
|
+
metadata: {
|
|
268
|
+
name: name,
|
|
269
|
+
labels: {
|
|
270
|
+
app: name,
|
|
271
|
+
environment: pulumi.getStack(),
|
|
272
|
+
// Pod Security Standards — relaxed to "baseline" when the image requires root
|
|
273
|
+
"pod-security.kubernetes.io/enforce": podSecurityLevel,
|
|
274
|
+
"pod-security.kubernetes.io/audit": podSecurityLevel,
|
|
275
|
+
"pod-security.kubernetes.io/warn": podSecurityLevel,
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
childOpts
|
|
280
|
+
);
|
|
281
|
+
this.namespace = namespace;
|
|
282
|
+
|
|
283
|
+
// If creating a new namespace AND imagePullSecrets are specified,
|
|
284
|
+
// automatically create ExternalSecrets for common pull secret names
|
|
285
|
+
const pullSecretResources: k8s.apiextensions.CustomResource[] = [];
|
|
286
|
+
if (isCreatingNamespace && args.imagePullSecrets && args.externalSecrets) {
|
|
287
|
+
const storeName = args.externalSecrets.storeName || "pulumi-esc";
|
|
288
|
+
|
|
289
|
+
// Create dependencies for ExternalSecret
|
|
290
|
+
const externalSecretDeps: pulumi.Resource[] = [namespace];
|
|
291
|
+
if (args.externalSecrets.operator) {
|
|
292
|
+
externalSecretDeps.push(args.externalSecrets.operator);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
args.imagePullSecrets.forEach((pullSecret) => {
|
|
296
|
+
// Only auto-create for known secret names to avoid creating unnecessary resources
|
|
297
|
+
if (pullSecret.name === "ghcr-pull-secret") {
|
|
298
|
+
pullSecretResources.push(
|
|
299
|
+
new k8s.apiextensions.CustomResource(
|
|
300
|
+
`${name}-ghcr-pull-secret`,
|
|
301
|
+
{
|
|
302
|
+
apiVersion: "external-secrets.io/v1beta1",
|
|
303
|
+
kind: "ExternalSecret",
|
|
304
|
+
metadata: {
|
|
305
|
+
name: "ghcr-pull-secret",
|
|
306
|
+
namespace: namespace.metadata.name,
|
|
307
|
+
},
|
|
308
|
+
spec: {
|
|
309
|
+
refreshInterval: "1h",
|
|
310
|
+
secretStoreRef: {
|
|
311
|
+
name: storeName,
|
|
312
|
+
kind: "ClusterSecretStore",
|
|
313
|
+
},
|
|
314
|
+
target: {
|
|
315
|
+
name: "ghcr-pull-secret",
|
|
316
|
+
creationPolicy: "Owner",
|
|
317
|
+
template: {
|
|
318
|
+
type: "kubernetes.io/dockerconfigjson",
|
|
319
|
+
data: {
|
|
320
|
+
".dockerconfigjson": `{"auths":{"ghcr.io":{"username":"{{ .github_username }}","password":"{{ .github_token }}","auth":"{{ printf "%s:%s" .github_username .github_token | b64enc }}"}}}`,
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
data: [
|
|
325
|
+
{
|
|
326
|
+
secretKey: "github_username",
|
|
327
|
+
remoteRef: {
|
|
328
|
+
key: "github-username",
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
secretKey: "github_token",
|
|
333
|
+
remoteRef: {
|
|
334
|
+
key: "github-token",
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
],
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
{ ...childOpts, dependsOn: externalSecretDeps }
|
|
341
|
+
)
|
|
342
|
+
);
|
|
343
|
+
} else if (pullSecret.name === "dockerhub-pull-secret") {
|
|
344
|
+
pullSecretResources.push(
|
|
345
|
+
new k8s.apiextensions.CustomResource(
|
|
346
|
+
`${name}-dockerhub-pull-secret`,
|
|
347
|
+
{
|
|
348
|
+
apiVersion: "external-secrets.io/v1beta1",
|
|
349
|
+
kind: "ExternalSecret",
|
|
350
|
+
metadata: {
|
|
351
|
+
name: "dockerhub-pull-secret",
|
|
352
|
+
namespace: namespace.metadata.name,
|
|
353
|
+
},
|
|
354
|
+
spec: {
|
|
355
|
+
refreshInterval: "1h",
|
|
356
|
+
secretStoreRef: {
|
|
357
|
+
name: storeName,
|
|
358
|
+
kind: "ClusterSecretStore",
|
|
359
|
+
},
|
|
360
|
+
target: {
|
|
361
|
+
name: "dockerhub-pull-secret",
|
|
362
|
+
creationPolicy: "Owner",
|
|
363
|
+
template: {
|
|
364
|
+
type: "kubernetes.io/dockerconfigjson",
|
|
365
|
+
data: {
|
|
366
|
+
".dockerconfigjson": `{
|
|
367
|
+
"auths": {
|
|
368
|
+
"https://index.docker.io/v1/": {
|
|
369
|
+
"username": "{{ .dockerhub_username }}",
|
|
370
|
+
"password": "{{ .dockerhub_token }}",
|
|
371
|
+
"auth": "{{ printf "%s:%s" .dockerhub_username .dockerhub_token | b64enc }}"
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}`,
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
data: [
|
|
379
|
+
{
|
|
380
|
+
secretKey: "dockerhub_username",
|
|
381
|
+
remoteRef: {
|
|
382
|
+
key: "dockerhub-credentials/username",
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
secretKey: "dockerhub_token",
|
|
387
|
+
remoteRef: {
|
|
388
|
+
key: "dockerhub-credentials/token",
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
],
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
{ ...childOpts, dependsOn: externalSecretDeps }
|
|
395
|
+
)
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Optional: Create PVC for persistent storage
|
|
402
|
+
if (args.storage) {
|
|
403
|
+
this.pvc = new k8s.core.v1.PersistentVolumeClaim(
|
|
404
|
+
`${name}-pvc`,
|
|
405
|
+
{
|
|
406
|
+
metadata: {
|
|
407
|
+
name: `${name}-storage`,
|
|
408
|
+
namespace: namespace.metadata.name,
|
|
409
|
+
},
|
|
410
|
+
spec: {
|
|
411
|
+
accessModes: ["ReadWriteOnce"],
|
|
412
|
+
storageClassName: args.storage.storageClass || "local-path",
|
|
413
|
+
resources: {
|
|
414
|
+
requests: {
|
|
415
|
+
storage: args.storage.size,
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
childOpts
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// Main application container
|
|
425
|
+
const appContainer: any = {
|
|
426
|
+
name: "app",
|
|
427
|
+
image: args.image,
|
|
428
|
+
ports: [
|
|
429
|
+
{
|
|
430
|
+
containerPort: args.port,
|
|
431
|
+
name: "http",
|
|
432
|
+
},
|
|
433
|
+
],
|
|
434
|
+
env: args.env || [],
|
|
435
|
+
resources: args.resources || {
|
|
436
|
+
requests: { cpu: "100m", memory: "128Mi" },
|
|
437
|
+
limits: { cpu: "500m", memory: "512Mi" },
|
|
438
|
+
},
|
|
439
|
+
securityContext: {
|
|
440
|
+
allowPrivilegeEscalation: false,
|
|
441
|
+
// Only enforce runAsNonRoot when the image supports it (opt-out via allowRoot)
|
|
442
|
+
...(args.securityContext?.allowRoot ? {} : { runAsNonRoot: true }),
|
|
443
|
+
capabilities: {
|
|
444
|
+
drop: ["ALL"],
|
|
445
|
+
},
|
|
446
|
+
seccompProfile: {
|
|
447
|
+
type: "RuntimeDefault",
|
|
448
|
+
},
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
// Add optional command / args overrides
|
|
453
|
+
if (args.command) {
|
|
454
|
+
appContainer.command = args.command;
|
|
455
|
+
}
|
|
456
|
+
if (args.args) {
|
|
457
|
+
appContainer.args = args.args;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// Add optional probes
|
|
461
|
+
if (args.probes?.readinessProbe) {
|
|
462
|
+
appContainer.readinessProbe = args.probes.readinessProbe;
|
|
463
|
+
}
|
|
464
|
+
if (args.probes?.livenessProbe) {
|
|
465
|
+
appContainer.livenessProbe = args.probes.livenessProbe;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// Build volume mounts: storage PVC mount + any extra mounts
|
|
469
|
+
const volumeMounts: object[] = [];
|
|
470
|
+
if (args.storage && this.pvc) {
|
|
471
|
+
volumeMounts.push({
|
|
472
|
+
name: "storage",
|
|
473
|
+
mountPath: args.storage.mountPath,
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
if (args.extraVolumeMounts) {
|
|
477
|
+
volumeMounts.push(...args.extraVolumeMounts);
|
|
478
|
+
}
|
|
479
|
+
if (volumeMounts.length > 0) {
|
|
480
|
+
appContainer.volumeMounts = volumeMounts;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// Build volumes list: storage PVC + any extra volumes
|
|
484
|
+
const volumes: any[] = [];
|
|
485
|
+
if (args.storage && this.pvc) {
|
|
486
|
+
volumes.push({
|
|
487
|
+
name: "storage",
|
|
488
|
+
persistentVolumeClaim: {
|
|
489
|
+
claimName: this.pvc.metadata.name,
|
|
490
|
+
},
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
if (args.extraVolumes) {
|
|
494
|
+
volumes.push(...args.extraVolumes);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// Create Deployment
|
|
498
|
+
// Build deployment dependencies - include pull secrets if we created them
|
|
499
|
+
const deploymentDeps: pulumi.Resource[] = [namespace, ...pullSecretResources];
|
|
500
|
+
|
|
501
|
+
this.deployment = new k8s.apps.v1.Deployment(
|
|
502
|
+
`${name}-deployment`,
|
|
503
|
+
{
|
|
504
|
+
metadata: {
|
|
505
|
+
name: name,
|
|
506
|
+
namespace: namespace.metadata.name,
|
|
507
|
+
labels: {
|
|
508
|
+
app: name,
|
|
509
|
+
environment: pulumi.getStack(),
|
|
510
|
+
},
|
|
511
|
+
},
|
|
512
|
+
spec: {
|
|
513
|
+
replicas: args.replicas || 1,
|
|
514
|
+
selector: {
|
|
515
|
+
matchLabels: {
|
|
516
|
+
app: name,
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
template: {
|
|
520
|
+
metadata: {
|
|
521
|
+
labels: {
|
|
522
|
+
app: name,
|
|
523
|
+
},
|
|
524
|
+
},
|
|
525
|
+
spec: {
|
|
526
|
+
serviceAccountName: args.serviceAccountName,
|
|
527
|
+
imagePullSecrets: args.imagePullSecrets,
|
|
528
|
+
nodeSelector: args.nodeSelector,
|
|
529
|
+
securityContext: {
|
|
530
|
+
// Only enforce runAsNonRoot when the image supports it (opt-out via allowRoot)
|
|
531
|
+
...(args.securityContext?.allowRoot ? {} : { runAsNonRoot: true }),
|
|
532
|
+
// When allowRoot is true, omit runAsUser/runAsGroup to let the image use its own UID
|
|
533
|
+
...(args.securityContext?.allowRoot
|
|
534
|
+
? {}
|
|
535
|
+
: {
|
|
536
|
+
runAsUser: args.securityContext?.runAsUser || 1000,
|
|
537
|
+
runAsGroup: args.securityContext?.runAsGroup || 1000,
|
|
538
|
+
}),
|
|
539
|
+
fsGroup: args.securityContext?.allowRoot
|
|
540
|
+
? undefined
|
|
541
|
+
: args.securityContext?.fsGroup || 1000,
|
|
542
|
+
},
|
|
543
|
+
containers: [
|
|
544
|
+
appContainer,
|
|
545
|
+
...((args.extraContainers ?? []) as k8s.types.input.core.v1.Container[]),
|
|
546
|
+
],
|
|
547
|
+
initContainers: args.initContainers as
|
|
548
|
+
| k8s.types.input.core.v1.Container[]
|
|
549
|
+
| undefined,
|
|
550
|
+
volumes: volumes.length > 0 ? volumes : undefined,
|
|
551
|
+
},
|
|
552
|
+
},
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
{ ...childOpts, dependsOn: deploymentDeps }
|
|
556
|
+
);
|
|
557
|
+
|
|
558
|
+
// Create Service
|
|
559
|
+
this.service = new k8s.core.v1.Service(
|
|
560
|
+
`${name}-service`,
|
|
561
|
+
{
|
|
562
|
+
metadata: {
|
|
563
|
+
name: name,
|
|
564
|
+
namespace: namespace.metadata.name,
|
|
565
|
+
},
|
|
566
|
+
spec: {
|
|
567
|
+
type: "ClusterIP",
|
|
568
|
+
selector: {
|
|
569
|
+
app: name,
|
|
570
|
+
},
|
|
571
|
+
ports: [
|
|
572
|
+
{
|
|
573
|
+
port: 80,
|
|
574
|
+
targetPort: args.port,
|
|
575
|
+
protocol: "TCP",
|
|
576
|
+
name: "http",
|
|
577
|
+
},
|
|
578
|
+
],
|
|
579
|
+
},
|
|
580
|
+
},
|
|
581
|
+
{ ...childOpts, dependsOn: [this.deployment] }
|
|
582
|
+
);
|
|
583
|
+
|
|
584
|
+
// --- Routing & Authentication ---
|
|
585
|
+
// OAuth2-Proxy uses IngressRoute (Traefik CRD) for reliable cross-namespace support
|
|
586
|
+
// Authelia and NONE use Gateway API HTTPRoute
|
|
587
|
+
|
|
588
|
+
if (args.auth === AuthType.OAUTH2_PROXY) {
|
|
589
|
+
// --- OAuth2-Proxy: IngressRoute-based routing ---
|
|
590
|
+
const oauth2Group = args.oauth2Proxy?.group || "users";
|
|
591
|
+
const oauth2Namespace = args.oauth2Proxy?.namespace || "oauth2-proxy";
|
|
592
|
+
const oauth2ProxyServiceAddress = `http://oauth2-proxy-${oauth2Group}.${oauth2Namespace}.svc.cluster.local/oauth2/auth`;
|
|
593
|
+
|
|
594
|
+
// ForwardAuth middleware - checks session via /oauth2/auth
|
|
595
|
+
this.forwardAuthMiddleware = new k8s.apiextensions.CustomResource(
|
|
596
|
+
`${name}-oauth2-forwardauth`,
|
|
597
|
+
{
|
|
598
|
+
apiVersion: "traefik.io/v1alpha1",
|
|
599
|
+
kind: "Middleware",
|
|
600
|
+
metadata: {
|
|
601
|
+
name: `${name}-oauth2-forwardauth`,
|
|
602
|
+
namespace: namespace.metadata.name,
|
|
603
|
+
},
|
|
604
|
+
spec: {
|
|
605
|
+
forwardAuth: {
|
|
606
|
+
address: oauth2ProxyServiceAddress,
|
|
607
|
+
trustForwardHeader: true,
|
|
608
|
+
// CRITICAL: Forward Cookie header so oauth2-proxy can see the session
|
|
609
|
+
authRequestHeaders: ["Cookie", "Authorization"],
|
|
610
|
+
authResponseHeaders: [
|
|
611
|
+
"X-Auth-Request-User",
|
|
612
|
+
"X-Auth-Request-Email",
|
|
613
|
+
"X-Auth-Request-Groups",
|
|
614
|
+
"Set-Cookie",
|
|
615
|
+
],
|
|
616
|
+
},
|
|
617
|
+
},
|
|
618
|
+
},
|
|
619
|
+
{ ...childOpts, dependsOn: [this.service] }
|
|
620
|
+
);
|
|
621
|
+
|
|
622
|
+
// Use shared redirect service from oauth2-proxy namespace
|
|
623
|
+
// This eliminates per-app ConfigMap + Deployment + Service (3 resources saved!)
|
|
624
|
+
|
|
625
|
+
// Errors middleware - catches 401 and serves redirect page from shared service
|
|
626
|
+
const errorsMiddleware = new k8s.apiextensions.CustomResource(
|
|
627
|
+
`${name}-oauth2-errors`,
|
|
628
|
+
{
|
|
629
|
+
apiVersion: "traefik.io/v1alpha1",
|
|
630
|
+
kind: "Middleware",
|
|
631
|
+
metadata: {
|
|
632
|
+
name: `${name}-oauth2-errors`,
|
|
633
|
+
namespace: namespace.metadata.name,
|
|
634
|
+
},
|
|
635
|
+
spec: {
|
|
636
|
+
errors: {
|
|
637
|
+
status: ["401"],
|
|
638
|
+
service: {
|
|
639
|
+
// Use ExternalName service to reference shared redirect service in oauth2-proxy namespace
|
|
640
|
+
name: "oauth2-shared-redirect",
|
|
641
|
+
namespace: "oauth2-proxy",
|
|
642
|
+
port: 80,
|
|
643
|
+
},
|
|
644
|
+
query: pulumi.interpolate`/?rd=https://${args.domain}{url}`,
|
|
645
|
+
},
|
|
646
|
+
},
|
|
647
|
+
},
|
|
648
|
+
{ ...childOpts, dependsOn: [this.service] }
|
|
649
|
+
);
|
|
650
|
+
|
|
651
|
+
// Chain middleware - errors wraps forwardauth
|
|
652
|
+
const chainMiddleware = new k8s.apiextensions.CustomResource(
|
|
653
|
+
`${name}-oauth2-chain`,
|
|
654
|
+
{
|
|
655
|
+
apiVersion: "traefik.io/v1alpha1",
|
|
656
|
+
kind: "Middleware",
|
|
657
|
+
metadata: {
|
|
658
|
+
name: `${name}-oauth2-chain`,
|
|
659
|
+
namespace: namespace.metadata.name,
|
|
660
|
+
},
|
|
661
|
+
spec: {
|
|
662
|
+
chain: {
|
|
663
|
+
middlewares: [
|
|
664
|
+
{ name: `${name}-oauth2-errors` },
|
|
665
|
+
{ name: `${name}-oauth2-forwardauth` },
|
|
666
|
+
],
|
|
667
|
+
},
|
|
668
|
+
},
|
|
669
|
+
},
|
|
670
|
+
{ ...childOpts, dependsOn: [errorsMiddleware, this.forwardAuthMiddleware] }
|
|
671
|
+
);
|
|
672
|
+
|
|
673
|
+
// IngressRoute 1: /oauth2/* → oauth2-proxy (unprotected, handles sign-in flow)
|
|
674
|
+
const signinRoute = new k8s.apiextensions.CustomResource(
|
|
675
|
+
`${name}-oauth2-signin-route`,
|
|
676
|
+
{
|
|
677
|
+
apiVersion: "traefik.io/v1alpha1",
|
|
678
|
+
kind: "IngressRoute",
|
|
679
|
+
metadata: {
|
|
680
|
+
name: `${name}-oauth2-signin`,
|
|
681
|
+
namespace: namespace.metadata.name,
|
|
682
|
+
},
|
|
683
|
+
spec: {
|
|
684
|
+
// Use "web" entryPoint: Cloudflare terminates TLS, traffic arrives as HTTP
|
|
685
|
+
entryPoints: ["web"],
|
|
686
|
+
routes: [
|
|
687
|
+
{
|
|
688
|
+
match: pulumi.interpolate`Host(\`${args.domain}\`) && PathPrefix(\`/oauth2/\`)`,
|
|
689
|
+
kind: "Rule",
|
|
690
|
+
services: [
|
|
691
|
+
{
|
|
692
|
+
name: `oauth2-proxy-${oauth2Group}`,
|
|
693
|
+
namespace: oauth2Namespace,
|
|
694
|
+
port: 80,
|
|
695
|
+
},
|
|
696
|
+
],
|
|
697
|
+
},
|
|
698
|
+
],
|
|
699
|
+
},
|
|
700
|
+
},
|
|
701
|
+
{ ...childOpts, dependsOn: [namespace] }
|
|
702
|
+
);
|
|
703
|
+
|
|
704
|
+
// IngressRoute 2: /* → app backend (protected by middleware chain)
|
|
705
|
+
const appRoute = new k8s.apiextensions.CustomResource(
|
|
706
|
+
`${name}-oauth2-app-route`,
|
|
707
|
+
{
|
|
708
|
+
apiVersion: "traefik.io/v1alpha1",
|
|
709
|
+
kind: "IngressRoute",
|
|
710
|
+
metadata: {
|
|
711
|
+
name: `${name}-oauth2-app`,
|
|
712
|
+
namespace: namespace.metadata.name,
|
|
713
|
+
},
|
|
714
|
+
spec: {
|
|
715
|
+
entryPoints: ["web"],
|
|
716
|
+
routes: [
|
|
717
|
+
{
|
|
718
|
+
match: pulumi.interpolate`Host(\`${args.domain}\`)`,
|
|
719
|
+
kind: "Rule",
|
|
720
|
+
middlewares: [
|
|
721
|
+
{
|
|
722
|
+
name: `${name}-oauth2-chain`,
|
|
723
|
+
namespace: namespace.metadata.name,
|
|
724
|
+
},
|
|
725
|
+
],
|
|
726
|
+
services: [
|
|
727
|
+
{
|
|
728
|
+
name: this.service.metadata.name,
|
|
729
|
+
port: 80,
|
|
730
|
+
},
|
|
731
|
+
],
|
|
732
|
+
priority: 1, // Lower priority than /oauth2/* route
|
|
733
|
+
},
|
|
734
|
+
],
|
|
735
|
+
},
|
|
736
|
+
},
|
|
737
|
+
{ ...childOpts, dependsOn: [this.service, chainMiddleware, signinRoute] }
|
|
738
|
+
);
|
|
739
|
+
|
|
740
|
+
this.route = [signinRoute, appRoute];
|
|
741
|
+
} else {
|
|
742
|
+
// --- Authelia / NONE: Gateway API HTTPRoute ---
|
|
743
|
+
|
|
744
|
+
const gatewayName = args.gatewayApi?.gatewayName || "homelab-gateway";
|
|
745
|
+
const gatewayNamespace = args.gatewayApi?.gatewayNamespace || "traefik-system";
|
|
746
|
+
|
|
747
|
+
// Build Gateway API dependencies
|
|
748
|
+
const httpRouteDeps: pulumi.Resource[] = [this.service];
|
|
749
|
+
if (args.gatewayApi?.controller) {
|
|
750
|
+
httpRouteDeps.push(args.gatewayApi.controller);
|
|
751
|
+
}
|
|
752
|
+
if (args.tls?.clusterIssuer) {
|
|
753
|
+
httpRouteDeps.push(args.tls.clusterIssuer);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// Create ForwardAuth middleware for Authelia
|
|
757
|
+
if (args.auth === AuthType.FORWARD) {
|
|
758
|
+
this.forwardAuthMiddleware = new k8s.apiextensions.CustomResource(
|
|
759
|
+
`${name}-forwardauth`,
|
|
760
|
+
{
|
|
761
|
+
apiVersion: "traefik.io/v1alpha1",
|
|
762
|
+
kind: "Middleware",
|
|
763
|
+
metadata: {
|
|
764
|
+
name: `forwardauth`,
|
|
765
|
+
namespace: namespace.metadata.name,
|
|
766
|
+
},
|
|
767
|
+
spec: {
|
|
768
|
+
forwardAuth: {
|
|
769
|
+
address: "http://authelia.authelia.svc.cluster.local:9091/api/authz/auth-request",
|
|
770
|
+
trustForwardHeader: true,
|
|
771
|
+
authRequestHeaders: [
|
|
772
|
+
"X-Original-URL",
|
|
773
|
+
"X-Original-Method",
|
|
774
|
+
"X-Forwarded-Host",
|
|
775
|
+
"X-Forwarded-Proto",
|
|
776
|
+
"X-Forwarded-Uri",
|
|
777
|
+
"Accept",
|
|
778
|
+
"Authorization",
|
|
779
|
+
"Cookie",
|
|
780
|
+
],
|
|
781
|
+
authResponseHeaders: [
|
|
782
|
+
"Remote-User",
|
|
783
|
+
"Remote-Groups",
|
|
784
|
+
"Remote-Name",
|
|
785
|
+
"Remote-Email",
|
|
786
|
+
],
|
|
787
|
+
},
|
|
788
|
+
},
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
...childOpts,
|
|
792
|
+
dependsOn: httpRouteDeps,
|
|
793
|
+
}
|
|
794
|
+
);
|
|
795
|
+
|
|
796
|
+
httpRouteDeps.push(this.forwardAuthMiddleware);
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// Determine TLS configuration
|
|
800
|
+
const tlsIssuerName = args.tls?.clusterIssuerName || "letsencrypt-prod";
|
|
801
|
+
const hasTLS = args.tls?.clusterIssuer || args.tls?.clusterIssuerName;
|
|
802
|
+
|
|
803
|
+
// Build HTTPRoute spec
|
|
804
|
+
const httpRouteSpec: any = {
|
|
805
|
+
parentRefs: [
|
|
806
|
+
{
|
|
807
|
+
name: gatewayName,
|
|
808
|
+
namespace: gatewayNamespace,
|
|
809
|
+
},
|
|
810
|
+
],
|
|
811
|
+
hostnames: [args.domain],
|
|
812
|
+
rules: [
|
|
813
|
+
{
|
|
814
|
+
matches: [
|
|
815
|
+
{
|
|
816
|
+
path: {
|
|
817
|
+
type: "PathPrefix",
|
|
818
|
+
value: "/",
|
|
819
|
+
},
|
|
820
|
+
},
|
|
821
|
+
],
|
|
822
|
+
backendRefs: [
|
|
823
|
+
{
|
|
824
|
+
name: this.service.metadata.name,
|
|
825
|
+
port: 80,
|
|
826
|
+
},
|
|
827
|
+
],
|
|
828
|
+
},
|
|
829
|
+
],
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
// Add ForwardAuth middleware for Authelia authentication
|
|
833
|
+
if (args.auth === AuthType.FORWARD && this.forwardAuthMiddleware) {
|
|
834
|
+
httpRouteSpec.rules[0].filters = [
|
|
835
|
+
{
|
|
836
|
+
type: "RequestHeaderModifier",
|
|
837
|
+
requestHeaderModifier: {
|
|
838
|
+
set: [
|
|
839
|
+
{
|
|
840
|
+
name: "X-Original-URL",
|
|
841
|
+
value: `https://${args.domain}`,
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
name: "X-Original-Method",
|
|
845
|
+
value: "GET",
|
|
846
|
+
},
|
|
847
|
+
],
|
|
848
|
+
},
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
type: "ExtensionRef",
|
|
852
|
+
extensionRef: {
|
|
853
|
+
group: "traefik.io",
|
|
854
|
+
kind: "Middleware",
|
|
855
|
+
name: this.forwardAuthMiddleware.metadata.name,
|
|
856
|
+
},
|
|
857
|
+
},
|
|
858
|
+
];
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// Create Gateway API HTTPRoute
|
|
862
|
+
this.route = new k8s.apiextensions.CustomResource(
|
|
863
|
+
`${name}-httproute`,
|
|
864
|
+
{
|
|
865
|
+
apiVersion: "gateway.networking.k8s.io/v1",
|
|
866
|
+
kind: "HTTPRoute",
|
|
867
|
+
metadata: {
|
|
868
|
+
name: name,
|
|
869
|
+
namespace: namespace.metadata.name,
|
|
870
|
+
annotations: hasTLS
|
|
871
|
+
? {
|
|
872
|
+
"cert-manager.io/cluster-issuer": tlsIssuerName,
|
|
873
|
+
}
|
|
874
|
+
: {},
|
|
875
|
+
},
|
|
876
|
+
spec: httpRouteSpec,
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
...childOpts,
|
|
880
|
+
dependsOn: httpRouteDeps,
|
|
881
|
+
}
|
|
882
|
+
);
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
// Optional: Create Cloudflare DNS record
|
|
886
|
+
if (args.cloudflare) {
|
|
887
|
+
this.dnsRecord = new cloudflare.Record(
|
|
888
|
+
`${name}-dns`,
|
|
889
|
+
{
|
|
890
|
+
zoneId: args.cloudflare.zoneId,
|
|
891
|
+
name: args.domain,
|
|
892
|
+
type: "CNAME",
|
|
893
|
+
content: args.cloudflare.tunnelCname,
|
|
894
|
+
// Proxy through Cloudflare to enable both IPv4 and IPv6
|
|
895
|
+
proxied: true,
|
|
896
|
+
comment: `Managed by Pulumi - ${name}`,
|
|
897
|
+
// Allow Pulumi to take ownership of a pre-existing record with the
|
|
898
|
+
// same name/type (e.g. when migrating from manually-created records
|
|
899
|
+
// or when the Pulumi URN changes due to refactoring).
|
|
900
|
+
allowOverwrite: true,
|
|
901
|
+
},
|
|
902
|
+
childOpts
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
this.registerOutputs({
|
|
907
|
+
namespaceName: this.namespace.metadata.name,
|
|
908
|
+
deploymentName: this.deployment.metadata.name,
|
|
909
|
+
serviceName: this.service.metadata.name,
|
|
910
|
+
routeName: Array.isArray(this.route)
|
|
911
|
+
? this.route.map((r) => r.metadata.name)
|
|
912
|
+
: this.route.metadata.name,
|
|
913
|
+
forwardAuthMiddlewareName: this.forwardAuthMiddleware?.metadata.name,
|
|
914
|
+
domain: args.domain,
|
|
915
|
+
dnsRecordId: this.dnsRecord?.id,
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
}
|