alasio 5.1.0 → 7.0.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/dist/cli/src/branches.js +53 -22
- package/dist/cli/src/branches.js.map +1 -1
- package/dist/cli/src/capacity.js +46 -0
- package/dist/cli/src/capacity.js.map +1 -0
- package/dist/cli/src/cluster/docker-engine.js +6 -4
- package/dist/cli/src/cluster/docker-engine.js.map +1 -1
- package/dist/cli/src/cluster/docker.js +49 -10
- package/dist/cli/src/cluster/docker.js.map +1 -1
- package/dist/cli/src/cluster/host.js +45 -19
- package/dist/cli/src/cluster/host.js.map +1 -1
- package/dist/cli/src/cluster/k3s.js +109 -9
- package/dist/cli/src/cluster/k3s.js.map +1 -1
- package/dist/cli/src/cluster/node.js +94 -50
- package/dist/cli/src/cluster/node.js.map +1 -1
- package/dist/cli/src/cluster/tar.js +43 -1
- package/dist/cli/src/cluster/tar.js.map +1 -1
- package/dist/cli/src/commands/branch.js +9 -4
- package/dist/cli/src/commands/branch.js.map +1 -1
- package/dist/cli/src/commands/restore-filer-store.js +247 -0
- package/dist/cli/src/commands/restore-filer-store.js.map +1 -0
- package/dist/cli/src/commands/status.js +141 -12
- package/dist/cli/src/commands/status.js.map +1 -1
- package/dist/cli/src/commands/uninstall.js +1 -1
- package/dist/cli/src/commands/uninstall.js.map +1 -1
- package/dist/cli/src/commands/up.js +42 -4
- package/dist/cli/src/commands/up.js.map +1 -1
- package/dist/cli/src/commands/upgrade.js +22 -6
- package/dist/cli/src/commands/upgrade.js.map +1 -1
- package/dist/cli/src/commands.js +2 -1
- package/dist/cli/src/commands.js.map +1 -1
- package/dist/cli/src/config.js +13 -4
- package/dist/cli/src/config.js.map +1 -1
- package/dist/cli/src/cpu-baseline.js +97 -0
- package/dist/cli/src/cpu-baseline.js.map +1 -0
- package/dist/cli/src/install.js +44 -11
- package/dist/cli/src/install.js.map +1 -1
- package/dist/cli/src/kept-releases.js +59 -0
- package/dist/cli/src/kept-releases.js.map +1 -0
- package/dist/cli/src/kube/api.js +13 -5
- package/dist/cli/src/kube/api.js.map +1 -1
- package/dist/cli/src/kube/apply.js +116 -13
- package/dist/cli/src/kube/apply.js.map +1 -1
- package/dist/cli/src/kube/autoscalers.js +48 -0
- package/dist/cli/src/kube/autoscalers.js.map +1 -0
- package/dist/cli/src/kube/object-store-scale.js +116 -0
- package/dist/cli/src/kube/object-store-scale.js.map +1 -0
- package/dist/cli/src/kube/rollout.js +23 -0
- package/dist/cli/src/kube/rollout.js.map +1 -1
- package/dist/cli/src/manifests/admission.js +416 -0
- package/dist/cli/src/manifests/admission.js.map +1 -0
- package/dist/cli/src/manifests/agent-sandbox.js +6 -3
- package/dist/cli/src/manifests/agent-sandbox.js.map +1 -1
- package/dist/cli/src/manifests/alasio.js +165 -25
- package/dist/cli/src/manifests/alasio.js.map +1 -1
- package/dist/cli/src/manifests/branch.js +2 -1
- package/dist/cli/src/manifests/branch.js.map +1 -1
- package/dist/cli/src/manifests/cloudeventsources.eventing.keda.sh.json +219 -0
- package/dist/cli/src/manifests/clustercloudeventsources.eventing.keda.sh.json +218 -0
- package/dist/cli/src/manifests/clustertriggerauthentications.keda.sh.json +997 -0
- package/dist/cli/src/manifests/collector.js +92 -45
- package/dist/cli/src/manifests/collector.js.map +1 -1
- package/dist/cli/src/manifests/common.js +34 -8
- package/dist/cli/src/manifests/common.js.map +1 -1
- package/dist/cli/src/manifests/config.js +273 -35
- package/dist/cli/src/manifests/config.js.map +1 -1
- package/dist/cli/src/manifests/controllers.js +39 -0
- package/dist/cli/src/manifests/controllers.js.map +1 -0
- package/dist/cli/src/manifests/disruption.js +47 -0
- package/dist/cli/src/manifests/disruption.js.map +1 -0
- package/dist/cli/src/manifests/grafana.js +66 -10
- package/dist/cli/src/manifests/grafana.js.map +1 -1
- package/dist/cli/src/manifests/headroom.js +40 -0
- package/dist/cli/src/manifests/headroom.js.map +1 -0
- package/dist/cli/src/manifests/index.js +20 -6
- package/dist/cli/src/manifests/index.js.map +1 -1
- package/dist/cli/src/manifests/juicefs-csi.js +9 -6
- package/dist/cli/src/manifests/juicefs-csi.js.map +1 -1
- package/dist/cli/src/manifests/keda.js +271 -0
- package/dist/cli/src/manifests/keda.js.map +1 -0
- package/dist/cli/src/manifests/lake.js +13 -5
- package/dist/cli/src/manifests/lake.js.map +1 -1
- package/dist/cli/src/manifests/neon.js +196 -51
- package/dist/cli/src/manifests/neon.js.map +1 -1
- package/dist/cli/src/manifests/network-policies.js +177 -28
- package/dist/cli/src/manifests/network-policies.js.map +1 -1
- package/dist/cli/src/manifests/node-agent.js +107 -0
- package/dist/cli/src/manifests/node-agent.js.map +1 -0
- package/dist/cli/src/manifests/object-store.js +543 -82
- package/dist/cli/src/manifests/object-store.js.map +1 -1
- package/dist/cli/src/manifests/priorities.js +31 -0
- package/dist/cli/src/manifests/priorities.js.map +1 -0
- package/dist/cli/src/manifests/scaledjobs.keda.sh.json +7507 -0
- package/dist/cli/src/manifests/scaledobjects.keda.sh.json +564 -0
- package/dist/cli/src/manifests/scalers.js +24 -0
- package/dist/cli/src/manifests/scalers.js.map +1 -0
- package/dist/cli/src/manifests/sizing.js +40 -0
- package/dist/cli/src/manifests/sizing.js.map +1 -0
- package/dist/cli/src/manifests/triggerauthentications.keda.sh.json +992 -0
- package/dist/cli/src/manifests/valkey.js +63 -35
- package/dist/cli/src/manifests/valkey.js.map +1 -1
- package/dist/cli/src/manifests/verticalpodautoscalercheckpoints.autoscaling.k8s.io.json +250 -0
- package/dist/cli/src/manifests/verticalpodautoscalers.autoscaling.k8s.io.json +837 -0
- package/dist/cli/src/manifests/vpa.js +220 -0
- package/dist/cli/src/manifests/vpa.js.map +1 -0
- package/dist/cli/src/manifests/workspace-storage.js +12 -2
- package/dist/cli/src/manifests/workspace-storage.js.map +1 -1
- package/dist/cli/src/object-store.js +57 -0
- package/dist/cli/src/object-store.js.map +1 -0
- package/dist/cli/src/release.js +6 -6
- package/dist/cli/src/target.js +1 -1
- package/dist/cli/src/target.js.map +1 -1
- package/dist/cluster/node/pins.json +6 -2
- package/dist/neon/control/branches.js +31 -12
- package/dist/neon/control/branches.js.map +1 -1
- package/dist/neon/control/endpoints.js +108 -0
- package/dist/neon/control/endpoints.js.map +1 -0
- package/dist/neon/control/scram.js +13 -1
- package/dist/neon/control/scram.js.map +1 -1
- package/dist/neon/control/secrets.js +52 -8
- package/dist/neon/control/secrets.js.map +1 -1
- package/dist/src/kube/busy-label.js +13 -0
- package/dist/src/kube/busy-label.js.map +1 -0
- package/dist/src/kube/config.js +30 -4
- package/dist/src/kube/config.js.map +1 -1
- package/dist/src/kube/sandbox-shape.js +98 -0
- package/dist/src/kube/sandbox-shape.js.map +1 -0
- package/dist/src/node-agent/names.js +74 -0
- package/dist/src/node-agent/names.js.map +1 -0
- package/dist/src/sandbox/names.js +44 -0
- package/dist/src/sandbox/names.js.map +1 -0
- package/package.json +2 -2
- package/dist/cluster/node/config-v3.toml.tmpl +0 -12
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* neon-control as the control plane of Neon's proxy (its `cplane-v1` backend:
|
|
3
|
+
* proxy/src/control_plane/client/cplane_proxy_v1.rs and messages.rs at Neon's
|
|
4
|
+
* release-9129), what is decided without I/O. Every client of alasio's Neon connects to
|
|
5
|
+
* the proxy, naming the compute it wants by `options=endpoint=<id>` (the compute's id,
|
|
6
|
+
* ./branches.ts's computeId), and the proxy asks:
|
|
7
|
+
*
|
|
8
|
+
* - `GET /get_endpoint_access_control?endpointish&role`: the role's SCRAM verifier, which
|
|
9
|
+
* it authenticates the client against and then the compute with, so the compute must
|
|
10
|
+
* store that verifier to the byte (./scram.ts). Main's roles' are the stack's, from its
|
|
11
|
+
* secrets; a branch's, the verifiers its request gave. Anything else is no endpoint, or
|
|
12
|
+
* no role, and refused.
|
|
13
|
+
* - `GET /wake_compute?endpointish`: the compute's address, once it accepts connections,
|
|
14
|
+
* woken first if it sleeps (./service.ts).
|
|
15
|
+
*
|
|
16
|
+
* A compute sleeps when no client has had a session on it for its `suspendAfter`, which
|
|
17
|
+
* neon-control counts on the compute itself: so a session holding an advisory lock, idle,
|
|
18
|
+
* keeps it awake, as compute_ctl's own activity monitor would not, and so does one opened
|
|
19
|
+
* and closed between two counts, and a wake asked for since, which a connection, or
|
|
20
|
+
* alasio's command line, is about to use.
|
|
21
|
+
*/
|
|
22
|
+
import { COMPUTE_PORT } from "./branches.js";
|
|
23
|
+
/** The annotation of a compute's Deployment saying how many seconds it may be idle before it sleeps (./computes.ts). */
|
|
24
|
+
export const SUSPEND_AFTER = "alasio.dev/suspend-after-seconds";
|
|
25
|
+
/** The query of a proxy's call, at `url`, or null when it names no endpoint. */
|
|
26
|
+
export function proxyQuery(url) {
|
|
27
|
+
const { searchParams } = new URL(url, "http://neon-control");
|
|
28
|
+
const endpoint = searchParams.get("endpointish");
|
|
29
|
+
return endpoint ? { endpoint, role: searchParams.get("role") } : null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The verifier `role` authenticates with on a branch's compute, given its `credentials`:
|
|
33
|
+
* of main's, which has none of its own, `mainVerifiers`' (the stack's); of any other, its
|
|
34
|
+
* own; null for a role neither has, as neon-control's own role, which no client connects
|
|
35
|
+
* as.
|
|
36
|
+
*/
|
|
37
|
+
export function roleSecret(credentials, role, mainVerifiers) {
|
|
38
|
+
const verifiers = credentials?.verifiers ?? mainVerifiers;
|
|
39
|
+
return Object.hasOwn(verifiers, role) ? verifiers[role] ?? null : null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Neon's error, as the proxy reads one (ControlPlaneErrorMessage): `reason` decides
|
|
43
|
+
* whether it asks again, ENDPOINT_IDLE among those it does, after the given delay.
|
|
44
|
+
*/
|
|
45
|
+
export function controlPlaneError(reason, message, retryDelayMs = null) {
|
|
46
|
+
return {
|
|
47
|
+
error: message,
|
|
48
|
+
status: {
|
|
49
|
+
code: reason,
|
|
50
|
+
message,
|
|
51
|
+
details: {
|
|
52
|
+
error_info: { reason },
|
|
53
|
+
retry_info: retryDelayMs === null ? null : { retry_delay_ms: retryDelayMs },
|
|
54
|
+
user_facing_message: { message },
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Where a compute is, as the proxy connects to it: its Service in `namespace`, which takes connections before the pod is ready. */
|
|
60
|
+
export const computeAddress = (service, namespace) => `${service}.${namespace}.svc.cluster.local:${COMPUTE_PORT}`;
|
|
61
|
+
/** What `wake_compute` answers: the compute of the branch `branch`'s address, and labels for the proxy's metrics. */
|
|
62
|
+
export function woken(address, branch, endpoint, cold) {
|
|
63
|
+
return {
|
|
64
|
+
address,
|
|
65
|
+
aux: { endpoint_id: endpoint, project_id: "alasio", branch_id: branch, compute_id: endpoint, cold_start_info: cold ? "pool_miss" : "warm" },
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A compute's idleness, given what it was (none before the first count), its `use`
|
|
70
|
+
* counted now, and the time: used while a session is open, or one was established, or a
|
|
71
|
+
* wake asked for, since the last count; idle from the first count that finds none of
|
|
72
|
+
* them.
|
|
73
|
+
*/
|
|
74
|
+
export function idleness(previous, use, now) {
|
|
75
|
+
const used = use.sessions > 0 || (previous !== undefined && (use.established !== previous.established || use.wokenAt !== previous.wokenAt));
|
|
76
|
+
return { since: used ? null : previous?.since ?? now, established: use.established, wokenAt: use.wokenAt };
|
|
77
|
+
}
|
|
78
|
+
/** Whether a compute idle as `idle` says has been idle for `suspendAfterMs` by `now`. */
|
|
79
|
+
export const suspendDue = ({ since }, now, suspendAfterMs) => since !== null && now - since >= suspendAfterMs;
|
|
80
|
+
/**
|
|
81
|
+
* Wakes a compute, as `steps` read it and act: records the wake asked for, and scales a
|
|
82
|
+
* compute that sleeps to one under its lock, once the pod put to sleep is gone, read
|
|
83
|
+
* again under it, as a sleep may have ended meanwhile; then waits until it takes
|
|
84
|
+
* connections. One found running needs no lock, but a sleep may then have scaled it
|
|
85
|
+
* down: one that counted it again before the wake was recorded, its scale to none
|
|
86
|
+
* landing after the compute was read. So while it takes none, the compute is read again,
|
|
87
|
+
* and one found asleep woken likewise. Whether it slept.
|
|
88
|
+
*/
|
|
89
|
+
export async function wakeCompute(steps) {
|
|
90
|
+
const first = await steps.deployment();
|
|
91
|
+
await steps.asked();
|
|
92
|
+
const scaled = () => steps.locked(async () => {
|
|
93
|
+
const now = await steps.deployment();
|
|
94
|
+
if (now.replicas > 0)
|
|
95
|
+
return false;
|
|
96
|
+
await steps.untilGone(now);
|
|
97
|
+
await steps.scaleUp();
|
|
98
|
+
return true;
|
|
99
|
+
});
|
|
100
|
+
let slept = first.replicas === 0 && await scaled();
|
|
101
|
+
while (!(await steps.accepts())) {
|
|
102
|
+
if ((await steps.deployment()).replicas === 0)
|
|
103
|
+
slept = (await scaled()) || slept;
|
|
104
|
+
await steps.pause();
|
|
105
|
+
}
|
|
106
|
+
return slept;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=endpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoints.js","sourceRoot":"","sources":["../../../../neon/control/endpoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,YAAY,EAA2B,MAAM,eAAe,CAAC;AAEtE,wHAAwH;AACxH,MAAM,CAAC,MAAM,aAAa,GAAG,kCAAkC,CAAC;AAQhE,gFAAgF;AAChF,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACjD,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CA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AI,MAAM,MAAM,EAAE,CAAC;IACnD,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QAChC,IAAI,CAAC,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,KAAK,CAAC;YAAE,KAAK,GAAG,CAAC,MAAM,MAAM,EAAE,CAAC,IAAI,KAAK,CAAC;QACjF,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A Postgres SCRAM-SHA-256 password verifier (RFC 5802, 7677), in the form
|
|
3
3
|
* Postgres stores and compute_ctl passes through as a role's
|
|
4
|
-
* encrypted_password: the password itself never reaches the compute's spec.
|
|
4
|
+
* encrypted_password: the password itself never reaches the compute's spec. Each is
|
|
5
|
+
* salted at random, as Postgres salts one, and made once: whoever sets a role's
|
|
6
|
+
* password (a compute's spec, alasio) and whoever answers for it (neon-control, to
|
|
7
|
+
* Neon's proxy, which authenticates a client with the keys of the verifier it is
|
|
8
|
+
* answered) are given the one verifier, which the compute must store to the byte.
|
|
5
9
|
*/
|
|
6
10
|
import { createHash, createHmac, pbkdf2Sync, randomBytes } from "node:crypto";
|
|
7
11
|
const ITERATIONS = 4096;
|
|
12
|
+
/**
|
|
13
|
+
* A verifier as Postgres stores one: its iterations, its salt, and the 32-byte StoredKey
|
|
14
|
+
* and ServerKey, each in base64. Nothing else, so one checked to be one may be written
|
|
15
|
+
* into a statement that sets a role's password.
|
|
16
|
+
*/
|
|
17
|
+
const VERIFIER = /^SCRAM-SHA-256\$[1-9][0-9]*:[A-Za-z0-9+/]+={0,2}\$[A-Za-z0-9+/]{43}=:[A-Za-z0-9+/]{43}=$/u;
|
|
18
|
+
/** Whether `text` is a SCRAM-SHA-256 verifier, in the form scramVerifier makes and Postgres stores. */
|
|
19
|
+
export const isScramVerifier = (text) => VERIFIER.test(text);
|
|
8
20
|
export function scramVerifier(password, salt = randomBytes(16)) {
|
|
9
21
|
const salted = pbkdf2Sync(Buffer.from(password, "utf8"), salt, ITERATIONS, 32, "sha256");
|
|
10
22
|
const clientKey = createHmac("sha256", salted).update("Client Key").digest();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scram.js","sourceRoot":"","sources":["../../../../neon/control/scram.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"scram.js","sourceRoot":"","sources":["../../../../neon/control/scram.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE9E,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB;;;;GAIG;AACH,MAAM,QAAQ,GAAG,2FAA2F,CAAC;AAE7G,uGAAuG;AACvG,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAE9E,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,IAAI,GAAW,WAAW,CAAC,EAAE,CAAC;IAC5E,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;IACzF,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE,CAAC;IAC7E,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,CAAC;IAClE,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE,CAAC;IAC7E,OAAO,iBAAiB,UAAU,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;AAClI,CAAC"}
|
|
@@ -4,9 +4,21 @@
|
|
|
4
4
|
* one, never rotated.
|
|
5
5
|
*/
|
|
6
6
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
7
|
+
import { scramVerifier } from "./scram.js";
|
|
7
8
|
export const PAGESERVER_ID = 1;
|
|
8
9
|
export const DATABASE = "alasio";
|
|
10
|
+
/** The roles of alasio's database: alasio's own, the one its spec gives every compute. */
|
|
9
11
|
export const ROLE = "alasio";
|
|
12
|
+
/** The analytics lake's (src/neon/lake.ts), which alasio makes. */
|
|
13
|
+
export const LAKE_ROLE = "lake";
|
|
14
|
+
/** The one the lake's query endpoint reads it as (src/neon/lake.ts), which alasio makes. */
|
|
15
|
+
export const LAKE_READER_ROLE = "lake_reader";
|
|
16
|
+
/** Grafana's (src/neon/grafana.ts), which alasio makes. */
|
|
17
|
+
export const GRAFANA_ROLE = "grafana";
|
|
18
|
+
/** neon-control's own (./computes.ts), which every compute's spec gives it, and no client connects as. */
|
|
19
|
+
export const MONITOR_ROLE = "neon_control";
|
|
20
|
+
/** The roles main's clients connect as, whose verifiers the stack keeps. */
|
|
21
|
+
export const CLIENT_ROLES = [ROLE, LAKE_ROLE, LAKE_READER_ROLE, GRAFANA_ROLE];
|
|
10
22
|
function hexId() {
|
|
11
23
|
return randomUUID().replaceAll("-", "");
|
|
12
24
|
}
|
|
@@ -30,6 +42,13 @@ export function completeSecrets(existing = {}) {
|
|
|
30
42
|
};
|
|
31
43
|
// A secret already held keeps its place; one made is added after them, in this order.
|
|
32
44
|
const s3 = kept(stored.s3, () => ({}));
|
|
45
|
+
const verifiers = kept(stored.verifiers, () => ({}));
|
|
46
|
+
const passwords = {
|
|
47
|
+
alasioPassword: kept(stored.alasioPassword, () => secret()),
|
|
48
|
+
lakePassword: kept(stored.lakePassword, () => secret()),
|
|
49
|
+
lakeReaderPassword: kept(stored.lakeReaderPassword, () => secret()),
|
|
50
|
+
grafanaPassword: kept(stored.grafanaPassword, () => secret()),
|
|
51
|
+
};
|
|
33
52
|
const secrets = {
|
|
34
53
|
...stored,
|
|
35
54
|
tenantId: kept(stored.tenantId, () => hexId()),
|
|
@@ -38,21 +57,36 @@ export function completeSecrets(existing = {}) {
|
|
|
38
57
|
...s3,
|
|
39
58
|
neon: kept(s3.neon, () => ({ accessKey: `neon${hexId().slice(0, 12)}`, secretKey: secret() })),
|
|
40
59
|
admin: kept(s3.admin, () => ({ accessKey: `admin${hexId().slice(0, 12)}`, secretKey: secret() })),
|
|
60
|
+
backups: kept(s3.backups, () => ({ accessKey: `backups${hexId().slice(0, 12)}`, secretKey: secret() })),
|
|
41
61
|
lake: kept(s3.lake, () => ({ accessKey: `lake${hexId().slice(0, 12)}`, secretKey: secret() })),
|
|
42
62
|
lakeReader: kept(s3.lakeReader, () => ({ accessKey: `lakereader${hexId().slice(0, 12)}`, secretKey: secret() })),
|
|
43
63
|
workspaces: kept(s3.workspaces, () => ({ accessKey: `workspaces${hexId().slice(0, 12)}`, secretKey: secret() })),
|
|
64
|
+
snapshots: kept(s3.snapshots, () => ({ accessKey: `snapshots${hexId().slice(0, 12)}`, secretKey: secret() })),
|
|
44
65
|
},
|
|
45
66
|
controllerDbPassword: kept(stored.controllerDbPassword, () => secret()),
|
|
46
|
-
alasioPassword:
|
|
47
|
-
lakePassword:
|
|
67
|
+
alasioPassword: passwords.alasioPassword,
|
|
68
|
+
lakePassword: passwords.lakePassword,
|
|
48
69
|
computeControlToken: kept(stored.computeControlToken, () => secret()),
|
|
49
70
|
valkeyPassword: kept(stored.valkeyPassword, () => secret()),
|
|
50
|
-
lakeReaderPassword:
|
|
71
|
+
lakeReaderPassword: passwords.lakeReaderPassword,
|
|
51
72
|
lakeQueryToken: kept(stored.lakeQueryToken, () => secret()),
|
|
52
|
-
grafanaPassword:
|
|
73
|
+
grafanaPassword: passwords.grafanaPassword,
|
|
53
74
|
grafanaAdminPassword: kept(stored.grafanaAdminPassword, () => secret()),
|
|
54
75
|
grafanaSecretKey: kept(stored.grafanaSecretKey, () => secret()),
|
|
55
76
|
branchForkKey: kept(stored.branchForkKey, () => secret()),
|
|
77
|
+
filerStoreFilerPassword: kept(stored.filerStoreFilerPassword, () => secret()),
|
|
78
|
+
filerStoreCollectorPassword: kept(stored.filerStoreCollectorPassword, () => secret()),
|
|
79
|
+
filerStoreBackupPassword: kept(stored.filerStoreBackupPassword, () => secret()),
|
|
80
|
+
monitorKey: kept(stored.monitorKey, () => secret()),
|
|
81
|
+
// Each of its password above, whether that was kept or made now.
|
|
82
|
+
verifiers: {
|
|
83
|
+
...verifiers,
|
|
84
|
+
[ROLE]: kept(verifiers[ROLE], () => scramVerifier(passwords.alasioPassword)),
|
|
85
|
+
[LAKE_ROLE]: kept(verifiers[LAKE_ROLE], () => scramVerifier(passwords.lakePassword)),
|
|
86
|
+
[LAKE_READER_ROLE]: kept(verifiers[LAKE_READER_ROLE], () => scramVerifier(passwords.lakeReaderPassword)),
|
|
87
|
+
[GRAFANA_ROLE]: kept(verifiers[GRAFANA_ROLE], () => scramVerifier(passwords.grafanaPassword)),
|
|
88
|
+
},
|
|
89
|
+
nodeAgentToken: kept(stored.nodeAgentToken, () => secret()),
|
|
56
90
|
};
|
|
57
91
|
return { secrets, changed };
|
|
58
92
|
}
|
|
@@ -64,22 +98,32 @@ export function remoteStorage(prefix, { endpoint, bucket, region = "us-east-1" }
|
|
|
64
98
|
return `{ endpoint="${endpoint}", bucket_name="${bucket}", bucket_region="${region}", prefix_in_bucket="${prefix}" }`;
|
|
65
99
|
}
|
|
66
100
|
/**
|
|
67
|
-
* SeaweedFS's S3 identities: Neon, the lake
|
|
68
|
-
* on their own bucket of `buckets`; the
|
|
69
|
-
*
|
|
101
|
+
* SeaweedFS's S3 identities: Neon, the lake, workspace storage when it is on and the
|
|
102
|
+
* snapshots' when sandboxes are snapshotted, each on their own bucket of `buckets`; the
|
|
103
|
+
* lake's reader, which may only read the lake's; the backups', which writes the backups'
|
|
104
|
+
* bucket and reads the workspaces' metadata it backs up; and an admin of Neon's bucket
|
|
105
|
+
* alone, which gives it its lifecycle rules. The snapshots' identity is its bucket's admin,
|
|
106
|
+
* giving it its rules itself: what may write that bucket writes the images the node agents
|
|
107
|
+
* restore as root, so nothing else may.
|
|
70
108
|
*/
|
|
71
109
|
export function s3Identities(secrets, buckets) {
|
|
72
110
|
const on = (name) => [`Read:${name}`, `List:${name}`, `Tagging:${name}`, `Write:${name}`];
|
|
73
111
|
return {
|
|
74
112
|
identities: [
|
|
75
113
|
{ name: "neon", credentials: [secrets.s3.neon], actions: on(buckets.neon) },
|
|
76
|
-
{ name: "admin", credentials: [secrets.s3.admin], actions: [
|
|
114
|
+
{ name: "admin", credentials: [secrets.s3.admin], actions: [`Admin:${buckets.neon}`] },
|
|
115
|
+
{
|
|
116
|
+
name: "backups",
|
|
117
|
+
credentials: [secrets.s3.backups],
|
|
118
|
+
actions: [...on(buckets.backups), ...(buckets.workspaces === null ? [] : [`Read:${buckets.workspaces}`, `List:${buckets.workspaces}`])],
|
|
119
|
+
},
|
|
77
120
|
// Branch environments' lakes are given it too: a branch's lake reads main's files where they are (DuckLake keeps
|
|
78
121
|
// every file's path relative to one data path) and writes beside them, and SeaweedFS's Write, which writing
|
|
79
122
|
// needs, deletes as well, so it cannot be narrowed to a branch's own files (cli/src/branches.ts).
|
|
80
123
|
{ name: "lake", credentials: [secrets.s3.lake], actions: on(buckets.lake) },
|
|
81
124
|
{ name: "lakeReader", credentials: [secrets.s3.lakeReader], actions: [`Read:${buckets.lake}`, `List:${buckets.lake}`] },
|
|
82
125
|
...(buckets.workspaces === null ? [] : [{ name: "workspaces", credentials: [secrets.s3.workspaces], actions: on(buckets.workspaces) }]),
|
|
126
|
+
...(buckets.snapshots === null ? [] : [{ name: "snapshots", credentials: [secrets.s3.snapshots], actions: [...on(buckets.snapshots), `Admin:${buckets.snapshots}`] }]),
|
|
83
127
|
],
|
|
84
128
|
};
|
|
85
129
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../../../neon/control/secrets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAC/B,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC;AACjC,MAAM,CAAC,MAAM,IAAI,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../../../neon/control/secrets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAC/B,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC;AACjC,0FAA0F;AAC1F,MAAM,CAAC,MAAM,IAAI,GAAG,QAAQ,CAAC;AAC7B,mEAAmE;AACnE,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC;AAChC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAC9C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;AACtC,0GAA0G;AAC1G,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,CAAU,CAAC;AAmGvF,SAAS,KAAK;IACZ,OAAO,U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kBAAkB,IAAI,CAAC,aAAa,CAAC,EAAE;QACvC,kBAAkB,IAAI,CAAC,cAAc,CAAC,EAAE;QACxC,oBAAoB,IAAI,CAAC,cAAc,CAAC,EAAE;QAC1C,qBAAqB,IAAI,CAAC,eAAe,CAAC,EAAE;QAC5C,qBAAqB,IAAI,CAAC,GAAG,aAAa,aAAa,CAAC,EAAE;QAC1D,2BAA2B,IAAI,CAAC,KAAK,CAAC,EAAE;QACxC,0BAA0B;QAC1B,wBAAwB;QACxB,mCAAmC,IAAI,CAAC,aAAa,CAAC,EAAE;QACxD,kBAAkB,OAAO,EAAE;QAC3B,6CAA6C,cAAc,CAAC,WAAW,qBAAqB,cAAc,CAAC,aAAa,IAAI;QAC5H,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,8GAA8G;AAC9G,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,oBAAoB,EAAE,eAAe,EAAE,CAAC,GAAG,IAAI,CAAC;AAC9H,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What marks a pod busy, running a turn: the label alasio sets on it while it does
|
|
3
|
+
* (./busy.ts), which its installation's PodDisruptionBudgets select
|
|
4
|
+
* (cli/src/manifests/disruption.ts), and the annotations that go with it.
|
|
5
|
+
*/
|
|
6
|
+
/** The label of a pod running a turn, "true" while it does. */
|
|
7
|
+
export const BUSY_LABEL = "alasio.dev/busy";
|
|
8
|
+
/** What cluster-autoscaler and Karpenter read as "do not remove this pod's node now". */
|
|
9
|
+
export const BUSY_ANNOTATIONS = {
|
|
10
|
+
"cluster-autoscaler.kubernetes.io/safe-to-evict": "false",
|
|
11
|
+
"karpenter.sh/do-not-disrupt": "true",
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=busy-label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"busy-label.js","sourceRoot":"","sources":["../../../../src/kube/busy-label.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+DAA+D;AAC/D,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAE5C,yFAAyF;AACzF,MAAM,CAAC,MAAM,gBAAgB,GAAqC;IAChE,gDAAgD,EAAE,OAAO;IACzD,6BAA6B,EAAE,MAAM;CACtC,CAAC"}
|
package/dist/src/kube/config.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* {
|
|
7
7
|
* "sessions": { "namespace", "port", "workspaceDir", "egressGate", "fullModeNameservers",
|
|
8
|
-
* "mountPodNamespace", "podTemplate", "volumeClaimTemplates", "clone"
|
|
8
|
+
* "mountPodNamespace", "podTemplate", "volumeClaimTemplates", "clone",
|
|
9
|
+
* "snapshots" },
|
|
9
10
|
* "host": { "namespace", "port", "stateRoot", "podTemplate" }
|
|
10
11
|
* }
|
|
11
12
|
*
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
*/
|
|
16
17
|
import { readFileSync } from "node:fs";
|
|
17
18
|
import { Config, Effect, Predicate, Result, Schema, SchemaGetter, SchemaIssue } from "effect";
|
|
19
|
+
import { CLAIM_TEMPLATE_MAX } from "../sandbox/names.js";
|
|
18
20
|
/** The deployment's templates could not be read, or are not what alasio needs; the message says which. */
|
|
19
21
|
export class KubeTemplatesError extends Schema.TaggedError()("KubeTemplatesError", {
|
|
20
22
|
message: Schema.String,
|
|
@@ -46,9 +48,26 @@ const VolumeClaimTemplates = said(Schema.Array(Schema.declare((value) => Predica
|
|
|
46
48
|
* installation gives, which the API server checks as each is made.
|
|
47
49
|
*/
|
|
48
50
|
const Clone = said(Schema.Struct({
|
|
49
|
-
|
|
51
|
+
// Short enough that each claim of it, named `<template>-<volume id>`, is a DNS label.
|
|
52
|
+
claimTemplate: said(Schema.String.check(Schema.isPattern(new RegExp(`^[a-z0-9]([-a-z0-9]{0,${CLAIM_TEMPLATE_MAX - 2}}[a-z0-9])?$`, "u"))), `must be a claim template's name, a DNS label of at most ${CLAIM_TEMPLATE_MAX} characters`),
|
|
50
53
|
job: said(Schema.declare((value) => Predicate.isObject(value)), "must be an object"),
|
|
51
54
|
}), "must be an object");
|
|
55
|
+
/** The variables a clone's Job is given, after its own, in this order (src/sandbox/index.ts). */
|
|
56
|
+
export const CLONE_VARIABLES = ["SOURCE_NAMESPACE", "SOURCE_CLAIM", "DESTINATION_NAMESPACE", "DESTINATION_CLAIM"];
|
|
57
|
+
const Count = said(Schema.Number.check(Schema.isInt({ message: "must be a whole number" }), Schema.isGreaterThan(0, { message: "must be positive" })), "must be a positive whole number");
|
|
58
|
+
/**
|
|
59
|
+
* Session sandboxes' whole-sandbox snapshots (../sandbox/snapshots.ts): how long a session
|
|
60
|
+
* runs no exec and no turn before its Sandbox is snapshotted and released; the gVisor
|
|
61
|
+
* releases a snapshot is restored under, each by its RuntimeClass, the current one first;
|
|
62
|
+
* and where the node agents that take and prepare the snapshots are, by their pods'
|
|
63
|
+
* namespace and labels, and the port they serve on.
|
|
64
|
+
*/
|
|
65
|
+
const Snapshots = said(Schema.Struct({
|
|
66
|
+
releaseAfterSeconds: Count,
|
|
67
|
+
releases: said(Schema.Array(Schema.Struct({ release: said(Schema.NonEmptyString, "must be a release"), runtimeClassName: said(Schema.NonEmptyString, "must be a RuntimeClass's name") }))
|
|
68
|
+
.check(Schema.isMinLength(1, { message: "must name a release" })), "must be a list of releases"),
|
|
69
|
+
agents: said(Schema.Struct({ namespace: Namespace, selector: said(Schema.NonEmptyString, "must be a label selector"), port: Port }), "must be an object"),
|
|
70
|
+
}), "must be an object");
|
|
52
71
|
/** Whether `podTemplate`, as the installation gives it, runs a container named `bayma`. */
|
|
53
72
|
function runsBayma(podTemplate) {
|
|
54
73
|
const containers = Predicate.hasProperty(podTemplate, "spec") && Predicate.hasProperty(podTemplate.spec, "containers")
|
|
@@ -77,6 +96,8 @@ const SessionsProfile = said(Schema.Struct({
|
|
|
77
96
|
volumeClaimTemplates: Schema.optional(VolumeClaimTemplates),
|
|
78
97
|
/** How a session's volume is cloned, where its storage can; none where it cannot, and sessions are not forked. */
|
|
79
98
|
clone: Schema.optional(Schema.NullOr(Clone)),
|
|
99
|
+
/** How sessions' Sandboxes are snapshotted as they are released, where they are; none where they are not. */
|
|
100
|
+
snapshots: Schema.optional(Schema.NullOr(Snapshots)),
|
|
80
101
|
}), "must be an object").check(Schema.makeFilter((profile) => (runsBayma(profile.podTemplate) ? undefined : baymaIssue)));
|
|
81
102
|
/** The template of folder workspaces' bayma (hostProfile in cli/src/manifests/alasio.ts). */
|
|
82
103
|
const HostProfile = said(Schema.Struct({
|
|
@@ -86,8 +107,13 @@ const HostProfile = said(Schema.Struct({
|
|
|
86
107
|
}), "must be an object").check(Schema.makeFilter((profile) => (runsBayma(profile.podTemplate) ? undefined : baymaIssue)));
|
|
87
108
|
/** A profile the deployment may leave out, which is then null. */
|
|
88
109
|
const optionalProfile = (schema) => said(Schema.NullOr(schema), "must be an object").pipe(Schema.withDecodingDefaultKey(Effect.succeed(null)));
|
|
89
|
-
/**
|
|
90
|
-
|
|
110
|
+
/**
|
|
111
|
+
* ALASIO_KUBE_TEMPLATES, checked: a profile the deployment does not render is null; and
|
|
112
|
+
* the sessions' profile before the current one, as `alasio up` carries it forward until
|
|
113
|
+
* their template changes again, which sessions' snapshots may restore onto
|
|
114
|
+
* (../sandbox/snapshots.ts), null where there is none.
|
|
115
|
+
*/
|
|
116
|
+
const KubeTemplates = said(Schema.Struct({ sessions: optionalProfile(SessionsProfile), previousSessions: optionalProfile(SessionsProfile), host: optionalProfile(HostProfile) }), "must be an object");
|
|
91
117
|
const formatIssue = SchemaIssue.makeFormatterStandardSchemaV1();
|
|
92
118
|
/** The first thing wrong with the templates, as alasio says it: the key's path, then what it must be. */
|
|
93
119
|
function describe(issue) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/kube/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/kube/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,0GAA0G;AAC1G,MAAM,OAAO,kBAAmB,SAAQ,MAAM,CAAC,WAAW,EAAsB,CAAC,oBAAoB,EAAE;IACrG,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CAAC;CAAG;AAEL,MAAM,SAAS,GAAG,uCAAuC,CAAC;AAE1D;;;GAGG;AACH,MAAM,IAAI,GAAG,CAAuB,MAAS,EAAE,OAAe,EAAgB,EAAE,CAC9E,MAAM,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,WAAW,CAAC,EAAE,iBAAiB,EAAE,OAAO,EAAE,CAAC,CAAC;AAE3E,8EAA8E;AAC9E,MAAM,SAAS,GAAG,IAAI,CACpB,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;KAChJ,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,0BAA0B,EAAE,CAAC,CAAC,EAC9E,0B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.ts): bayma's token, mounted from a Secret of the Sandbox's, and passed
|
|
4
|
+
* as a file; the labels that name the Sandbox and say what it is; and, of a session's,
|
|
5
|
+
* its internet's gate and DNS (../sandbox/index.ts), and of a folder's bayma, its state
|
|
6
|
+
* directory (../mcp/bayma.ts). In one place, with no dependency, so the admission policy
|
|
7
|
+
* that holds alasio to its templates (cli/src/manifests/admission.ts) knows it as they do.
|
|
8
|
+
*/
|
|
9
|
+
/** The container in every Sandbox's pod that runs bayma. */
|
|
10
|
+
export const BAYMA_CONTAINER = "bayma";
|
|
11
|
+
/** Where a Sandbox's token Secret is mounted in its bayma container, its key, and its volume. */
|
|
12
|
+
export const TOKEN_DIR = "/run/alasio/bayma";
|
|
13
|
+
export const TOKEN_KEY = "token";
|
|
14
|
+
export const TOKEN_VOLUME = "alasio-bayma-token";
|
|
15
|
+
/** The token volume's files' mode: readable by the pod's group, which is how a non-root bayma reads it. */
|
|
16
|
+
export const TOKEN_MODE = 0o440;
|
|
17
|
+
/** The file bayma reads its token from, which a restored Sandbox's new token replaces. */
|
|
18
|
+
export const TOKEN_FILE = `${TOKEN_DIR}/${TOKEN_KEY}`;
|
|
19
|
+
/** The arguments bayma is given after its template's: where its token is. */
|
|
20
|
+
export const TOKEN_FILE_ARGS = ["--token-file", TOKEN_FILE];
|
|
21
|
+
/** The arguments a session's bayma is given after those when it exports telemetry: the token it exports with, read from the same file for each export. */
|
|
22
|
+
export const TELEMETRY_TOKEN_FILE_ARGS = ["--telemetry-token-file", TOKEN_FILE];
|
|
23
|
+
/** The name of a Sandbox's token Secret. */
|
|
24
|
+
export function tokenSecretName(name) {
|
|
25
|
+
return `${name}-bayma-token`;
|
|
26
|
+
}
|
|
27
|
+
/** The label every object alasio makes carries, and the one that names its Sandbox. */
|
|
28
|
+
export const MANAGED_BY = { "app.kubernetes.io/managed-by": "alasio" };
|
|
29
|
+
export const SANDBOX_LABEL = "alasio.dev/sandbox";
|
|
30
|
+
/** What a Sandbox's pod is to alasio: a session's, or a folder's bayma's. */
|
|
31
|
+
export const WORKLOAD_LABEL = "alasio.dev/workload";
|
|
32
|
+
/** A session's internet, `none` or `full`, which its NetworkPolicies follow. */
|
|
33
|
+
export const NET_MODE_LABEL = "alasio.dev/net-mode";
|
|
34
|
+
/** The harness a folder's bayma serves, as a path segment. */
|
|
35
|
+
export const HARNESS_LABEL = "alasio.dev/harness";
|
|
36
|
+
/** The resolvers a session with internet uses unless its template names others. */
|
|
37
|
+
export const DEFAULT_FULL_MODE_NAMESERVERS = ["1.1.1.1", "8.8.8.8"];
|
|
38
|
+
/** The argument a folder's bayma is given its state directory by, under its template's state root. */
|
|
39
|
+
export const STATE_DIR_ARG = "--state-dir";
|
|
40
|
+
/** A path segment from `value`: never empty, nor starting with a dot. */
|
|
41
|
+
export function sanitizePathToken(value) {
|
|
42
|
+
return String(value).replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^[-.]+|-+$/g, "") || "default";
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* What a session's pod template carries of its whole-sandbox snapshots
|
|
46
|
+
* (../sandbox/snapshots.ts): the hash of the template it was made from, which its
|
|
47
|
+
* snapshots record; the CPU features its sandbox is held to; and, of a pod restored from
|
|
48
|
+
* a snapshot, the image it is restored from, on its node under the snapshot cache, left
|
|
49
|
+
* paused until its node's agent resumes it, which its readiness gate waits for.
|
|
50
|
+
*/
|
|
51
|
+
export const SESSION_TEMPLATE_ANNOTATION = "alasio.dev/session-template";
|
|
52
|
+
/** gVisor's annotation that holds a sandbox to the CPU features it names, of those its node has. */
|
|
53
|
+
export const CPU_FEATURES_ANNOTATION = "dev.gvisor.internal.cpufeatures";
|
|
54
|
+
/** The annotation alasio's fork of gVisor restores a pod's sandbox from, naming the image on the node. */
|
|
55
|
+
export const RESTORE_ANNOTATION = "dev.gvisor.internal.restore.host-image-path";
|
|
56
|
+
/** The fork's annotation that leaves a restored sandbox paused, running nothing, until it is resumed. */
|
|
57
|
+
export const RESTORE_PAUSED_ANNOTATION = "dev.gvisor.internal.restore.paused";
|
|
58
|
+
/** The condition of a restored pod's readiness gate, which alasio sets once its sandbox is resumed. */
|
|
59
|
+
export const RESUMED_CONDITION = "alasio.dev/resumed";
|
|
60
|
+
/**
|
|
61
|
+
* The annotation of a suspended Sandbox naming the snapshot its pod was saved into, which
|
|
62
|
+
* alone it may be restored from: set as it is suspended, removed as it is next resumed,
|
|
63
|
+
* from that snapshot or not, so a snapshot outlives no resume of its Sandbox's.
|
|
64
|
+
*/
|
|
65
|
+
export const SNAPSHOT_ANNOTATION = "alasio.dev/snapshot";
|
|
66
|
+
/**
|
|
67
|
+
* The annotation naming the gVisor release that took the snapshot SNAPSHOT_ANNOTATION
|
|
68
|
+
* names, beside it, the only one that restores it: `alasio up` keeps every release one
|
|
69
|
+
* names (cli/src/kept-releases.ts).
|
|
70
|
+
*/
|
|
71
|
+
export const SNAPSHOT_RELEASE_ANNOTATION = "alasio.dev/snapshot-release";
|
|
72
|
+
/** Where a node agent keeps the snapshots it prepares, as `<environment>/<workspace>/<snapshot>` (../node-agent/cache.ts). */
|
|
73
|
+
export const SNAPSHOT_CACHE_DIR = "/var/lib/alasio/snapshots";
|
|
74
|
+
/** A snapshot's id, as a node agent names it: when it was taken, then 32 random bits. */
|
|
75
|
+
export const SNAPSHOT_ID = "[0-9]{8}T[0-9]{6}Z-[0-9a-f]{8}";
|
|
76
|
+
/** A DNS label: an environment's name (its sessions' namespace) and a workspace's (its Sandbox's), as the snapshot cache's directories are named. */
|
|
77
|
+
export const NAME = /^[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])?$/u;
|
|
78
|
+
/** The init container that holds a session's pod until its egress is confined: its name, and its resources. */
|
|
79
|
+
export const EGRESS_GATE = { name: "egress-gate", resources: { requests: { cpu: "10m", memory: "32Mi" }, limits: { memory: "64Mi" } } };
|
|
80
|
+
/**
|
|
81
|
+
* The egress gate's program: exits once three connections in a row to the API server
|
|
82
|
+
* fail, and fails the pod if they still succeed after two minutes. Runs on the agent
|
|
83
|
+
* image's Node.
|
|
84
|
+
*/
|
|
85
|
+
export const EGRESS_GATE_SCRIPT = [
|
|
86
|
+
"const net = require('node:net');",
|
|
87
|
+
"const host = process.env.KUBERNETES_SERVICE_HOST, port = Number(process.env.KUBERNETES_SERVICE_PORT);",
|
|
88
|
+
"const deadline = Date.now() + 120000; let refused = 0;",
|
|
89
|
+
"(function probe() {",
|
|
90
|
+
" const socket = net.connect({ host, port, timeout: 1000 });",
|
|
91
|
+
" const next = (blocked) => { socket.destroy(); refused = blocked ? refused + 1 : 0;",
|
|
92
|
+
" if (refused >= 3) process.exit(0);",
|
|
93
|
+
" if (Date.now() > deadline) { console.error('egress is not confined: is NetworkPolicy enforced in this cluster?'); process.exit(1); }",
|
|
94
|
+
" setTimeout(probe, 250); };",
|
|
95
|
+
" socket.once('connect', () => next(false)); socket.once('timeout', () => next(true)); socket.once('error', () => next(true));",
|
|
96
|
+
"})();",
|
|
97
|
+
].join("\n");
|
|
98
|
+
//# sourceMappingURL=sandbox-shape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-shape.js","sourceRoot":"","sources":["../../../../src/kube/sandbox-shape.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AAEvC,iGAAiG;AACjG,MAAM,CAAC,MAAM,SAAS,GAAG,mBAAmB,CAAC;AAC7C,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AACjC,MAAM,CAAC,MAAM,YAAY,GAAG,oBAAoB,CAAC;AACjD,2GAA2G;AAC3G,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAChC,0FAA0F;AAC1F,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,SAAS,IAAI,SAAS,EAAE,CAAC;AAEtD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAsB,CAAC,cAAc,EAAE,UAAU,CAAC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BAAoB,CAAC;AACtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AACzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,6BAA6B,CAAC;AACzE,8HAA8H;AAC9H,MAAM,CAAC,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AAC9D,yFAAyF;AACzF,MAAM,CAAC,MAAM,WAAW,GAAG,gCAAgC,CAAC;AAC5D,qJAAqJ;AACrJ,MAAM,CAAC,MAAM,IAAI,GAAG,uCAAuC,CAAC;AAE5D,+GAA+G;AAC/G,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAW,CAAC;AAEjJ;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,kCAAkC;IAClC,uGAAuG;IACvG,wDAAwD;IACxD,qBAAqB;IACrB,8DAA8D;IAC9D,sFAAsF;IACtF,wCAAwC;IACxC,0IAA0I;IAC1I,gCAAgC;IAChC,gIAAgI;IAChI,OAAO;CACR,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a node keeps its gVisor releases, containerd's runtimes of them and its
|
|
3
|
+
* snapshots, where its node agent serves, and the memory the agent needs: as the agent
|
|
4
|
+
* reads them, the clusters alasio makes lay them out (cli/src/cluster/), and the
|
|
5
|
+
* installation's manifests give them to the agent (cli/src/manifests/node-agent.ts). Free
|
|
6
|
+
* of any import but sandbox-shape's, itself free of any, so the command line takes it
|
|
7
|
+
* without the agent.
|
|
8
|
+
*/
|
|
9
|
+
/** The port a node agent serves its API on, on its pod's address. */
|
|
10
|
+
export const NODE_AGENT_PORT = 8484;
|
|
11
|
+
/**
|
|
12
|
+
* Where a node keeps the gVisor releases alasio keeps, each in a directory of its own
|
|
13
|
+
* named after it, as its release archive has them: runsc, its shim, and gvisor-bin/, the
|
|
14
|
+
* binaries runsc runs beside it.
|
|
15
|
+
*/
|
|
16
|
+
export const GVISOR_RELEASES = "/usr/local/lib/alasio/gvisor";
|
|
17
|
+
/** The directory of gVisor's `release` on a node. */
|
|
18
|
+
export const gvisorDirectory = (release) => `${GVISOR_RELEASES}/${release}`;
|
|
19
|
+
/** Where k3s's containerd reads its template, and runsc its options. */
|
|
20
|
+
export const CONTAINERD = "/var/lib/rancher/k3s/agent/etc/containerd";
|
|
21
|
+
/** gVisor's `release` as a DNS label, which containerd's runtimes and Kubernetes' RuntimeClasses are named with: its dots made dashes. */
|
|
22
|
+
export const gvisorLabel = (release) => release.replaceAll(".", "-");
|
|
23
|
+
/**
|
|
24
|
+
* The containerd runtime of gVisor's `release`, which a RuntimeClass names as its
|
|
25
|
+
* handler, and whose runsc options are `<CONTAINERD>/<runtime>.toml`.
|
|
26
|
+
*/
|
|
27
|
+
export const gvisorHandler = (release) => `runsc-${gvisorLabel(release)}`;
|
|
28
|
+
/** The RuntimeClass of gVisor's `release` alone, which a sandbox snapshotted under it is restored with. */
|
|
29
|
+
export const gvisorRuntimeClass = (release) => `gvisor-${gvisorLabel(release)}`;
|
|
30
|
+
/** The version runsc of gVisor's `release` reports, and saves its images with: its release's tag. */
|
|
31
|
+
export const runscVersion = (release) => `release-${release}`;
|
|
32
|
+
/** The root the gVisor shims run runsc with for Kubernetes' containers, under the node's /run. */
|
|
33
|
+
export const RUNSC_ROOT = "/run/containerd/runsc/k8s.io";
|
|
34
|
+
/** The node's snapshot cache, where its sandboxes are restored from, as the admission policy holds a restore to. */
|
|
35
|
+
export { SNAPSHOT_CACHE_DIR } from "../kube/sandbox-shape.js";
|
|
36
|
+
/**
|
|
37
|
+
* The node agent's container that says, as its pod starts, the CPU features its node has
|
|
38
|
+
* under the current gVisor release (./cpu-features.ts), as its termination message, which
|
|
39
|
+
* Kubernetes keeps up to 4 KiB of: a CpuFeaturesReport, as JSON.
|
|
40
|
+
*/
|
|
41
|
+
export const CPU_FEATURES_CONTAINER = "cpu-features";
|
|
42
|
+
/** A part of a snapshot file the node agent puts or gets (./s3.ts): 32 MiB, as large as S3's 10000 parts make an object of 312 GiB. */
|
|
43
|
+
export const SNAPSHOT_PART_BYTES = 32 * 1024 ** 2;
|
|
44
|
+
/** How many parts of a snapshot file the node agent puts or gets at a time, and how many gets, of every snapshot it gets. */
|
|
45
|
+
export const SNAPSHOT_PARTS_AT_ONCE = 4;
|
|
46
|
+
/** What a get of the node agent's writes to its file between syncs to the disk: 8 MiB. */
|
|
47
|
+
export const SNAPSHOT_SYNC_BYTES = 8 * 1024 ** 2;
|
|
48
|
+
/**
|
|
49
|
+
* The node agent's memory budget for what it gets: what it holds written and not yet on
|
|
50
|
+
* the disk, at most, of every get at a time together (./s3.ts). The kernel counts it in the
|
|
51
|
+
* agent's memory and cannot reclaim it before it is written, so the agent's memory limit
|
|
52
|
+
* leaves room for it beside the agent's own; what it reads through the page cache, the
|
|
53
|
+
* kernel reclaims.
|
|
54
|
+
*/
|
|
55
|
+
export const UNSYNCED_DOWNLOAD_BYTES = SNAPSHOT_PARTS_AT_ONCE * SNAPSHOT_SYNC_BYTES;
|
|
56
|
+
/**
|
|
57
|
+
* The node agent's own memory: what it was measured to hold restoring a 1 GiB session's
|
|
58
|
+
* snapshot from the bucket on a node of its own (test/e2e, 125 to 145 MiB anonymous),
|
|
59
|
+
* rounded up.
|
|
60
|
+
*/
|
|
61
|
+
export const NODE_AGENT_OWN_BYTES = 160 * 1024 ** 2;
|
|
62
|
+
/** The least memory limit a node agent runs under: its own, and a download's budget beside it. */
|
|
63
|
+
export const NODE_AGENT_MEMORY_FLOOR = NODE_AGENT_OWN_BYTES + UNSYNCED_DOWNLOAD_BYTES;
|
|
64
|
+
/** The variable holding the token alasio presents to a node agent. */
|
|
65
|
+
export const NODE_AGENT_TOKEN_VARIABLE = "ALASIO_NODE_AGENT_TOKEN";
|
|
66
|
+
/** The variable holding the most bytes the node's snapshot cache keeps. */
|
|
67
|
+
export const SNAPSHOT_CACHE_BYTES_VARIABLE = "ALASIO_SNAPSHOT_CACHE_BYTES";
|
|
68
|
+
/**
|
|
69
|
+
* How long a checkpoint, a prepare or a copy may take: a sandbox's memory, through the store,
|
|
70
|
+
* both ways, or within it. alasio waits for one so long, and an agent that stops lets the
|
|
71
|
+
* ones it runs end within it (./operations.ts).
|
|
72
|
+
*/
|
|
73
|
+
export const OPERATION_LIMIT_SECONDS = 15 * 60;
|
|
74
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../src/node-agent/names.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,qEAAqE;AACrE,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AAEpC;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,8BAA8B,CAAC;AAE9D,qDAAqD;AACrD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,GAAG,eAAe,IAAI,OAAO,EAAE,CAAC;AAE5F,wEAAwE;AACxE,MAAM,CAAC,MAAM,UAAU,GAAG,2CAA2C,CAAC;AAEtE,0IAA0I;AAC1I,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAErF;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,SAAS,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;AAE1F,2GAA2G;AAC3G,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,UAAU,WAAW,CAAC,OAAO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