cdk8s-local 0.1.0 → 0.2.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/CHANGELOG.md +12 -0
- package/dist/config.d.mts +3 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/k3d-config/index.d.mts +1 -1
- package/dist/k3d-config/index.mjs.map +1 -1
- package/dist/requirements.mjs +1 -1
- package/dist/requirements.mjs.map +1 -1
- package/package.json +4 -4
- package/src/config.ts +3 -3
- package/src/index.ts +3 -3
- package/src/k3d-config/index.ts +1 -1
- package/src/requirements.ts +1 -1
- package/tsconfig.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# cdk8s-local
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Fixed dependency packaging errors and published `utils` rather than attempting to bundle it.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- cdk8s-kbld2@0.2.0
|
|
13
|
+
- @hamishwhc/cdk8s-monorepo-utils@0.1.0
|
|
14
|
+
|
|
3
15
|
## 0.1.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/config.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DefaultArgs } from "./default-args.mjs";
|
|
2
2
|
import { K3dConfig } from "./k3d-config/index.mjs";
|
|
3
3
|
import { RequiredProgram } from "./requirements.mjs";
|
|
4
|
-
import { ArgTypes, Output } from "@
|
|
5
|
-
import { Awaitable } from "@
|
|
6
|
-
import { CommonContext, CommonStartupContext } from "@
|
|
4
|
+
import { ArgTypes, Output } from "@hamishwhc/cdk8s-monorepo-utils/cmd-ts-types";
|
|
5
|
+
import { Awaitable } from "@hamishwhc/cdk8s-monorepo-utils/awaitable";
|
|
6
|
+
import { CommonContext, CommonStartupContext } from "@hamishwhc/cdk8s-monorepo-utils/cli-contexts";
|
|
7
7
|
import { App } from "cdk8s";
|
|
8
8
|
|
|
9
9
|
//#region src/config.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -6,7 +6,7 @@ import isWsl from "is-wsl";
|
|
|
6
6
|
import * as cmd_ts_dist_cjs_argparser0 from "cmd-ts/dist/cjs/argparser";
|
|
7
7
|
import * as cmd_ts_dist_cjs_helpdoc0 from "cmd-ts/dist/cjs/helpdoc";
|
|
8
8
|
import * as cmd_ts_dist_cjs_runner0 from "cmd-ts/dist/cjs/runner";
|
|
9
|
-
import { ArgTypes } from "@
|
|
9
|
+
import { ArgTypes } from "@hamishwhc/cdk8s-monorepo-utils/cmd-ts-types";
|
|
10
10
|
|
|
11
11
|
//#region src/index.d.ts
|
|
12
12
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import { getK3dNodes } from "./get-k3d-nodes.mjs";
|
|
|
3
3
|
import { getRegistry } from "./get-registry.mjs";
|
|
4
4
|
import { resolveK3dConfig } from "./k3d-config/index.mjs";
|
|
5
5
|
import { DEFAULT_REQUIREMENTS, checkRequirements } from "./requirements.mjs";
|
|
6
|
-
import { logger } from "@
|
|
7
|
-
import { resolveThunk } from "@
|
|
6
|
+
import { logger } from "@hamishwhc/cdk8s-monorepo-utils/logger";
|
|
7
|
+
import { resolveThunk } from "@hamishwhc/cdk8s-monorepo-utils/thunk";
|
|
8
8
|
import { $ } from "bun";
|
|
9
9
|
import { KbldConfig } from "cdk8s-kbld2";
|
|
10
10
|
import { binary, command, run } from "cmd-ts";
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { ArgTypes } from \"@repo/utils/cmd-ts-types\";\nimport { logger } from \"@repo/utils/logger\";\nimport { resolveThunk } from \"@repo/utils/thunk\";\nimport { $ } from \"bun\";\nimport { KbldConfig } from \"cdk8s-kbld2\";\nimport { binary, command, run } from \"cmd-ts\";\nimport { ConstructOrder } from \"constructs\";\nimport { rm } from \"fs/promises\";\nimport isWsl from \"is-wsl\";\nimport path from \"path\";\nimport type { Config } from \"./config\";\nimport { defaultArgs } from \"./default-args\";\nimport { getK3dNodes } from \"./get-k3d-nodes\";\nimport { getRegistry } from \"./get-registry\";\nimport { resolveK3dConfig, type K3dConfigResolution } from \"./k3d-config\";\nimport { checkRequirements, DEFAULT_REQUIREMENTS, type CommonRequirements } from \"./requirements\";\n\ntype ManifestSource = { type: \"directory\"; path: string } | { type: \"buffer\"; buffer: ArrayBuffer };\n\nexport type {\n\tBindMountVolume,\n\tEnvironmentVariable,\n\tK3dConfig,\n\tK3dConfigResolution,\n\tK3dSimpleConfig,\n\tK3DSimpleConfigV1Alpha5,\n\tK3sArg,\n\tPort,\n} from \"./k3d-config\";\nexport { CommonRequirements, Config, isWsl };\n\n/**\n * Creates a cdk8s-local CLI command based on the provided configuration.\n *\n * Unless you want to integrate a cdk8s-local command into an existing cmd-ts CLI, you probably want to use `cdk8sLocal` instead.\n */\nexport function cdk8sLocalCommand<Arguments extends ArgTypes, Data>(config: Config<Arguments, Data>) {\n\treturn command({\n\t\tname: config.command?.name ?? \"local\",\n\t\tdescription:\n\t\t\tconfig.command?.description ?? \"Synthesises, builds and deploys your CDK8s app to a local k3d cluster.\",\n\t\targs: {\n\t\t\t...config.args!,\n\t\t\t...defaultArgs,\n\t\t},\n\t\thandler: async (args) => {\n\t\t\tconst startupCtx = { args, command: \"local\" as const };\n\t\t\tconst additionalRequirements = (await resolveThunk(config.requirements, startupCtx)) ?? [];\n\t\t\tawait checkRequirements([...DEFAULT_REQUIREMENTS, ...additionalRequirements]);\n\n\t\t\tconst ctx = {\n\t\t\t\t...startupCtx,\n\t\t\t\tdata: (await config.hooks?.startup?.(startupCtx)) ?? ({} as Data),\n\t\t\t};\n\n\t\t\tconst clusterName = (await resolveThunk(config.clusterName, ctx)) ?? \"cdk8s-local\";\n\n\t\t\tconst clusterGetProc = await $`k3d cluster get ${clusterName}`.throws(false).quiet();\n\t\t\tlet create = true;\n\t\t\tif (clusterGetProc.exitCode === 0) {\n\t\t\t\tif (args.recreate) {\n\t\t\t\t\tlogger.info(\"Deleting existing k3d cluster...\");\n\t\t\t\t\tawait $`k3d cluster delete ${clusterName}`.quiet();\n\t\t\t\t} else {\n\t\t\t\t\tcreate = false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet registry = create ? null : await getRegistry(clusterName);\n\t\t\tlet k3dConfigResolution: K3dConfigResolution | null = null;\n\n\t\t\tif (create) {\n\t\t\t\tconst k3dConfig = await resolveThunk(config.k3d, ctx);\n\t\t\t\tk3dConfigResolution = await resolveK3dConfig(clusterName, k3dConfig);\n\t\t\t\tregistry = k3dConfigResolution.registry;\n\t\t\t}\n\n\t\t\tconst synthCtx = {\n\t\t\t\t...ctx,\n\t\t\t\tcreate,\n\t\t\t\tregistry,\n\t\t\t};\n\t\t\tsynthCtx.data = (await config.hooks?.preSynth?.(synthCtx)) ?? synthCtx.data;\n\n\t\t\tlogger.info(\"Running synth (generating manifests)...\");\n\t\t\tconst app = await config.synth(synthCtx);\n\t\t\tawait rm(app.outdir, { recursive: true, force: true });\n\t\t\tapp.synth();\n\n\t\t\tif (args.synth) {\n\t\t\t\tlogger.info(\n\t\t\t\t\t\"Synth complete, skipping build and deploy, find manifests in \" + path.relative(process.cwd(), app.outdir),\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (k3dConfigResolution) {\n\t\t\t\tlogger.info(`Creating k3d cluster (${clusterName})...`);\n\t\t\t\tif (k3dConfigResolution.originalConfig?.configureCilium && isWsl) {\n\t\t\t\t\tlogger.warn(\"Cilium configuration is not supported on WSL, skipping Cilium setup for k3d.\");\n\t\t\t\t\tk3dConfigResolution.originalConfig.configureCilium = false;\n\t\t\t\t}\n\n\t\t\t\tfor (const volume of k3dConfigResolution.originalConfig?.volumes ?? []) {\n\t\t\t\t\tif (volume.deleteOnClusterCreate) {\n\t\t\t\t\t\tawait rm(volume.hostPath, { recursive: true, force: true });\n\t\t\t\t\t}\n\t\t\t\t\tawait $`mkdir -p ${volume.hostPath}`;\n\t\t\t\t}\n\n\t\t\t\tconst configBuffer = Buffer.from(k3dConfigResolution.resolvedConfig, \"utf-8\");\n\t\t\t\tawait $`k3d cluster create -c - < ${configBuffer}`;\n\n\t\t\t\tif (k3dConfigResolution.originalConfig?.configureCilium) {\n\t\t\t\t\tconst nodes = await getK3dNodes(clusterName);\n\t\t\t\t\tfor (const { name, role } of nodes) {\n\t\t\t\t\t\tif (role !== \"server\" && role !== \"agent\") {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Magic to make Cilium work on MacOS (and hopefully Linux) Docker Desktop/OrbStack:\n\t\t\t\t\t\t// - https://sandstorm.de/blog/posts/running-cilium-in-k3s-and-k3d-lightweight-kubernetes-on-mac-os-for-development\n\t\t\t\t\t\t// - https://github.com/cilium/cilium/issues/10516\n\t\t\t\t\t\t// - https://github.com/k3d-io/k3d/issues/363\n\t\t\t\t\t\t// - https://docs.cilium.io/en/v1.14/installation/rancher-desktop/#rancher-desktop-install\n\t\t\t\t\t\t// - https://github.com/istio/istio/issues/54865\n\t\t\t\t\t\tawait $`docker exec -it ${name} mount bpffs /sys/fs/bpf -t bpf`;\n\t\t\t\t\t\tawait $`docker exec -it ${name} mount --make-shared /sys/fs/bpf`;\n\t\t\t\t\t\tawait $`docker exec -it ${name} mkdir -p /run/cilium/cgroupv2`;\n\t\t\t\t\t\tawait $`docker exec -it ${name} mount -t cgroup2 none /run/cilium/cgroupv2`;\n\t\t\t\t\t\tawait $`docker exec -it ${name} mount --make-shared /run/cilium/cgroupv2`;\n\t\t\t\t\t\tawait $`docker exec -it ${name} mount --make-rshared /var/run`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet manifestSource: ManifestSource = { type: \"directory\" as const, path: app.outdir };\n\t\t\tif (app.node.findAll(ConstructOrder.POSTORDER).find((c) => c instanceof KbldConfig)) {\n\t\t\t\tlogger.info(\"Detected kbld config construct, running kbld...\");\n\t\t\t\ttry {\n\t\t\t\t\tmanifestSource = { type: \"buffer\" as const, buffer: await $`kbld -f ${app.outdir}`.arrayBuffer() };\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (e instanceof $.ShellError) {\n\t\t\t\t\t\tlogger.error(e.stderr.toString(\"utf-8\"));\n\t\t\t\t\t\tlogger.fatal(\"Failed to build images from manifests.\");\n\t\t\t\t\t\treturn 1;\n\t\t\t\t\t}\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t} else if (args.build) {\n\t\t\t\tlogger.warn(\n\t\t\t\t\t\"The --build flag was set but no kbld config was found in the app. Skipping build step - no manifests will be emitted on stdout.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (args.build) {\n\t\t\t\tif (manifestSource.type === \"buffer\") {\n\t\t\t\t\tprocess.stdout.write(Buffer.from(manifestSource.buffer));\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlogger.info(\"Applying manifests to local cluster...\");\n\n\t\t\t// TODO: Set KUBECONFIG for kapp to use the k3d cluster config directly, rather than relying on k3d setting current-context.\n\t\t\tconst context = (await $`kubectl config current-context`.text()).trim();\n\t\t\tif (context !== `k3d-${clusterName}`) {\n\t\t\t\tlogger.fatal(`Will not deploy local environment to context: ${context}`);\n\t\t\t\t// throw new CliError(\"Current kubectl context does not match k3d cluster context.\");\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// TODO: Re-evaluate if this is needed in general - it was originally added as I used to only include CRDs when creating a cluster.\n\t\t\t// const filterJson = {\n\t\t\t// \tnot: { and: [{ ops: [\"delete\"] }, { existingResource: { kinds: [\"CustomResourceDefinition\"] } }] },\n\t\t\t// };\n\t\t\t// const filter = `--diff-filter=${JSON.stringify(filterJson)}`;\n\t\t\ttry {\n\t\t\t\tconst commonArguments = [\"-y\", \"-a\", clusterName];\n\t\t\t\tif (manifestSource.type === \"directory\") {\n\t\t\t\t\tawait $`kapp deploy ${commonArguments} -f ${manifestSource.path}`;\n\t\t\t\t} else {\n\t\t\t\t\tawait $`kapp deploy ${commonArguments} -f - < ${manifestSource.buffer}`;\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tif (e instanceof $.ShellError) {\n\t\t\t\t\tlogger.fatal(\"Failed to deploy manifests to local cluster.\");\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\tthrow e;\n\t\t\t}\n\n\t\t\tlogger.info(\"Local deployment successful.\");\n\t\t},\n\t});\n}\n\nexport async function cdk8sLocal<Arguments extends ArgTypes, Data>(config: Config<Arguments, Data>) {\n\tconst cmd = cdk8sLocalCommand(config);\n\tawait run(binary(cmd), process.argv);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,kBAAoD,QAAiC;AACpG,QAAO,QAAQ;EACd,MAAM,OAAO,SAAS,QAAQ;EAC9B,aACC,OAAO,SAAS,eAAe;EAChC,MAAM;GACL,GAAG,OAAO;GACV,GAAG;GACH;EACD,SAAS,OAAO,SAAS;GACxB,MAAM,aAAa;IAAE;IAAM,SAAS;IAAkB;GACtD,MAAM,yBAA0B,MAAM,aAAa,OAAO,cAAc,WAAW,IAAK,EAAE;AAC1F,SAAM,kBAAkB,CAAC,GAAG,sBAAsB,GAAG,uBAAuB,CAAC;GAE7E,MAAM,MAAM;IACX,GAAG;IACH,MAAO,MAAM,OAAO,OAAO,UAAU,WAAW,IAAM,EAAE;IACxD;GAED,MAAM,cAAe,MAAM,aAAa,OAAO,aAAa,IAAI,IAAK;GAErE,MAAM,iBAAiB,MAAM,CAAC,mBAAmB,cAAc,OAAO,MAAM,CAAC,OAAO;GACpF,IAAI,SAAS;AACb,OAAI,eAAe,aAAa,EAC/B,KAAI,KAAK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AAkB,OAAO,CAChB,EAAE,QAAQ,KAAK"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { ArgTypes } from \"@hamishwhc/cdk8s-monorepo-utils/cmd-ts-types\";\nimport { logger } from \"@hamishwhc/cdk8s-monorepo-utils/logger\";\nimport { resolveThunk } from \"@hamishwhc/cdk8s-monorepo-utils/thunk\";\nimport { $ } from \"bun\";\nimport { KbldConfig } from \"cdk8s-kbld2\";\nimport { binary, command, run } from \"cmd-ts\";\nimport { ConstructOrder } from \"constructs\";\nimport { rm } from \"fs/promises\";\nimport isWsl from \"is-wsl\";\nimport path from \"path\";\nimport type { Config } from \"./config\";\nimport { defaultArgs } from \"./default-args\";\nimport { getK3dNodes } from \"./get-k3d-nodes\";\nimport { getRegistry } from \"./get-registry\";\nimport { resolveK3dConfig, type K3dConfigResolution } from \"./k3d-config\";\nimport { checkRequirements, DEFAULT_REQUIREMENTS, type CommonRequirements } from \"./requirements\";\n\ntype ManifestSource = { type: \"directory\"; path: string } | { type: \"buffer\"; buffer: ArrayBuffer };\n\nexport type {\n\tBindMountVolume,\n\tEnvironmentVariable,\n\tK3dConfig,\n\tK3dConfigResolution,\n\tK3dSimpleConfig,\n\tK3DSimpleConfigV1Alpha5,\n\tK3sArg,\n\tPort,\n} from \"./k3d-config\";\nexport { CommonRequirements, Config, isWsl };\n\n/**\n * Creates a cdk8s-local CLI command based on the provided configuration.\n *\n * Unless you want to integrate a cdk8s-local command into an existing cmd-ts CLI, you probably want to use `cdk8sLocal` instead.\n */\nexport function cdk8sLocalCommand<Arguments extends ArgTypes, Data>(config: Config<Arguments, Data>) {\n\treturn command({\n\t\tname: config.command?.name ?? \"local\",\n\t\tdescription:\n\t\t\tconfig.command?.description ?? \"Synthesises, builds and deploys your CDK8s app to a local k3d cluster.\",\n\t\targs: {\n\t\t\t...config.args!,\n\t\t\t...defaultArgs,\n\t\t},\n\t\thandler: async (args) => {\n\t\t\tconst startupCtx = { args, command: \"local\" as const };\n\t\t\tconst additionalRequirements = (await resolveThunk(config.requirements, startupCtx)) ?? [];\n\t\t\tawait checkRequirements([...DEFAULT_REQUIREMENTS, ...additionalRequirements]);\n\n\t\t\tconst ctx = {\n\t\t\t\t...startupCtx,\n\t\t\t\tdata: (await config.hooks?.startup?.(startupCtx)) ?? ({} as Data),\n\t\t\t};\n\n\t\t\tconst clusterName = (await resolveThunk(config.clusterName, ctx)) ?? \"cdk8s-local\";\n\n\t\t\tconst clusterGetProc = await $`k3d cluster get ${clusterName}`.throws(false).quiet();\n\t\t\tlet create = true;\n\t\t\tif (clusterGetProc.exitCode === 0) {\n\t\t\t\tif (args.recreate) {\n\t\t\t\t\tlogger.info(\"Deleting existing k3d cluster...\");\n\t\t\t\t\tawait $`k3d cluster delete ${clusterName}`.quiet();\n\t\t\t\t} else {\n\t\t\t\t\tcreate = false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet registry = create ? null : await getRegistry(clusterName);\n\t\t\tlet k3dConfigResolution: K3dConfigResolution | null = null;\n\n\t\t\tif (create) {\n\t\t\t\tconst k3dConfig = await resolveThunk(config.k3d, ctx);\n\t\t\t\tk3dConfigResolution = await resolveK3dConfig(clusterName, k3dConfig);\n\t\t\t\tregistry = k3dConfigResolution.registry;\n\t\t\t}\n\n\t\t\tconst synthCtx = {\n\t\t\t\t...ctx,\n\t\t\t\tcreate,\n\t\t\t\tregistry,\n\t\t\t};\n\t\t\tsynthCtx.data = (await config.hooks?.preSynth?.(synthCtx)) ?? synthCtx.data;\n\n\t\t\tlogger.info(\"Running synth (generating manifests)...\");\n\t\t\tconst app = await config.synth(synthCtx);\n\t\t\tawait rm(app.outdir, { recursive: true, force: true });\n\t\t\tapp.synth();\n\n\t\t\tif (args.synth) {\n\t\t\t\tlogger.info(\n\t\t\t\t\t\"Synth complete, skipping build and deploy, find manifests in \" + path.relative(process.cwd(), app.outdir),\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (k3dConfigResolution) {\n\t\t\t\tlogger.info(`Creating k3d cluster (${clusterName})...`);\n\t\t\t\tif (k3dConfigResolution.originalConfig?.configureCilium && isWsl) {\n\t\t\t\t\tlogger.warn(\"Cilium configuration is not supported on WSL, skipping Cilium setup for k3d.\");\n\t\t\t\t\tk3dConfigResolution.originalConfig.configureCilium = false;\n\t\t\t\t}\n\n\t\t\t\tfor (const volume of k3dConfigResolution.originalConfig?.volumes ?? []) {\n\t\t\t\t\tif (volume.deleteOnClusterCreate) {\n\t\t\t\t\t\tawait rm(volume.hostPath, { recursive: true, force: true });\n\t\t\t\t\t}\n\t\t\t\t\tawait $`mkdir -p ${volume.hostPath}`;\n\t\t\t\t}\n\n\t\t\t\tconst configBuffer = Buffer.from(k3dConfigResolution.resolvedConfig, \"utf-8\");\n\t\t\t\tawait $`k3d cluster create -c - < ${configBuffer}`;\n\n\t\t\t\tif (k3dConfigResolution.originalConfig?.configureCilium) {\n\t\t\t\t\tconst nodes = await getK3dNodes(clusterName);\n\t\t\t\t\tfor (const { name, role } of nodes) {\n\t\t\t\t\t\tif (role !== \"server\" && role !== \"agent\") {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Magic to make Cilium work on MacOS (and hopefully Linux) Docker Desktop/OrbStack:\n\t\t\t\t\t\t// - https://sandstorm.de/blog/posts/running-cilium-in-k3s-and-k3d-lightweight-kubernetes-on-mac-os-for-development\n\t\t\t\t\t\t// - https://github.com/cilium/cilium/issues/10516\n\t\t\t\t\t\t// - https://github.com/k3d-io/k3d/issues/363\n\t\t\t\t\t\t// - https://docs.cilium.io/en/v1.14/installation/rancher-desktop/#rancher-desktop-install\n\t\t\t\t\t\t// - https://github.com/istio/istio/issues/54865\n\t\t\t\t\t\tawait $`docker exec -it ${name} mount bpffs /sys/fs/bpf -t bpf`;\n\t\t\t\t\t\tawait $`docker exec -it ${name} mount --make-shared /sys/fs/bpf`;\n\t\t\t\t\t\tawait $`docker exec -it ${name} mkdir -p /run/cilium/cgroupv2`;\n\t\t\t\t\t\tawait $`docker exec -it ${name} mount -t cgroup2 none /run/cilium/cgroupv2`;\n\t\t\t\t\t\tawait $`docker exec -it ${name} mount --make-shared /run/cilium/cgroupv2`;\n\t\t\t\t\t\tawait $`docker exec -it ${name} mount --make-rshared /var/run`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet manifestSource: ManifestSource = { type: \"directory\" as const, path: app.outdir };\n\t\t\tif (app.node.findAll(ConstructOrder.POSTORDER).find((c) => c instanceof KbldConfig)) {\n\t\t\t\tlogger.info(\"Detected kbld config construct, running kbld...\");\n\t\t\t\ttry {\n\t\t\t\t\tmanifestSource = { type: \"buffer\" as const, buffer: await $`kbld -f ${app.outdir}`.arrayBuffer() };\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (e instanceof $.ShellError) {\n\t\t\t\t\t\tlogger.error(e.stderr.toString(\"utf-8\"));\n\t\t\t\t\t\tlogger.fatal(\"Failed to build images from manifests.\");\n\t\t\t\t\t\treturn 1;\n\t\t\t\t\t}\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t} else if (args.build) {\n\t\t\t\tlogger.warn(\n\t\t\t\t\t\"The --build flag was set but no kbld config was found in the app. Skipping build step - no manifests will be emitted on stdout.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (args.build) {\n\t\t\t\tif (manifestSource.type === \"buffer\") {\n\t\t\t\t\tprocess.stdout.write(Buffer.from(manifestSource.buffer));\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlogger.info(\"Applying manifests to local cluster...\");\n\n\t\t\t// TODO: Set KUBECONFIG for kapp to use the k3d cluster config directly, rather than relying on k3d setting current-context.\n\t\t\tconst context = (await $`kubectl config current-context`.text()).trim();\n\t\t\tif (context !== `k3d-${clusterName}`) {\n\t\t\t\tlogger.fatal(`Will not deploy local environment to context: ${context}`);\n\t\t\t\t// throw new CliError(\"Current kubectl context does not match k3d cluster context.\");\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// TODO: Re-evaluate if this is needed in general - it was originally added as I used to only include CRDs when creating a cluster.\n\t\t\t// const filterJson = {\n\t\t\t// \tnot: { and: [{ ops: [\"delete\"] }, { existingResource: { kinds: [\"CustomResourceDefinition\"] } }] },\n\t\t\t// };\n\t\t\t// const filter = `--diff-filter=${JSON.stringify(filterJson)}`;\n\t\t\ttry {\n\t\t\t\tconst commonArguments = [\"-y\", \"-a\", clusterName];\n\t\t\t\tif (manifestSource.type === \"directory\") {\n\t\t\t\t\tawait $`kapp deploy ${commonArguments} -f ${manifestSource.path}`;\n\t\t\t\t} else {\n\t\t\t\t\tawait $`kapp deploy ${commonArguments} -f - < ${manifestSource.buffer}`;\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tif (e instanceof $.ShellError) {\n\t\t\t\t\tlogger.fatal(\"Failed to deploy manifests to local cluster.\");\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\tthrow e;\n\t\t\t}\n\n\t\t\tlogger.info(\"Local deployment successful.\");\n\t\t},\n\t});\n}\n\nexport async function cdk8sLocal<Arguments extends ArgTypes, Data>(config: Config<Arguments, Data>) {\n\tconst cmd = cdk8sLocalCommand(config);\n\tawait run(binary(cmd), process.argv);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,kBAAoD,QAAiC;AACpG,QAAO,QAAQ;EACd,MAAM,OAAO,SAAS,QAAQ;EAC9B,aACC,OAAO,SAAS,eAAe;EAChC,MAAM;GACL,GAAG,OAAO;GACV,GAAG;GACH;EACD,SAAS,OAAO,SAAS;GACxB,MAAM,aAAa;IAAE;IAAM,SAAS;IAAkB;GACtD,MAAM,yBAA0B,MAAM,aAAa,OAAO,cAAc,WAAW,IAAK,EAAE;AAC1F,SAAM,kBAAkB,CAAC,GAAG,sBAAsB,GAAG,uBAAuB,CAAC;GAE7E,MAAM,MAAM;IACX,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AAM,eAAe;QAE3D,OAAM,CAAC,eAAe,gBAAgB,UAAU,eAAe;YAExD,GAAG;AACX,QAAI,aAAa,EAAE,YAAY;AAC9B,YAAO,MAAM,+CAA+C;AAC5D,YAAO;;AAER,UAAM;;AAGP,UAAO,KAAK,+BAA+B;;EAE5C,CAAC;;AAGH,eAAsB,WAA6C,QAAiC;AAEnG,OAAM,IAAI,OADE,kBAAkB,OAAO,CAChB,EAAE,QAAQ,KAAK"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RegistryInfo } from "../get-registry.mjs";
|
|
2
2
|
import { K3DSimpleConfigV1Alpha5, NodeFilters } from "./v1alpha5.mjs";
|
|
3
|
-
import { Awaitable } from "@
|
|
3
|
+
import { Awaitable } from "@hamishwhc/cdk8s-monorepo-utils/awaitable";
|
|
4
4
|
|
|
5
5
|
//#region src/k3d-config/index.d.ts
|
|
6
6
|
type K3dSimpleConfig = K3DSimpleConfigV1Alpha5;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/k3d-config/index.ts"],"sourcesContent":["import type { Awaitable } from \"@repo/utils/awaitable\";\nimport { YAML } from \"bun\";\nimport type { RegistryInfo } from \"../get-registry\";\nimport type { K3DSimpleConfigV1Alpha5, NodeFilters } from \"./v1alpha5\";\n\nfunction randomRegistryName() {\n\tconst randomHex = crypto\n\t\t.getRandomValues(new Uint8Array(2))\n\t\t.reduce((str, byte) => str + byte.toString(16).padStart(2, \"0\"), \"\");\n\treturn `registry-${randomHex}.k3d.hamishwhc.com`;\n}\n\nfunction randomRegistryPort() {\n\treturn 10000 + Math.floor(Math.random() * 50000);\n}\n\nexport { K3DSimpleConfigV1Alpha5 };\nexport type K3dSimpleConfig = K3DSimpleConfigV1Alpha5;\n\nexport interface BindMountVolume {\n\thostPath: string;\n\tcontainerPath: string;\n\t/**\n\t * If enabled, the host path will be deleted similarly to `rm -rf` on cluster creation.\n\t * @default false\n\t */\n\tdeleteOnClusterCreate?: boolean;\n\t/**\n\t * Node filters to determine which cluster nodes this volume applies to.\n\t * @example [\"server:0\", \"agent:*\"]\n\t * @default [\"all\"]\n\t */\n\tnodeFilters?: NodeFilters;\n}\n\nexport interface Port {\n\thostPort: number;\n\tcontainerPort: number;\n\t/**\n\t * Node filters to determine which cluster nodes this port mapping applies to.\n\t * Note that the default for port mappings is different to other items, as typically\n\t * port mappings are only needed on the loadbalancer node.\n\t *\n\t * @example [\"server:0\", \"agent:*\"]\n\t * @default [\"loadbalancer\"]\n\t */\n\tnodeFilters?: NodeFilters;\n}\n\nexport interface EnvironmentVariable {\n\tname: string;\n\tvalue: string;\n\t/**\n\t * Node filters to determine which cluster nodes this environment variable applies to.\n\t * @example [\"server:0\", \"agent:*\"]\n\t * @default [\"all\"]\n\t */\n\tnodeFilters?: NodeFilters;\n}\n\nexport interface K3sArg {\n\targ: string;\n\t/**\n\t * Node filters to determine which cluster nodes this k3s arg applies to.\n\t * @example [\"server:0\", \"agent:*\"]\n\t * @default [\"all\"]\n\t */\n\tnodeFilters?: NodeFilters;\n}\n\nexport interface K3dConfig {\n\t/**\n\t * The K3s image to use for the cluster nodes. k3d will automatically pick the latest version for your host architecture if not specified.\n\t *\n\t * You can specify a platform-specific image from the K3s image tags, such as `rancher/k3s:v1.34.1-k3s1-amd64`, to force the k3d nodes to be created as a specific platform.\n\t */\n\timage?: string;\n\n\t/**\n\t * Number of server nodes in the k3d cluster.\n\t * Note that the default of 1 disables etcd and the ability to add additional servers later.\n\t * See https://k3d.io/stable/usage/multiserver/#adding-server-nodes-to-a-running-cluster.\n\t * @default 1\n\t */\n\tservers?: number;\n\t/**\n\t * Number of agent nodes in the k3d cluster.\n\t * @default undefined\n\t */\n\tagents?: number;\n\n\t/**\n\t * Bind mount volumes to add to the k3d cluster on creation.\n\t *\n\t * Useful for inspecting PVCs and enabling code reloading by mounting source code into pods.\n\t *\n\t * @example\n\t * - Inspecting PVCs when using the built-in local-path provisioner:\n\t * ```ts\n\t * {\n\t * hostPath: path.join(YOUR_REPO_DIR, \".k3d\"),\n\t * containerPath: \"/var/lib/rancher/k3s/storage\",\n\t * deleteOnClusterCreate: true,\n\t * }\n\t * ```\n\t * - Mounting source code into pods for code reloading:\n\t * ```ts\n\t * {\n\t * hostPath: YOUR_REPO_DIR,\n\t * containerPath: \"/workspace\",\n\t * }\n\t * ```\n\t * You can then use `hostPath` mounts to mount sub-directories of `/workspace` into your pods as needed.\n\t *\n\t * @default []\n\t */\n\tvolumes?: BindMountVolume[];\n\t/**\n\t * Port mappings to add to the k3d cluster nodes on creation.\n\t */\n\tports?: Port[];\n\t/**\n\t * Environment variables to add to the k3d cluster nodes on creation.\n\t */\n\tenv?: EnvironmentVariable[];\n\n\t/**\n\t * The name of the k3d registry container.\n\t * The default will resolve to localhost, allowing `kbld` (or yourself) to\n\t * `docker push` images to it from your local machine without host file or other configuration changes.\n\t * See https://k3d.io/stable/usage/registries/#secure-registries for more information.\n\t *\n\t * If you want to use a more complicated registry configuration (e.g. using an existing registry, a proxy or mirrors)\n\t * or simply don't want to run a local registry, you can set this to `null`\n\t * and instead use `config` to provide custom k3d registry settings.\n\t *\n\t * Security note: consider setting up your own DNS A wildcard record on your own domain (e.g. `*.k3d.example.com`)\n\t * pointing to 127.0.0.1, to avoid DNS rebinding attacks.\n\t *\n\t * @default \"registry-${random-hex}.k3d.hamishwhc.com\"\n\t */\n\t// TODO: Consider persisting a k3d-managed registry between runs instead of creating a new one per cluster.\n\tregistryName?: string | null;\n\n\t/**\n\t * If enabled, k3d will be configured in a way that is compatible with Cilium networking.\n\t * This involves disabling the default flannel network plugin and network policy engine,\n\t * and pre-configuring some volumes required by Cilium within the k3d docker containers.\n\t * More information can be found in source code comments.\n\t *\n\t * Once the cluster is created, your CDK8s app is still responsible for installing and configuring Cilium itself.\n\t *\n\t * This is not supported on Windows Subsystem for Linux (WSL) at this time and a warning\n\t * will be logged if set to true on WSL.\n\t * The warning can be silenced by using the `isWsl` variable exported from this package\n\t * to conditionally set this value to false on WSL environments.\n\t *\n\t * @default false\n\t */\n\tconfigureCilium?: boolean;\n\n\t/**\n\t * If enabled, Traefik will be disabled in the K3s cluster using the K3s argument `--disable=traefik`.\n\t */\n\tdisableTraefik?: boolean;\n\t/**\n\t * If enabled, ServiceLB will be disabled in the K3s cluster using the K3s argument `--disable=servicelb`.\n\t */\n\tdisableServiceLB?: boolean;\n\t/**\n\t * Additional K3s arguments to pass to each k3d cluster node on creation.\n\t */\n\tk3sExtraArgs?: (string | K3sArg)[];\n\n\t/**\n\t * In the event you want to set other k3d cluster options, you can read/add to/modify/override any and all of the k3d config here.\n\t * This function receives the config generated by `cdk8s-local` and you can modify (or replace) it as needed.\n\t * This is only used during cluster creation.\n\t * I make no guarantees that your custom config will work with `cdk8s-local`, so use this with caution.\n\t * Note that the current config version supported by the types is `k3d.io/v1alpha5`.\n\t *\n\t * Generally, would recommend using only for adding k3d/K3s options not covered by the convenience options available in this package.\n\t */\n\tconfig?: (c: K3DSimpleConfigV1Alpha5, r: RegistryInfo | null) => Awaitable<string | K3dSimpleConfig>;\n}\n\nexport interface K3dConfigResolution {\n\toriginalConfig?: K3dConfig;\n\tautoConfig: K3DSimpleConfigV1Alpha5;\n\tresolvedConfig: string;\n\tregistry: RegistryInfo | null;\n}\n\nexport async function resolveK3dConfig(name: string, config: K3dConfig | undefined): Promise<K3dConfigResolution> {\n\tconst registry =\n\t\tconfig?.registryName !== null\n\t\t\t? {\n\t\t\t\t\tname: config?.registryName || randomRegistryName(),\n\t\t\t\t\tport: randomRegistryPort(),\n\t\t\t\t}\n\t\t\t: null;\n\n\tconst autoConfig: K3DSimpleConfigV1Alpha5 = {\n\t\tapiVersion: \"k3d.io/v1alpha5\",\n\t\tkind: \"Simple\",\n\t\tmetadata: { name },\n\t\timage: config?.image,\n\t\tservers: config?.servers ?? 1,\n\t\tagents: config?.agents ?? undefined,\n\t\tvolumes:\n\t\t\tconfig?.volumes?.map(({ hostPath, containerPath, nodeFilters }) => ({\n\t\t\t\tvolume: `${hostPath}:${containerPath}`,\n\t\t\t\tnodeFilters: nodeFilters ?? [\"all\"],\n\t\t\t})) ?? [],\n\t\tports:\n\t\t\tconfig?.ports?.map(({ hostPort, containerPort, nodeFilters }) => ({\n\t\t\t\tport: `${hostPort}:${containerPort}`,\n\t\t\t\tnodeFilters: nodeFilters ?? [\"loadbalancer\"],\n\t\t\t})) ?? [],\n\t\tregistries: registry\n\t\t\t? {\n\t\t\t\t\tcreate: {\n\t\t\t\t\t\tname: registry.name,\n\t\t\t\t\t\thostPort: `${registry.port}`,\n\t\t\t\t\t\t// enforcePortMatch: true,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tenv: config?.env?.map(({ name, value, nodeFilters }) => ({ envVar: `${name}=${value}`, nodeFilters })) ?? [],\n\t\toptions: {\n\t\t\tk3s: {\n\t\t\t\textraArgs: [\n\t\t\t\t\t...(config?.configureCilium ? [\"--flannel-backend=none\", \"--disable-network-policy\"] : []),\n\t\t\t\t\t...(config?.k3sExtraArgs ?? []),\n\t\t\t\t\t...(config?.disableTraefik ? [\"--disable=traefik\"] : []),\n\t\t\t\t\t...(config?.disableServiceLB ? [\"--disable=servicelb\"] : []),\n\t\t\t\t].map((arg) =>\n\t\t\t\t\ttypeof arg === \"string\" ? { arg, nodeFilters: [\"all\"] } : { ...arg, nodeFilters: arg.nodeFilters ?? [\"all\"] },\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t};\n\n\tlet resolvedConfig = config?.config ? await config?.config(autoConfig, registry) : autoConfig;\n\tif (typeof resolvedConfig !== \"string\") {\n\t\tresolvedConfig = YAML.stringify(resolvedConfig, null, 2);\n\t}\n\n\treturn { originalConfig: config, autoConfig, resolvedConfig, registry };\n}\n"],"mappings":";;;AAKA,SAAS,qBAAqB;AAI7B,QAAO,YAHW,OAChB,gBAAgB,IAAI,WAAW,EAAE,CAAC,CAClC,QAAQ,KAAK,SAAS,MAAM,KAAK,SAAS,GAAG,CAAC,SA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a,IAAI,eAAe,CAAC,MAAM;GAAE,CAC7G,EACD,EACD;EACD;CAED,IAAI,iBAAiB,QAAQ,SAAS,MAAM,QAAQ,OAAO,YAAY,SAAS,GAAG;AACnF,KAAI,OAAO,mBAAmB,SAC7B,kBAAiB,KAAK,UAAU,gBAAgB,MAAM,EAAE;AAGzD,QAAO;EAAE,gBAAgB;EAAQ;EAAY;EAAgB;EAAU"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/k3d-config/index.ts"],"sourcesContent":["import type { Awaitable } from \"@hamishwhc/cdk8s-monorepo-utils/awaitable\";\nimport { YAML } from \"bun\";\nimport type { RegistryInfo } from \"../get-registry\";\nimport type { K3DSimpleConfigV1Alpha5, NodeFilters } from \"./v1alpha5\";\n\nfunction randomRegistryName() {\n\tconst randomHex = crypto\n\t\t.getRandomValues(new Uint8Array(2))\n\t\t.reduce((str, byte) => str + byte.toString(16).padStart(2, \"0\"), \"\");\n\treturn `registry-${randomHex}.k3d.hamishwhc.com`;\n}\n\nfunction randomRegistryPort() {\n\treturn 10000 + Math.floor(Math.random() * 50000);\n}\n\nexport { K3DSimpleConfigV1Alpha5 };\nexport type K3dSimpleConfig = K3DSimpleConfigV1Alpha5;\n\nexport interface BindMountVolume {\n\thostPath: string;\n\tcontainerPath: string;\n\t/**\n\t * If enabled, the host path will be deleted similarly to `rm -rf` on cluster creation.\n\t * @default false\n\t */\n\tdeleteOnClusterCreate?: boolean;\n\t/**\n\t * Node filters to determine which cluster nodes this volume applies to.\n\t * @example [\"server:0\", \"agent:*\"]\n\t * @default [\"all\"]\n\t */\n\tnodeFilters?: NodeFilters;\n}\n\nexport interface Port {\n\thostPort: number;\n\tcontainerPort: number;\n\t/**\n\t * Node filters to determine which cluster nodes this port mapping applies to.\n\t * Note that the default for port mappings is different to other items, as typically\n\t * port mappings are only needed on the loadbalancer node.\n\t *\n\t * @example [\"server:0\", \"agent:*\"]\n\t * @default [\"loadbalancer\"]\n\t */\n\tnodeFilters?: NodeFilters;\n}\n\nexport interface EnvironmentVariable {\n\tname: string;\n\tvalue: string;\n\t/**\n\t * Node filters to determine which cluster nodes this environment variable applies to.\n\t * @example [\"server:0\", \"agent:*\"]\n\t * @default [\"all\"]\n\t */\n\tnodeFilters?: NodeFilters;\n}\n\nexport interface K3sArg {\n\targ: string;\n\t/**\n\t * Node filters to determine which cluster nodes this k3s arg applies to.\n\t * @example [\"server:0\", \"agent:*\"]\n\t * @default [\"all\"]\n\t */\n\tnodeFilters?: NodeFilters;\n}\n\nexport interface K3dConfig {\n\t/**\n\t * The K3s image to use for the cluster nodes. k3d will automatically pick the latest version for your host architecture if not specified.\n\t *\n\t * You can specify a platform-specific image from the K3s image tags, such as `rancher/k3s:v1.34.1-k3s1-amd64`, to force the k3d nodes to be created as a specific platform.\n\t */\n\timage?: string;\n\n\t/**\n\t * Number of server nodes in the k3d cluster.\n\t * Note that the default of 1 disables etcd and the ability to add additional servers later.\n\t * See https://k3d.io/stable/usage/multiserver/#adding-server-nodes-to-a-running-cluster.\n\t * @default 1\n\t */\n\tservers?: number;\n\t/**\n\t * Number of agent nodes in the k3d cluster.\n\t * @default undefined\n\t */\n\tagents?: number;\n\n\t/**\n\t * Bind mount volumes to add to the k3d cluster on creation.\n\t *\n\t * Useful for inspecting PVCs and enabling code reloading by mounting source code into pods.\n\t *\n\t * @example\n\t * - Inspecting PVCs when using the built-in local-path provisioner:\n\t * ```ts\n\t * {\n\t * hostPath: path.join(YOUR_REPO_DIR, \".k3d\"),\n\t * containerPath: \"/var/lib/rancher/k3s/storage\",\n\t * deleteOnClusterCreate: true,\n\t * }\n\t * ```\n\t * - Mounting source code into pods for code reloading:\n\t * ```ts\n\t * {\n\t * hostPath: YOUR_REPO_DIR,\n\t * containerPath: \"/workspace\",\n\t * }\n\t * ```\n\t * You can then use `hostPath` mounts to mount sub-directories of `/workspace` into your pods as needed.\n\t *\n\t * @default []\n\t */\n\tvolumes?: BindMountVolume[];\n\t/**\n\t * Port mappings to add to the k3d cluster nodes on creation.\n\t */\n\tports?: Port[];\n\t/**\n\t * Environment variables to add to the k3d cluster nodes on creation.\n\t */\n\tenv?: EnvironmentVariable[];\n\n\t/**\n\t * The name of the k3d registry container.\n\t * The default will resolve to localhost, allowing `kbld` (or yourself) to\n\t * `docker push` images to it from your local machine without host file or other configuration changes.\n\t * See https://k3d.io/stable/usage/registries/#secure-registries for more information.\n\t *\n\t * If you want to use a more complicated registry configuration (e.g. using an existing registry, a proxy or mirrors)\n\t * or simply don't want to run a local registry, you can set this to `null`\n\t * and instead use `config` to provide custom k3d registry settings.\n\t *\n\t * Security note: consider setting up your own DNS A wildcard record on your own domain (e.g. `*.k3d.example.com`)\n\t * pointing to 127.0.0.1, to avoid DNS rebinding attacks.\n\t *\n\t * @default \"registry-${random-hex}.k3d.hamishwhc.com\"\n\t */\n\t// TODO: Consider persisting a k3d-managed registry between runs instead of creating a new one per cluster.\n\tregistryName?: string | null;\n\n\t/**\n\t * If enabled, k3d will be configured in a way that is compatible with Cilium networking.\n\t * This involves disabling the default flannel network plugin and network policy engine,\n\t * and pre-configuring some volumes required by Cilium within the k3d docker containers.\n\t * More information can be found in source code comments.\n\t *\n\t * Once the cluster is created, your CDK8s app is still responsible for installing and configuring Cilium itself.\n\t *\n\t * This is not supported on Windows Subsystem for Linux (WSL) at this time and a warning\n\t * will be logged if set to true on WSL.\n\t * The warning can be silenced by using the `isWsl` variable exported from this package\n\t * to conditionally set this value to false on WSL environments.\n\t *\n\t * @default false\n\t */\n\tconfigureCilium?: boolean;\n\n\t/**\n\t * If enabled, Traefik will be disabled in the K3s cluster using the K3s argument `--disable=traefik`.\n\t */\n\tdisableTraefik?: boolean;\n\t/**\n\t * If enabled, ServiceLB will be disabled in the K3s cluster using the K3s argument `--disable=servicelb`.\n\t */\n\tdisableServiceLB?: boolean;\n\t/**\n\t * Additional K3s arguments to pass to each k3d cluster node on creation.\n\t */\n\tk3sExtraArgs?: (string | K3sArg)[];\n\n\t/**\n\t * In the event you want to set other k3d cluster options, you can read/add to/modify/override any and all of the k3d config here.\n\t * This function receives the config generated by `cdk8s-local` and you can modify (or replace) it as needed.\n\t * This is only used during cluster creation.\n\t * I make no guarantees that your custom config will work with `cdk8s-local`, so use this with caution.\n\t * Note that the current config version supported by the types is `k3d.io/v1alpha5`.\n\t *\n\t * Generally, would recommend using only for adding k3d/K3s options not covered by the convenience options available in this package.\n\t */\n\tconfig?: (c: K3DSimpleConfigV1Alpha5, r: RegistryInfo | null) => Awaitable<string | K3dSimpleConfig>;\n}\n\nexport interface K3dConfigResolution {\n\toriginalConfig?: K3dConfig;\n\tautoConfig: K3DSimpleConfigV1Alpha5;\n\tresolvedConfig: string;\n\tregistry: RegistryInfo | null;\n}\n\nexport async function resolveK3dConfig(name: string, config: K3dConfig | undefined): Promise<K3dConfigResolution> {\n\tconst registry =\n\t\tconfig?.registryName !== null\n\t\t\t? {\n\t\t\t\t\tname: config?.registryName || randomRegistryName(),\n\t\t\t\t\tport: randomRegistryPort(),\n\t\t\t\t}\n\t\t\t: null;\n\n\tconst autoConfig: K3DSimpleConfigV1Alpha5 = {\n\t\tapiVersion: \"k3d.io/v1alpha5\",\n\t\tkind: \"Simple\",\n\t\tmetadata: { name },\n\t\timage: config?.image,\n\t\tservers: config?.servers ?? 1,\n\t\tagents: config?.agents ?? undefined,\n\t\tvolumes:\n\t\t\tconfig?.volumes?.map(({ hostPath, containerPath, nodeFilters }) => ({\n\t\t\t\tvolume: `${hostPath}:${containerPath}`,\n\t\t\t\tnodeFilters: nodeFilters ?? [\"all\"],\n\t\t\t})) ?? [],\n\t\tports:\n\t\t\tconfig?.ports?.map(({ hostPort, containerPort, nodeFilters }) => ({\n\t\t\t\tport: `${hostPort}:${containerPort}`,\n\t\t\t\tnodeFilters: nodeFilters ?? [\"loadbalancer\"],\n\t\t\t})) ?? [],\n\t\tregistries: registry\n\t\t\t? {\n\t\t\t\t\tcreate: {\n\t\t\t\t\t\tname: registry.name,\n\t\t\t\t\t\thostPort: `${registry.port}`,\n\t\t\t\t\t\t// enforcePortMatch: true,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tenv: config?.env?.map(({ name, value, nodeFilters }) => ({ envVar: `${name}=${value}`, nodeFilters })) ?? [],\n\t\toptions: {\n\t\t\tk3s: {\n\t\t\t\textraArgs: [\n\t\t\t\t\t...(config?.configureCilium ? [\"--flannel-backend=none\", \"--disable-network-policy\"] : []),\n\t\t\t\t\t...(config?.k3sExtraArgs ?? []),\n\t\t\t\t\t...(config?.disableTraefik ? [\"--disable=traefik\"] : []),\n\t\t\t\t\t...(config?.disableServiceLB ? [\"--disable=servicelb\"] : []),\n\t\t\t\t].map((arg) =>\n\t\t\t\t\ttypeof arg === \"string\" ? { arg, nodeFilters: [\"all\"] } : { ...arg, nodeFilters: arg.nodeFilters ?? [\"all\"] },\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t};\n\n\tlet resolvedConfig = config?.config ? await config?.config(autoConfig, registry) : autoConfig;\n\tif (typeof resolvedConfig !== \"string\") {\n\t\tresolvedConfig = YAML.stringify(resolvedConfig, null, 2);\n\t}\n\n\treturn { originalConfig: config, autoConfig, resolvedConfig, registry };\n}\n"],"mappings":";;;AAKA,SAAS,qBAAqB;AAI7B,QAAO,YAHW,OAChB,gBAAgB,IAAI,WAAW,EAAE,CAAC,CAClC,QAAQ,KAAK,SAAS,MAAM,KAAK,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,EAAE,GAAG,CACxC;;AAG9B,SAAS,qBAAqB;AAC7B,QAAO,MAAQ,KAAK,MAAM,KAAK,QAAQ,GAAG,IAAM;;AAoLjD,eAAsB,iBAAiB,MAAc,QAA6D;CACjH,MAAM,WACL,QAAQ,iBAAiB,OACtB;EACA,MAAM,QAAQ,gBAAgB,oBAAoB;EAClD,MAAM,oBAAoB;EAC1B,GACA;CAEJ,MAAM,aAAsC;EAC3C,YAAY;EACZ,MAAM;EACN,UAAU,EAAE,MAAM;EAClB,OAAO,QAAQ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../src/requirements.ts"],"sourcesContent":["import { logger } from \"@
|
|
1
|
+
{"version":3,"file":"requirements.mjs","names":[],"sources":["../src/requirements.ts"],"sourcesContent":["import { logger } from \"@hamishwhc/cdk8s-monorepo-utils/logger\";\nimport { $ } from \"bun\";\n\nexport const CommonRequirements = {\n\tHELM: { name: \"helm\", url: \"https://helm.sh/docs/intro/install/\" },\n};\n\nexport const DEFAULT_REQUIREMENTS = [\n\t// Local dev.\n\t{ name: \"k3d\", url: \"https://k3d.io/stable/#releases\" },\n\t// Image building.\n\t{ name: \"kbld\", url: \"https://carvel.dev/kbld/\" },\n\t{\n\t\tname: \"docker\",\n\t\turl: \"https://docs.docker.com/desktop/install/mac-install/\",\n\t},\n\t// Deployment.\n\t{\n\t\tname: \"kubectl\",\n\t\turl: \"https://kubernetes.io/docs/tasks/tools/#kubectl\",\n\t},\n\t{ name: \"kapp\", url: \"https://carvel.dev/kapp/\" },\n];\n\nconst isInstalled = async (name: string) => (await $`which ${name}`.throws(false).quiet()).exitCode === 0;\n\nexport interface RequiredProgram {\n\tname: string;\n\turl: string;\n}\n\nexport const checkRequirements = async (requirements: RequiredProgram[]) => {\n\tlet hasPrereqs = true;\n\tfor (const { name, url } of requirements) {\n\t\tif (!(await isInstalled(name))) {\n\t\t\tlogger.error(`Missing ${name}. You can install it from ${url}.`);\n\t\t\thasPrereqs = false;\n\t\t}\n\t}\n\n\tif (!hasPrereqs) {\n\t\tlogger.error(\"Please install the missing programs and try again.\");\n\t\tthrow new Error(\"Missing required programs\");\n\t}\n};\n"],"mappings":";;;;AAOA,MAAa,uBAAuB;CAEnC;EAAE,MAAM;EAAO,KAAK;EAAmC;CAEvD;EAAE,MAAM;EAAQ,KAAK;EAA4B;CACjD;EACC,MAAM;EACN,KAAK;EACL;CAED;EACC,MAAM;EACN,KAAK;EACL;CACD;EAAE,MAAM;EAAQ,KAAK;EAA4B;CACjD;AAED,MAAM,cAAc,OAAO,UAAkB,MAAM,CAAC,SAAS,OAAO,OAAO,MAAM,CAAC,OAAO,EAAE,aAAa;AAOxG,MAAa,oBAAoB,OAAO,iBAAoC;CAC3E,IAAI,aAAa;AACjB,MAAK,MAAM,EAAE,MAAM,SAAS,aAC3B,KAAI,CAAE,MAAM,YAAY,KAAK,EAAG;AAC/B,SAAO,MAAM,WAAW,KAAK,4BAA4B,IAAI,GAAG;AAChE,eAAa;;AAIf,KAAI,CAAC,YAAY;AAChB,SAAO,MAAM,qDAAqD;AAClE,QAAM,IAAI,MAAM,4BAA4B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cdk8s-local",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"scripts": {
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"cmd-ts": "^0.14.3",
|
|
18
18
|
"constructs": "^10.4.3",
|
|
19
19
|
"is-wsl": "^3.1.0",
|
|
20
|
-
"@
|
|
20
|
+
"@hamishwhc/cdk8s-monorepo-utils": "0.0.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"@
|
|
23
|
+
"@hamishwhc/cdk8s-monorepo-eslint-config": "0.0.0",
|
|
24
|
+
"@hamishwhc/cdk8s-monorepo-typescript-config": "0.0.0",
|
|
25
25
|
"@types/bun": "^1.3.8",
|
|
26
26
|
"eslint": "^9.34.0",
|
|
27
27
|
"json-schema-to-typescript": "^15.0.4",
|
package/src/config.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Awaitable } from "@
|
|
2
|
-
import type { CommonContext, CommonStartupContext } from "@
|
|
3
|
-
import type { ArgTypes, Output } from "@
|
|
1
|
+
import type { Awaitable } from "@hamishwhc/cdk8s-monorepo-utils/awaitable";
|
|
2
|
+
import type { CommonContext, CommonStartupContext } from "@hamishwhc/cdk8s-monorepo-utils/cli-contexts";
|
|
3
|
+
import type { ArgTypes, Output } from "@hamishwhc/cdk8s-monorepo-utils/cmd-ts-types";
|
|
4
4
|
import type { App } from "cdk8s";
|
|
5
5
|
import type { DefaultArgs } from "./default-args";
|
|
6
6
|
import type { K3dConfig } from "./k3d-config";
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ArgTypes } from "@
|
|
2
|
-
import { logger } from "@
|
|
3
|
-
import { resolveThunk } from "@
|
|
1
|
+
import type { ArgTypes } from "@hamishwhc/cdk8s-monorepo-utils/cmd-ts-types";
|
|
2
|
+
import { logger } from "@hamishwhc/cdk8s-monorepo-utils/logger";
|
|
3
|
+
import { resolveThunk } from "@hamishwhc/cdk8s-monorepo-utils/thunk";
|
|
4
4
|
import { $ } from "bun";
|
|
5
5
|
import { KbldConfig } from "cdk8s-kbld2";
|
|
6
6
|
import { binary, command, run } from "cmd-ts";
|
package/src/k3d-config/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Awaitable } from "@
|
|
1
|
+
import type { Awaitable } from "@hamishwhc/cdk8s-monorepo-utils/awaitable";
|
|
2
2
|
import { YAML } from "bun";
|
|
3
3
|
import type { RegistryInfo } from "../get-registry";
|
|
4
4
|
import type { K3DSimpleConfigV1Alpha5, NodeFilters } from "./v1alpha5";
|
package/src/requirements.ts
CHANGED
package/tsconfig.json
CHANGED