@intentius/behold 0.4.1 → 0.5.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 +4 -0
- package/demos.json +30 -0
- package/dist/cli.js +143 -39
- package/example-k8s/README.md +120 -0
- package/example-k8s/chant.config.ts +21 -0
- package/example-k8s/ops/k3d-apply.op.ts +18 -0
- package/example-k8s/package-lock.json +2071 -0
- package/example-k8s/package.json +14 -0
- package/example-k8s/scripts/local/local-down.sh +23 -0
- package/example-k8s/scripts/local/local-up.sh +46 -0
- package/example-k8s/src/config.ts +5 -0
- package/example-k8s/src/web.ts +29 -0
- package/example-k8s/tsconfig.json +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "behold-example-k8s",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "A small nginx Deployment+Service on k3d — behold's k3d turnkey demo (#88), the Kubernetes counterpart to Loom-on-Floci.",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "./node_modules/.bin/chant build src --lexicon k8s -o app.yaml"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@intentius/chant": "^0.32.0",
|
|
11
|
+
"@intentius/chant-lexicon-k8s": "^0.32.0",
|
|
12
|
+
"@intentius/chant-lexicon-temporal": "^0.32.0"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Tear down behold's k3d turnkey demo cluster (#88) and restore whatever
|
|
3
|
+
# kubectl context was current before local-up.sh ran. Safe to run even if the
|
|
4
|
+
# cluster is already gone (k3d's delete is then a no-op).
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
cd "$(dirname "$0")"
|
|
7
|
+
|
|
8
|
+
CLUSTER=behold-k3d-demo
|
|
9
|
+
STATE=".prev-context"
|
|
10
|
+
|
|
11
|
+
if command -v k3d >/dev/null 2>&1; then
|
|
12
|
+
k3d cluster delete "$CLUSTER" >/dev/null 2>&1 || true
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
if [ -f "$STATE" ]; then
|
|
16
|
+
prev="$(cat "$STATE")"
|
|
17
|
+
rm -f "$STATE"
|
|
18
|
+
if [ -n "$prev" ] && kubectl config get-contexts "$prev" >/dev/null 2>&1; then
|
|
19
|
+
kubectl config use-context "$prev" >/dev/null 2>&1 || true
|
|
20
|
+
echo "behold k3d demo: restored kubectl context \"$prev\"."
|
|
21
|
+
fi
|
|
22
|
+
fi
|
|
23
|
+
echo "behold k3d demo: cluster \"$CLUSTER\" removed."
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Bring up the local, single-node k3d cluster behold's k3d turnkey demo (#88)
|
|
3
|
+
# deploys to. Docker + k3d only — no cloud account, no credentials. Idempotent:
|
|
4
|
+
# a cluster of this name already up is left alone.
|
|
5
|
+
#
|
|
6
|
+
# Safety: never touches any OTHER kubeconfig context. Whatever context is
|
|
7
|
+
# current before k3d switches it is saved to .prev-context and restored by
|
|
8
|
+
# local-down.sh; the cluster and its context are uniquely named to this demo
|
|
9
|
+
# (behold-k3d-demo / k3d-behold-k3d-demo) so nothing pre-existing is renamed,
|
|
10
|
+
# reused, or deleted.
|
|
11
|
+
set -euo pipefail
|
|
12
|
+
cd "$(dirname "$0")"
|
|
13
|
+
|
|
14
|
+
CLUSTER=behold-k3d-demo
|
|
15
|
+
CONTEXT="k3d-${CLUSTER}"
|
|
16
|
+
STATE=".prev-context"
|
|
17
|
+
|
|
18
|
+
if ! docker info >/dev/null 2>&1; then
|
|
19
|
+
echo "behold k3d demo: Docker is not running — start Docker and re-run this script." >&2
|
|
20
|
+
exit 1
|
|
21
|
+
fi
|
|
22
|
+
if ! command -v k3d >/dev/null 2>&1; then
|
|
23
|
+
echo "behold k3d demo: k3d is not installed — see https://k3d.io/#installation." >&2
|
|
24
|
+
exit 1
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
if k3d cluster list "$CLUSTER" --no-headers 2>/dev/null | grep -q .; then
|
|
28
|
+
echo "behold k3d demo: cluster \"$CLUSTER\" already up — reusing."
|
|
29
|
+
else
|
|
30
|
+
# Save whatever context is current BEFORE k3d switches it, so local-down.sh
|
|
31
|
+
# can restore it. Only written once: a later local-up (already-up cluster,
|
|
32
|
+
# different code path above) must never overwrite an earlier save with our
|
|
33
|
+
# own context.
|
|
34
|
+
if [ ! -f "$STATE" ]; then
|
|
35
|
+
kubectl config current-context > "$STATE" 2>/dev/null || : > "$STATE"
|
|
36
|
+
fi
|
|
37
|
+
echo "behold k3d demo: creating single-node cluster \"$CLUSTER\"…"
|
|
38
|
+
k3d cluster create "$CLUSTER" --servers 1 --agents 0 --wait --timeout 120s
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
current="$(kubectl config current-context 2>/dev/null || true)"
|
|
42
|
+
if [ "$current" != "$CONTEXT" ]; then
|
|
43
|
+
echo "behold k3d demo: expected kubectl context \"$CONTEXT\" to be current after cluster create, got \"$current\" — aborting rather than reading the wrong cluster." >&2
|
|
44
|
+
exit 1
|
|
45
|
+
fi
|
|
46
|
+
echo "behold k3d demo: cluster \"$CLUSTER\" up, kubectl context \"$CONTEXT\" active."
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// The whole "infra": one small web app. `WebApp` is a composite — a typed call
|
|
2
|
+
// that expands to a Deployment, a Service, and a PodDisruptionBudget — deployed
|
|
3
|
+
// via `ops/k3d-apply.op.ts` to a local k3d cluster (scripts/local/local-up.sh),
|
|
4
|
+
// no cloud account. The Deployment's replicas are the runtime tier's example:
|
|
5
|
+
// its Pods aren't declared here, but a live cluster owns them.
|
|
6
|
+
import { WebApp } from "@intentius/chant-lexicon-k8s";
|
|
7
|
+
import { appName, image } from "./config";
|
|
8
|
+
|
|
9
|
+
const web = WebApp({
|
|
10
|
+
name: appName,
|
|
11
|
+
image,
|
|
12
|
+
port: 8080,
|
|
13
|
+
replicas: 2,
|
|
14
|
+
minAvailable: 1,
|
|
15
|
+
cpuRequest: "50m",
|
|
16
|
+
memoryRequest: "64Mi",
|
|
17
|
+
cpuLimit: "200m",
|
|
18
|
+
memoryLimit: "128Mi",
|
|
19
|
+
securityContext: {
|
|
20
|
+
runAsNonRoot: true,
|
|
21
|
+
runAsUser: 101,
|
|
22
|
+
allowPrivilegeEscalation: false,
|
|
23
|
+
capabilities: { drop: ["ALL"] },
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const deployment = web.deployment;
|
|
28
|
+
export const service = web.service;
|
|
29
|
+
export const pdb = web.pdb!;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "compilerOptions": { "target": "ES2022", "module": "ESNext", "moduleResolution": "Bundler", "strict": true, "skipLibCheck": true, "noEmit": true }, "include": ["src/**/*", "ops/**/*", "chant.config.ts"] }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/behold",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "behold — a live control plane on chant. See your whole estate (every substrate in one graph), coloured by drift; act through delegated, gated Ops.",
|
|
6
6
|
"bin": {
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
"dist",
|
|
12
12
|
"web",
|
|
13
13
|
"example-writes",
|
|
14
|
+
"example-k8s",
|
|
15
|
+
"demos.json",
|
|
14
16
|
"AGENTS.md"
|
|
15
17
|
],
|
|
16
18
|
"publishConfig": {
|