@rallycry/conveyor-k3 0.1.11 → 0.1.12
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.js +4941 -1129
- package/dist/index.d.ts +258 -82
- package/dist/index.js +1782 -362
- package/dist/vm-qemu.js +256 -91
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ interface ClusterConnectionConfig {
|
|
|
5
5
|
clusterToken: string;
|
|
6
6
|
/** Test-only override; production always reads the root-owned guest key. */
|
|
7
7
|
deviceKeyPath?: string;
|
|
8
|
+
/** Test-only overrides; production reads the host-written control aliases. */
|
|
9
|
+
readControlFile?: (path: string) => string | null;
|
|
10
|
+
controlFileExists?: (path: string) => boolean;
|
|
8
11
|
}
|
|
9
12
|
declare class ClusterConnection {
|
|
10
13
|
private socket;
|
|
@@ -68,7 +71,8 @@ interface FileSystemPort$1 {
|
|
|
68
71
|
readFile(path: string): Promise<string | null>;
|
|
69
72
|
writeFile(path: string, content: string, mode?: number): Promise<void>;
|
|
70
73
|
removeFile(path: string): Promise<void>;
|
|
71
|
-
|
|
74
|
+
/** With a mode, an existing directory is set to it as well. */
|
|
75
|
+
ensureDir(path: string, mode?: number): Promise<void>;
|
|
72
76
|
}
|
|
73
77
|
declare const nodeFileSystem: FileSystemPort$1;
|
|
74
78
|
/** In-memory filesystem for tests. Exported so suites share one shape. */
|
|
@@ -78,6 +82,23 @@ declare function createMemoryFileSystem(seed?: Record<string, string>): FileSyst
|
|
|
78
82
|
removed: string[];
|
|
79
83
|
};
|
|
80
84
|
|
|
85
|
+
/**
|
|
86
|
+
* The long-lived daemon: connect, converge, report, repeat.
|
|
87
|
+
*
|
|
88
|
+
* Three clocks, deliberately independent:
|
|
89
|
+
*
|
|
90
|
+
* - **Heartbeat, 30s.** Placement reads what this writes, so it is the one
|
|
91
|
+
* thing that must never stall behind slower work.
|
|
92
|
+
* - **Warm, hourly.** Re-pull the wanted refs so a bake never costs the next
|
|
93
|
+
* card a cold multi-gigabyte pull.
|
|
94
|
+
* - **Reconcile + prune, daily** — plus on connect and whenever Conveyor says
|
|
95
|
+
* the desired state changed.
|
|
96
|
+
*
|
|
97
|
+
* The daily reconcile is what makes this a reconciler rather than a command
|
|
98
|
+
* listener: a machine that was powered off, or whose sync nudge landed on
|
|
99
|
+
* another API replica, still converges on its own.
|
|
100
|
+
*/
|
|
101
|
+
|
|
81
102
|
interface DaemonPorts {
|
|
82
103
|
exec: Executor;
|
|
83
104
|
fs: FileSystemPort$1;
|
|
@@ -85,6 +106,8 @@ interface DaemonPorts {
|
|
|
85
106
|
cliVersion: string;
|
|
86
107
|
writeWorkloads?: (data: PersonalClusterWorkloads | undefined) => Promise<void>;
|
|
87
108
|
log: (line: string) => void;
|
|
109
|
+
/** The in-cluster registry's HTTP API; the global `fetch` when absent. */
|
|
110
|
+
fetch?: (url: string, init?: RequestInit) => Promise<Response>;
|
|
88
111
|
}
|
|
89
112
|
declare class ClusterDaemon {
|
|
90
113
|
private readonly ports;
|
|
@@ -105,7 +128,13 @@ declare class ClusterDaemon {
|
|
|
105
128
|
* the next reconcile silently clear them.
|
|
106
129
|
*/
|
|
107
130
|
private warmWarnings;
|
|
131
|
+
/** Content hash labels by image id, so each image is inspected once. */
|
|
132
|
+
private readonly localImageHashes;
|
|
133
|
+
/** How long the in-cluster registry has been not ready, across beats. */
|
|
134
|
+
private readonly registryWatch;
|
|
108
135
|
private timers;
|
|
136
|
+
/** When the last store walk started, so one that failed is not retried on every reconcile. */
|
|
137
|
+
private storeWalkStartedAt;
|
|
109
138
|
/** Serializes reconcile against itself — a sync nudge during a reconcile
|
|
110
139
|
* must queue, not interleave two kubectl applies of the same manifests. */
|
|
111
140
|
private reconciling;
|
|
@@ -124,6 +153,14 @@ declare class ClusterDaemon {
|
|
|
124
153
|
* generations in between.
|
|
125
154
|
*/
|
|
126
155
|
private warmAndPruneIfDue;
|
|
156
|
+
/**
|
|
157
|
+
* Measure k3s's containerd store when the last measurement is old enough,
|
|
158
|
+
* and keep the result for the heartbeat. After a prune, so the number it
|
|
159
|
+
* reports is what the prune left. A failed measurement keeps the last one.
|
|
160
|
+
*/
|
|
161
|
+
private measureStoreIfDue;
|
|
162
|
+
/** The store size the heartbeat reports: the last measurement, null before one. */
|
|
163
|
+
private get measuredStoreBytes();
|
|
127
164
|
/** Pre-pull the wanted refs. Silent on success; that is the normal case. */
|
|
128
165
|
warm(): Promise<void>;
|
|
129
166
|
/**
|
|
@@ -158,63 +195,8 @@ declare class ClusterDaemon {
|
|
|
158
195
|
private runBeat;
|
|
159
196
|
}
|
|
160
197
|
|
|
161
|
-
/**
|
|
162
|
-
|
|
163
|
-
*
|
|
164
|
-
* This is what "manages itself" means in code. Conveyor publishes what the
|
|
165
|
-
* cluster SHOULD look like; this function makes it so, and it runs on connect,
|
|
166
|
-
* on request, and daily. Nothing here is a command from the server — a machine
|
|
167
|
-
* that was powered off for a week catches up on its next run, and a practice
|
|
168
|
-
* Conveyor changes reaches every enrolled box without anyone touching one.
|
|
169
|
-
*
|
|
170
|
-
* Three properties every step keeps:
|
|
171
|
-
*
|
|
172
|
-
* 1. **Idempotent.** Running twice changes nothing the first run already did.
|
|
173
|
-
* 2. **Independently fallible.** A step that fails records a warning and the
|
|
174
|
-
* rest still run. A cluster with one bad namespace is not a reason to skip
|
|
175
|
-
* image hygiene.
|
|
176
|
-
* 3. **Additive.** Nothing here deletes a namespace, a workload, or an image
|
|
177
|
-
* that is in use. The machine belongs to its owner.
|
|
178
|
-
* 4. **Bounded.** The server does not get to say what runs here. The one field
|
|
179
|
-
* it sends as raw YAML is checked against a local kind allowlist before it
|
|
180
|
-
* reaches `kubectl` — see `../lib/manifest-guard.js`.
|
|
181
|
-
*/
|
|
182
|
-
|
|
183
|
-
/** The filesystem operations reconcile needs, injectable for tests. */
|
|
184
|
-
interface FileSystemPort {
|
|
185
|
-
readFile(path: string): Promise<string | null>;
|
|
186
|
-
writeFile(path: string, content: string, mode?: number): Promise<void>;
|
|
187
|
-
removeFile(path: string): Promise<void>;
|
|
188
|
-
ensureDir(path: string): Promise<void>;
|
|
189
|
-
}
|
|
190
|
-
interface ReconcileContext {
|
|
191
|
-
exec: Executor;
|
|
192
|
-
fs: FileSystemPort;
|
|
193
|
-
/**
|
|
194
|
-
* Conveyor pods currently running here, or null when that could not be
|
|
195
|
-
* determined. A disruptive step is unsafe above zero AND unsafe on null —
|
|
196
|
-
* "I could not ask" is not "nothing is running".
|
|
197
|
-
*/
|
|
198
|
-
runningConveyorPods: number | null;
|
|
199
|
-
}
|
|
200
|
-
interface ReconcileResult {
|
|
201
|
-
appliedVersion: number;
|
|
202
|
-
warnings: string[];
|
|
203
|
-
/** True when the kubelet drop-in changed and k3s was restarted. */
|
|
204
|
-
restartedK3s: boolean;
|
|
205
|
-
/** Kubelet flags left to the owner because their own config sets them. */
|
|
206
|
-
skippedKubeletFlags: string[];
|
|
207
|
-
/**
|
|
208
|
-
* The image-GC high threshold the kubelet is actually enforcing — ours, or
|
|
209
|
-
* the owner's when their own config.yaml set it and the drop-in stood down.
|
|
210
|
-
* Null when neither side named one. Reported so the heartbeat can warn about
|
|
211
|
-
* GC pressure against the number in force rather than the one we sent.
|
|
212
|
-
*/
|
|
213
|
-
effectiveImageGcHighThreshold: number | null;
|
|
214
|
-
/** True when a wrong-valued PriorityClass was deleted AND put back. */
|
|
215
|
-
recreatedPriorityClass: boolean;
|
|
216
|
-
}
|
|
217
|
-
declare function reconcile(ctx: ReconcileContext, desired: PersonalClusterDesiredState): Promise<ReconcileResult>;
|
|
198
|
+
/** The `fetch` the registry API calls go through, injectable for tests. */
|
|
199
|
+
type RegistryFetch = (url: string, init?: RequestInit) => Promise<Response>;
|
|
218
200
|
|
|
219
201
|
/** One entry of `crictl images -o json`. */
|
|
220
202
|
interface CrictlImage {
|
|
@@ -277,6 +259,22 @@ interface WarmResult {
|
|
|
277
259
|
*/
|
|
278
260
|
declare function warmImages(exec: Executor, wantedImages: string[], unauthenticatedHosts: string[]): Promise<WarmResult>;
|
|
279
261
|
|
|
262
|
+
/**
|
|
263
|
+
* Which locally baked images this machine holds, for placement.
|
|
264
|
+
*
|
|
265
|
+
* A Bake Locally project's image exists only where a bake imported it: the
|
|
266
|
+
* runner's own machine, or the managed VM on it. When one account has several
|
|
267
|
+
* instances, placement has to send a card to an instance that holds the image,
|
|
268
|
+
* and should prefer one holding the latest bake. So the heartbeat lists every
|
|
269
|
+
* `localhost/` ref, with the content hash the bake stamped on the image.
|
|
270
|
+
*
|
|
271
|
+
* The hash takes one `crictl inspecti` per image, cached by image id: an id
|
|
272
|
+
* names exactly one image config, so its label never changes.
|
|
273
|
+
*/
|
|
274
|
+
|
|
275
|
+
/** Image id to the content hash label on that image, null when it has none. */
|
|
276
|
+
type LocalImageHashCache = Map<string, string | null>;
|
|
277
|
+
|
|
280
278
|
interface TelemetryState {
|
|
281
279
|
cliVersion: string;
|
|
282
280
|
appliedDesiredStateVersion: number;
|
|
@@ -291,10 +289,32 @@ interface TelemetryState {
|
|
|
291
289
|
* no reconcile has read one yet. Drives the GC-pressure warning below.
|
|
292
290
|
*/
|
|
293
291
|
imageGcHighThreshold?: number | null;
|
|
292
|
+
/** The daemon's own cache of content hash labels, kept across beats. */
|
|
293
|
+
localImageHashes?: LocalImageHashCache;
|
|
294
|
+
/** Present while desired state turns the in-cluster registry on. */
|
|
295
|
+
localRegistry?: LocalRegistryWatch;
|
|
296
|
+
/**
|
|
297
|
+
* The last measured size of k3s's containerd store. Null (or absent) until
|
|
298
|
+
* the first measurement, and the heartbeat says null then: a 0 would read
|
|
299
|
+
* as an empty store.
|
|
300
|
+
*/
|
|
301
|
+
k3sStoreBytes?: number | null;
|
|
294
302
|
}
|
|
295
303
|
interface TelemetryPorts {
|
|
296
304
|
exec: Executor;
|
|
297
305
|
readFile(path: string): Promise<string | null>;
|
|
306
|
+
/** Injectable for tests; the registry probe uses the global otherwise. */
|
|
307
|
+
fetch?: RegistryFetch;
|
|
308
|
+
}
|
|
309
|
+
/** The daemon's memory of the registry's readiness, kept across beats. */
|
|
310
|
+
interface LocalRegistryWatch {
|
|
311
|
+
/** When a beat first found the registry not ready; null while it is. */
|
|
312
|
+
notReadySince: number | null;
|
|
313
|
+
/**
|
|
314
|
+
* Until when a cleanup stops the registry on purpose. The clock does not
|
|
315
|
+
* run until then, so the panel never calls that stop an outage.
|
|
316
|
+
*/
|
|
317
|
+
pausedUntil?: number | null;
|
|
298
318
|
}
|
|
299
319
|
/**
|
|
300
320
|
* Conveyor pods running here, across every namespace it manages — or null when
|
|
@@ -313,6 +333,71 @@ interface TelemetryPorts {
|
|
|
313
333
|
declare function countRunningConveyorPods(exec: Executor): Promise<number | null>;
|
|
314
334
|
declare function collectHeartbeat(ports: TelemetryPorts, state: TelemetryState, inventory: ImageInventory | null): Promise<PersonalClusterHeartbeat>;
|
|
315
335
|
|
|
336
|
+
/**
|
|
337
|
+
* Converge the machine onto Conveyor's desired state.
|
|
338
|
+
*
|
|
339
|
+
* This is what "manages itself" means in code. Conveyor publishes what the
|
|
340
|
+
* cluster SHOULD look like; this function makes it so, and it runs on connect,
|
|
341
|
+
* on request, and daily. Nothing here is a command from the server — a machine
|
|
342
|
+
* that was powered off for a week catches up on its next run, and a practice
|
|
343
|
+
* Conveyor changes reaches every enrolled box without anyone touching one.
|
|
344
|
+
*
|
|
345
|
+
* Three properties every step keeps:
|
|
346
|
+
*
|
|
347
|
+
* 1. **Idempotent.** Running twice changes nothing the first run already did.
|
|
348
|
+
* 2. **Independently fallible.** A step that fails records a warning and the
|
|
349
|
+
* rest still run. A cluster with one bad namespace is not a reason to skip
|
|
350
|
+
* image hygiene.
|
|
351
|
+
* 3. **Additive.** Nothing here deletes a namespace, a workload, or an image
|
|
352
|
+
* that is in use. The machine belongs to its owner. The one delete is an
|
|
353
|
+
* EMPTY pool namespace of a project the machine no longer serves, under
|
|
354
|
+
* local bounds the server cannot widen — see `./prune-namespaces.js`.
|
|
355
|
+
* 4. **Bounded.** The server does not get to say what runs here. The one field
|
|
356
|
+
* it sends as raw YAML is checked against a local kind allowlist before it
|
|
357
|
+
* reaches `kubectl` — see `../lib/manifest-guard.js`.
|
|
358
|
+
*/
|
|
359
|
+
|
|
360
|
+
/** The filesystem operations reconcile needs, injectable for tests. */
|
|
361
|
+
interface FileSystemPort {
|
|
362
|
+
readFile(path: string): Promise<string | null>;
|
|
363
|
+
writeFile(path: string, content: string, mode?: number): Promise<void>;
|
|
364
|
+
removeFile(path: string): Promise<void>;
|
|
365
|
+
ensureDir(path: string, mode?: number): Promise<void>;
|
|
366
|
+
}
|
|
367
|
+
interface ReconcileContext {
|
|
368
|
+
exec: Executor;
|
|
369
|
+
fs: FileSystemPort;
|
|
370
|
+
/**
|
|
371
|
+
* Conveyor pods currently running here, or null when that could not be
|
|
372
|
+
* determined. A disruptive step is unsafe above zero AND unsafe on null —
|
|
373
|
+
* "I could not ask" is not "nothing is running".
|
|
374
|
+
*/
|
|
375
|
+
runningConveyorPods: number | null;
|
|
376
|
+
}
|
|
377
|
+
interface ReconcileResult {
|
|
378
|
+
appliedVersion: number;
|
|
379
|
+
warnings: string[];
|
|
380
|
+
/**
|
|
381
|
+
* True when this pass restarted k3s: for new kubelet settings, or to load
|
|
382
|
+
* the local image registry's mirror. At most one restart per pass.
|
|
383
|
+
*/
|
|
384
|
+
restartedK3s: boolean;
|
|
385
|
+
/** Kubelet flags left to the owner because their own config sets them. */
|
|
386
|
+
skippedKubeletFlags: string[];
|
|
387
|
+
/**
|
|
388
|
+
* The image-GC high threshold the kubelet is actually enforcing — ours, or
|
|
389
|
+
* the owner's when their own config.yaml set it and the drop-in stood down.
|
|
390
|
+
* Null when neither side named one. Reported so the heartbeat can warn about
|
|
391
|
+
* GC pressure against the number in force rather than the one we sent.
|
|
392
|
+
*/
|
|
393
|
+
effectiveImageGcHighThreshold: number | null;
|
|
394
|
+
/** True when a wrong-valued PriorityClass was deleted AND put back. */
|
|
395
|
+
recreatedPriorityClass: boolean;
|
|
396
|
+
/** Empty pool namespaces of projects this machine no longer serves, removed. */
|
|
397
|
+
prunedNamespaces: string[];
|
|
398
|
+
}
|
|
399
|
+
declare function reconcile(ctx: ReconcileContext, desired: PersonalClusterDesiredState): Promise<ReconcileResult>;
|
|
400
|
+
|
|
316
401
|
interface RegistryAuth {
|
|
317
402
|
username?: string;
|
|
318
403
|
password?: string;
|
|
@@ -491,6 +576,15 @@ interface MachineState {
|
|
|
491
576
|
* wanted" is not a safe rule to unpin on. Only what we pinned, we unpin.
|
|
492
577
|
*/
|
|
493
578
|
pinnedImages?: string[];
|
|
579
|
+
/** When the in-cluster registry's garbage was last collected. */
|
|
580
|
+
lastRegistryGcAt?: string | null;
|
|
581
|
+
/**
|
|
582
|
+
* The size of k3s's containerd store at the last measurement, and when that
|
|
583
|
+
* was. Kept so the heartbeat reports it between the hourly measurements,
|
|
584
|
+
* and a daemon restart does not walk the store again straight away.
|
|
585
|
+
*/
|
|
586
|
+
k3sStoreBytes?: number;
|
|
587
|
+
k3sStoreMeasuredAt?: string;
|
|
494
588
|
}
|
|
495
589
|
declare function readState(fs: FileSystemPort$1): Promise<MachineState>;
|
|
496
590
|
declare function writeState(fs: FileSystemPort$1, state: MachineState): Promise<void>;
|
|
@@ -519,15 +613,17 @@ interface ParsedArgs {
|
|
|
519
613
|
* this surface is nine verbs and six flags, not a general CLI framework.
|
|
520
614
|
*/
|
|
521
615
|
declare function parseArgs(argv: readonly string[]): ParsedArgs;
|
|
522
|
-
declare const HELP = "conveyor-k3 \u2014 managed personal compute for Conveyor\n\nUsage: conveyor-k3 <command> [options]\n\nCommands:\n vm Manage isolated compute on macOS or Linux.\n Run conveyor-k3 vm for host lifecycle commands.\n setup Install and enrol this machine. Safe to re-run.\n start Start the tunnel and the daemon.\n stop Stop both, and tell Conveyor at once so your next\n build goes straight to project compute.\n status [--json] What is running, what Conveyor knows, and what is\n missing.\n sync Re-read your settings from Conveyor and apply them.\n update Update conveyor-k3, cloudflared, and (when you have\n allowed it and nothing is running) k3s.\n registry list Which registry credentials are configured, and which\n ones your projects still need.\n registry add <host> Add one registry credential.\n --username <user>\n --password-stdin read the password from stdin\n --no-restart skip the required k3s restart\n runners list Which GitHub Actions runners this machine hosts, and\n whether each may import a locally baked image.\n runners grant <user>\u2026 Let those runner users import a locally baked image\n into this node and pin it. Writes one file under\n /etc/sudoers.d, checked with visudo first. Needed only\n when a project has Bake Locally turned on.\n uninstall Remove Conveyor's units, environment, and
|
|
616
|
+
declare const HELP = "conveyor-k3 \u2014 managed personal compute for Conveyor\n\nUsage: conveyor-k3 <command> [options]\n\nCommands:\n vm Manage isolated compute on macOS or Linux.\n Run conveyor-k3 vm for host lifecycle commands.\n setup Install and enrol this machine. Safe to re-run.\n start Start the tunnel and the daemon.\n stop Stop both, and tell Conveyor at once so your next\n build goes straight to project compute.\n status [--json] What is running, what Conveyor knows, and what is\n missing.\n sync Re-read your settings from Conveyor and apply them.\n update Update conveyor-k3, cloudflared, and (when you have\n allowed it and nothing is running) k3s.\n registry list Which registry credentials are configured, and which\n ones your projects still need.\n registry add <host> Add one registry credential.\n --username <user>\n --password-stdin read the password from stdin\n --no-restart skip the required k3s restart\n registry gc Delete superseded shadow-bake images from the image\n registry inside this cluster. Runs daily on its own,\n and only while no Conveyor pod or bake is running.\n --dry-run list what it would delete\n runners list Which GitHub Actions runners this machine hosts, and\n whether each may import a locally baked image.\n runners grant <user>\u2026 Let those runner users import a locally baked image\n into this node and pin it. Writes one file under\n /etc/sudoers.d, checked with visudo first. Needed only\n when a project has Bake Locally turned on.\n uninstall Remove Conveyor's units, environment, state, and image\n registry. Your k3s config, your own registries.yaml\n entries, your workloads, and the registry's data are\n left alone.\n --purge-k3s --yes also remove k3s itself and the\n registry's data\n daemon Run in the foreground (what the systemd unit calls).\n\nOptions:\n --version Print the version.\n --help Print this message.\n\nDocs: https://conveyor.rallycryapp.com/docs/guides/managed-personal-compute\n";
|
|
523
617
|
|
|
524
618
|
/**
|
|
525
|
-
* `conveyor-k3 registry add|list` —
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
619
|
+
* `conveyor-k3 registry add|list|gc` — where an owner adds registry
|
|
620
|
+
* credentials, and cleans up the registry inside the cluster.
|
|
621
|
+
*
|
|
622
|
+
* `add` is the one command that writes a credential into `registries.yaml`.
|
|
623
|
+
* The reconcile loop writes that file for one reason only: the mirror for the
|
|
624
|
+
* in-cluster registry's host (`lib/registries.ts` lists both writers). Both
|
|
625
|
+
* take a timestamped backup first, and both merge rather than template — so a
|
|
626
|
+
* machine pulling through its own LAN mirror keeps that mirror, its TLS
|
|
531
627
|
* settings, and every other host it had configured.
|
|
532
628
|
*
|
|
533
629
|
* A restart is required and is not optional: k3s reads `registries.yaml` at
|
|
@@ -568,23 +664,12 @@ declare function registryList(ports: RegistryPorts, requiredHosts: string[]): Pr
|
|
|
568
664
|
*/
|
|
569
665
|
declare function renderRegistryAuthSummary(missing: string[]): string[];
|
|
570
666
|
|
|
571
|
-
/**
|
|
572
|
-
* `conveyor-k3 uninstall` — remove exactly what Conveyor put on this machine.
|
|
573
|
-
*
|
|
574
|
-
* Everything this CLI created carries a `conveyor-k3` name and lives under
|
|
575
|
-
* `/etc/conveyor` or `/var/lib/conveyor-k3`, which is what makes a precise
|
|
576
|
-
* removal possible. Nothing else is touched: not the owner's `config.yaml`,
|
|
577
|
-
* not `registries.yaml`, not their workloads.
|
|
578
|
-
*
|
|
579
|
-
* k3s itself is NOT removed by default. On most machines it predates us, or
|
|
580
|
-
* the owner wants to keep it — so removing it is `--purge-k3s`, and even then
|
|
581
|
-
* only after an explicit confirmation.
|
|
582
|
-
*/
|
|
583
|
-
|
|
584
667
|
interface UninstallPorts {
|
|
585
668
|
exec: Executor;
|
|
586
669
|
fs: FileSystemPort$1;
|
|
587
670
|
log: (line: string) => void;
|
|
671
|
+
/** Injected so the `registries.yaml` backup's name is deterministic in tests. */
|
|
672
|
+
now?: () => Date;
|
|
588
673
|
}
|
|
589
674
|
interface UninstallOptions {
|
|
590
675
|
/** Also run k3s-uninstall.sh. Requires `confirmed`. */
|
|
@@ -694,6 +779,27 @@ declare function runUpdate(ports: UpdatePorts, decision: K3sUpgradeDecision, cha
|
|
|
694
779
|
declare function parseK3sVersion(output: string): [number, number] | null;
|
|
695
780
|
declare function meetsK3sMinimum(version: [number, number] | null): boolean;
|
|
696
781
|
|
|
782
|
+
/**
|
|
783
|
+
* Capacity profiles: how many guest connections a VM's host relays at once, how
|
|
784
|
+
* much one connection may carry, and how fast the boot disk may go.
|
|
785
|
+
*
|
|
786
|
+
* Pure and import-free on purpose: the QEMU wrapper bundle (dist/vm-qemu.js)
|
|
787
|
+
* includes it, and that bundle starts once for every guest connection.
|
|
788
|
+
*/
|
|
789
|
+
/** `custom` is any set of values that no longer matches a preset. */
|
|
790
|
+
type CapacityProfile = "default" | "server" | "custom";
|
|
791
|
+
/** What the host enforces, in bytes, rendered into network.json as `limits`. */
|
|
792
|
+
interface CapacityLimits {
|
|
793
|
+
schema: 1;
|
|
794
|
+
profile: CapacityProfile;
|
|
795
|
+
relaySlots: number;
|
|
796
|
+
/** Slots that only control-plane relays (the tunnel and the daemon) may take. */
|
|
797
|
+
reservedRelaySlots: number;
|
|
798
|
+
relayMaxBytes: number;
|
|
799
|
+
diskBytesPerSecond: number;
|
|
800
|
+
diskIops: number;
|
|
801
|
+
}
|
|
802
|
+
|
|
697
803
|
interface NetworkEndpoint {
|
|
698
804
|
host: string;
|
|
699
805
|
ports: number[];
|
|
@@ -706,6 +812,8 @@ interface ResolvedNetworkHost {
|
|
|
706
812
|
/** Host-resolved, pinned, globally-routable IPv4 address. */
|
|
707
813
|
address: string;
|
|
708
814
|
ports: number[];
|
|
815
|
+
/** A control-plane destination, whose relays may use the reserved slots. */
|
|
816
|
+
reserve?: "control";
|
|
709
817
|
}
|
|
710
818
|
interface GuestSrvRecord {
|
|
711
819
|
name: string;
|
|
@@ -719,6 +827,13 @@ interface ResolvedNetwork {
|
|
|
719
827
|
hosts: ResolvedNetworkHost[];
|
|
720
828
|
/** Static SRV answers needed by cloudflared's documented edge discovery. */
|
|
721
829
|
srv: GuestSrvRecord[];
|
|
830
|
+
/**
|
|
831
|
+
* Daemon-only aliases of the Conveyor API. Guest DNS never serves them, so
|
|
832
|
+
* only the daemon, which dials them by address, can use the reserved slots.
|
|
833
|
+
*/
|
|
834
|
+
control?: ResolvedNetworkHost[];
|
|
835
|
+
/** What the host enforces. Absent in a document an older CLI wrote. */
|
|
836
|
+
limits?: CapacityLimits;
|
|
722
837
|
}
|
|
723
838
|
/** Alias used by the VM host manager. */
|
|
724
839
|
type NetworkPolicy = ResolvedNetwork;
|
|
@@ -776,11 +891,72 @@ interface QemuNetworkPolicy extends ResolvedNetwork {
|
|
|
776
891
|
/** Host-only information used to tie QEMU file endpoints to one Lima instance. */
|
|
777
892
|
interface QemuPolicyContext {
|
|
778
893
|
instanceDir?: string;
|
|
894
|
+
/** The Lima instance name, which Lima passes as `-name lima-<name>`. */
|
|
895
|
+
vmName?: string;
|
|
896
|
+
/** The boot-disk throttle, from the network policy's capacity limits. */
|
|
897
|
+
disk?: {
|
|
898
|
+
bps: number;
|
|
899
|
+
iops: number;
|
|
900
|
+
};
|
|
779
901
|
}
|
|
780
|
-
/**
|
|
781
|
-
|
|
902
|
+
/**
|
|
903
|
+
* Rewrites only a complete, known Lima QEMU profile; every unknown input fails
|
|
904
|
+
* closed. The network's capacity limits set the boot-disk throttle.
|
|
905
|
+
*/
|
|
906
|
+
declare function rewriteQemuArgs(args: string[], network: QemuNetworkPolicy, ncPath?: string, hostContext?: QemuPolicyContext): string[];
|
|
782
907
|
|
|
908
|
+
/** The largest whole-GiB guest whose host cost (see vmHostMemoryGiB) fits in the budget. */
|
|
909
|
+
declare function maximumGuestMemoryGiBWithin(budgetGiB: number, relaySlots?: number): number;
|
|
783
910
|
/** Reserve 25% of physical host RAM after accounting for VM overhead. */
|
|
784
|
-
declare function maximumGuestMemoryGiB(hostBytes: number): number;
|
|
911
|
+
declare function maximumGuestMemoryGiB(hostBytes: number, relaySlots?: number): number;
|
|
912
|
+
|
|
913
|
+
/** `--instance` omitted or `default`: the original VM, whose paths never move. */
|
|
914
|
+
declare const DEFAULT_INSTANCE = "default";
|
|
915
|
+
/** The `--instance` flag's value. Omitted or `default` selects the default VM. */
|
|
916
|
+
declare function parseInstanceName(value: unknown): string;
|
|
917
|
+
|
|
918
|
+
/** One VM's host paths. The default VM keeps its original root. */
|
|
919
|
+
declare function hostPaths(instance?: string): {
|
|
920
|
+
root: string;
|
|
921
|
+
limaHome: string;
|
|
922
|
+
state: string;
|
|
923
|
+
network: string;
|
|
924
|
+
template: string;
|
|
925
|
+
wrapper: string;
|
|
926
|
+
wrapperJs: string;
|
|
927
|
+
applied: string;
|
|
928
|
+
guard: string;
|
|
929
|
+
startRequest: string;
|
|
930
|
+
policyTransaction: string;
|
|
931
|
+
lock: string;
|
|
932
|
+
/** Written by an owner stop, so a supervising service does not restart the VM. */
|
|
933
|
+
stopIntent: string;
|
|
934
|
+
instance: string;
|
|
935
|
+
vmName: string;
|
|
936
|
+
instanceDir: string;
|
|
937
|
+
limaConfig: string;
|
|
938
|
+
};
|
|
939
|
+
/** Every host path of one VM under `root`. Pure, so tests inject a temporary root. */
|
|
940
|
+
declare function pathsForRoot(root: string, instance?: string): {
|
|
941
|
+
root: string;
|
|
942
|
+
limaHome: string;
|
|
943
|
+
state: string;
|
|
944
|
+
network: string;
|
|
945
|
+
template: string;
|
|
946
|
+
wrapper: string;
|
|
947
|
+
wrapperJs: string;
|
|
948
|
+
applied: string;
|
|
949
|
+
guard: string;
|
|
950
|
+
startRequest: string;
|
|
951
|
+
policyTransaction: string;
|
|
952
|
+
lock: string;
|
|
953
|
+
/** Written by an owner stop, so a supervising service does not restart the VM. */
|
|
954
|
+
stopIntent: string;
|
|
955
|
+
instance: string;
|
|
956
|
+
vmName: string;
|
|
957
|
+
instanceDir: string;
|
|
958
|
+
limaConfig: string;
|
|
959
|
+
};
|
|
960
|
+
type HostPaths = ReturnType<typeof pathsForRoot>;
|
|
785
961
|
|
|
786
|
-
export { ClusterConnection, type ClusterConnectionConfig, ClusterDaemon, CommandError, type CrictlImage, type DaemonPorts, type Executor, type FileSystemPort$1 as FileSystemPort, type GuestDnsProvision, type GuestSrvRecord, HELP, type ImageInventory, K3S_DISABLED_COMPONENTS, K3S_INSTALL_EXEC, type K3sUpgradeDecision, type MachineState, type NetworkEndpoint, type NetworkPolicy, type QemuNetworkPolicy, type ReconcileContext, type ReconcileResult, type RegistriesFile, type ResolvedNetwork, type ResolvedNetworkHost, type SRVLookup, type UninstallResult, type UnitRenderOptions, VERBS, type Verb, cloudflaredSrvRecords, collectHeartbeat, configuredAuthHosts, countRunningConveyorPods, createMemoryFileSystem, decideK3sUpgrade, isGloballyRoutableIPv4, isVerb, maximumGuestMemoryGiB, meetsK3sMinimum, missingAuthHosts, nodeFileSystem, ownerConfiguredKeys, ownerConfiguredKubeletFlags, parseArgs, parseK3sVersion, parseRegistries, pruneStrandedImages, readImageInventory, readState, reconcile, registryAdd, registryList, renderAllUnits, renderGuestDnsProvision, renderK3sDropIn, renderKubeletDropIn, renderRegistryAuthSummary, resolveCloudflaredSrvRecords, resolveNetwork, rewriteQemuArgs, runOrThrow, runUpdate, selectStrandedImages, serializeRegistries, spawnExecutor, uninstall, upsertRegistryAuth, warmImages, writeState };
|
|
962
|
+
export { ClusterConnection, type ClusterConnectionConfig, ClusterDaemon, CommandError, type CrictlImage, DEFAULT_INSTANCE, type DaemonPorts, type Executor, type FileSystemPort$1 as FileSystemPort, type GuestDnsProvision, type GuestSrvRecord, HELP, type HostPaths, type ImageInventory, K3S_DISABLED_COMPONENTS, K3S_INSTALL_EXEC, type K3sUpgradeDecision, type MachineState, type NetworkEndpoint, type NetworkPolicy, type QemuNetworkPolicy, type ReconcileContext, type ReconcileResult, type RegistriesFile, type ResolvedNetwork, type ResolvedNetworkHost, type SRVLookup, type UninstallResult, type UnitRenderOptions, VERBS, type Verb, cloudflaredSrvRecords, collectHeartbeat, configuredAuthHosts, countRunningConveyorPods, createMemoryFileSystem, decideK3sUpgrade, hostPaths, isGloballyRoutableIPv4, isVerb, maximumGuestMemoryGiB, maximumGuestMemoryGiBWithin, meetsK3sMinimum, missingAuthHosts, nodeFileSystem, ownerConfiguredKeys, ownerConfiguredKubeletFlags, parseArgs, parseInstanceName, parseK3sVersion, parseRegistries, pruneStrandedImages, readImageInventory, readState, reconcile, registryAdd, registryList, renderAllUnits, renderGuestDnsProvision, renderK3sDropIn, renderKubeletDropIn, renderRegistryAuthSummary, resolveCloudflaredSrvRecords, resolveNetwork, rewriteQemuArgs, runOrThrow, runUpdate, selectStrandedImages, serializeRegistries, spawnExecutor, uninstall, upsertRegistryAuth, warmImages, writeState };
|