@gresearch/marimohub-compute-armada 0.3.0 → 0.4.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.
@@ -0,0 +1,582 @@
1
+ # Configuring marimohub-compute-armada
2
+
3
+ The adapter is configured through environment variables of the marimohub process. This
4
+ file lists every variable it reads, and ships in the npm package next to the bundle.
5
+
6
+ All of it is checked when marimohub starts. A missing, malformed or conflicting value stops
7
+ startup with an error that names the variable, so a bad setting never waits for the first
8
+ session to fail. Error messages name the variable and, where it has one, the field at
9
+ fault; for settings that may hold credentials they never repeat the value.
10
+
11
+ Every variable has an entry under [Reference](#reference), with its heading spelled
12
+ exactly as the variable is. Variables that start with `MARIMOHUB_` are marimohub's own; the
13
+ adapter reads them too, so they are listed here with what they mean for Armada.
14
+
15
+ ## Loading the adapter
16
+
17
+ marimohub loads the adapter as an external library. These two are marimohub's settings:
18
+
19
+ ```bash
20
+ MARIMOHUB_COMPUTE_BACKEND=library
21
+ MARIMOHUB_COMPUTE_LIBRARY=/abs/path/to/node_modules/@gresearch/marimohub-compute-armada/dist/index.js
22
+ ```
23
+
24
+ The path must be absolute. The `Dockerfile` in the repository presets both, with the
25
+ bundle at `/etc/marimohub/compute.mjs`. The adapter needs marimohub 0.7.1 or later and
26
+ refuses to load on an older one.
27
+
28
+ ## Common setups
29
+
30
+ ### The smallest working configuration
31
+
32
+ Four variables are required. Everything else has a default.
33
+
34
+ ```bash
35
+ ARMADA_URL=https://armada.example.com
36
+ ARMADA_QUEUE=marimohub
37
+ ARMADA_AGENT_IMAGE=registry.example.com/marimohub-kernel-agent:<version>
38
+ ARMADA_AGENT_TOKEN_SECRET=<output of openssl rand -hex 32, the same for every hub process>
39
+ ```
40
+
41
+ This submits to the `default` namespace, exposes each kernel through a NodePort, which is
42
+ plaintext HTTP on the cluster network, and sends no `Authorization` header to Armada. It
43
+ suits a local cluster. A local kind cluster with Armada is described in
44
+ [docs/CONTRIBUTING.md](https://github.com/G-Research/marimohub-compute-armada/blob/main/docs/CONTRIBUTING.md).
45
+
46
+ ### A production hub
47
+
48
+ ```bash
49
+ ARMADA_URL=https://armada.example.com
50
+ ARMADA_LOOKOUT_URL=https://lookout.example.com
51
+ ARMADA_AUTH_TOKEN_FILE=/var/run/secrets/armada/token
52
+ ARMADA_QUEUE=marimohub
53
+ ARMADA_NAMESPACE=marimohub-kernels
54
+ ARMADA_AGENT_IMAGE=registry.example.com/marimohub-kernel-agent:<version>
55
+ ARMADA_AGENT_TOKEN_SECRET=<output of openssl rand -hex 32, the same for every hub process>
56
+ ARMADA_IMAGE_PULL_SECRETS=registry-pull
57
+ ARMADA_RUN_AS_USER=1000
58
+ ARMADA_RUN_AS_GROUP=1000
59
+ ARMADA_FS_GROUP=1000
60
+ ARMADA_EXPOSE=ingress
61
+ ARMADA_INGRESS_ANNOTATIONS='{"nginx.ingress.kubernetes.io/proxy-read-timeout": "3600"}'
62
+ ARMADA_START_TIMEOUT_SECONDS=600
63
+ MARIMOHUB_SANDBOX_AUTH=on
64
+ ```
65
+
66
+ `ARMADA_LOOKOUT_URL` lets marimohub find running sessions again after a restart.
67
+ `MARIMOHUB_SANDBOX_AUTH=on` is marimohub's setting: without it, anyone who can reach a
68
+ kernel's address has a live editor in that pod. Before going live, read
69
+ [What Armada shows everyone](#what-armada-shows-everyone) with whoever sets these values.
70
+
71
+ ### Shared storage, and kernels without the namespace's identity
72
+
73
+ [`examples/kernel-pod.yaml`](../examples/kernel-pod.yaml), also in the npm package, mounts
74
+ network shares through a CSI driver with a Kerberos credential cache from a Secret, and
75
+ runs kernels under their own service account with no API token. A CSI driver (Container
76
+ Storage Interface) is a storage plugin installed on the cluster's worker nodes: a pod
77
+ names it in a `csi` volume, and the driver mounts the storage into the pod.
78
+ `kubectl get csidrivers` lists the drivers a cluster has, and every worker cluster Armada
79
+ can place a kernel on needs the same one. The example's comments cover the driver's
80
+ settings and whether the kernel or the driver authenticates to the shares.
81
+
82
+ ```bash
83
+ ARMADA_POD_TEMPLATE_FILE=/etc/marimohub/kernel-pod.yaml
84
+ ```
85
+
86
+ See [`ARMADA_POD_TEMPLATE_FILE`](#armada_pod_template_file).
87
+
88
+ ## Reference
89
+
90
+ | Variable | Required | Default |
91
+ | ------------------------------------ | -------- | ------------------------------------------------------------- |
92
+ | `ARMADA_URL` | yes | |
93
+ | `ARMADA_QUEUE` | yes | |
94
+ | `ARMADA_AGENT_IMAGE` | yes | |
95
+ | `ARMADA_AGENT_TOKEN_SECRET` | yes | |
96
+ | `ARMADA_LOOKOUT_URL` | no | unset: no reconciliation after a restart |
97
+ | `ARMADA_AUTH_USERNAME` | no | unset: no `Authorization` header |
98
+ | `ARMADA_AUTH_PASSWORD` | no | unset |
99
+ | `ARMADA_AUTH_TOKEN` | no | unset |
100
+ | `ARMADA_AUTH_TOKEN_FILE` | no | unset |
101
+ | `ARMADA_QUEUE_BY_USER` | no | `{}` |
102
+ | `ARMADA_QUEUE_BY_PROJECT` | no | `{}` |
103
+ | `ARMADA_NAMESPACE` | no | `default` |
104
+ | `ARMADA_PRIORITY_CLASS` | no | the Armada server's default |
105
+ | `MARIMOHUB_COMPUTE_IMAGE` | no | `ghcr.io/marimo-team/marimo-sandbox:latest` |
106
+ | `ARMADA_KERNEL_PORT` | no | `2718` |
107
+ | `ARMADA_AGENT_PORT` | no | `8718` |
108
+ | `ARMADA_EXPOSE` | no | `nodeport` |
109
+ | `ARMADA_INGRESS_TLS` | no | `true` |
110
+ | `ARMADA_INGRESS_CERT_NAME` | no | Armada's `<namespace>-` |
111
+ | `ARMADA_INGRESS_ANNOTATIONS` | no | `{}` |
112
+ | `ARMADA_IMAGE_PULL_SECRETS` | no | unset: anonymous pulls |
113
+ | `ARMADA_RUN_AS_USER` | no | unset: the cluster decides |
114
+ | `ARMADA_RUN_AS_GROUP` | no | unset |
115
+ | `ARMADA_FS_GROUP` | no | unset |
116
+ | `ARMADA_POD_LABELS` | no | `{}` |
117
+ | `ARMADA_POD_ANNOTATIONS` | no | `{}` |
118
+ | `ARMADA_POD_TEMPLATE_FILE` | no | unset: nothing added to the pod |
119
+ | `MARIMOHUB_COMPUTE_PROFILES` | no | unset: 1 CPU and `2Gi` per kernel |
120
+ | `MARIMOHUB_COMPUTE_APP_PROFILES` | no | the editing list |
121
+ | `ARMADA_GPU_NODE_SELECTORS` | no | unset: GPU profiles off |
122
+ | `MARIMOHUB_SURFACES` | no | `marimo`: the kernel only |
123
+ | `MARIMOHUB_SURFACE_VSCODE_PORT` | no | `8443` |
124
+ | `MARIMOHUB_SURFACE_OPENCODE_PORT` | no | `4096` |
125
+ | `ARMADA_START_TIMEOUT_SECONDS` | no | `300` |
126
+ | `ARMADA_KERNEL_MAX_LIFETIME_SECONDS` | no | twice marimohub's session lifetime; `86400` without marimohub |
127
+ | `ARMADA_COMMAND_MAX_SECONDS` | no | `21600` |
128
+ | `MARIMOHUB_COMPUTE_SANDBOX_HOSTNAME` | no | no effect with this adapter |
129
+
130
+ ### Armada and Lookout
131
+
132
+ #### `ARMADA_URL`
133
+
134
+ The base URL of Armada's REST API, `http` or `https`. Anything else stops startup.
135
+
136
+ #### `ARMADA_LOOKOUT_URL`
137
+
138
+ The base URL of Lookout, `http` or `https`. Armada's own API cannot list the jobs one
139
+ client owns, and Lookout aggregates jobs across every executor cluster, so with it set the
140
+ adapter advertises `listActive`: marimohub's reconciler then finds the sessions still
141
+ running after a restart. Without it, reconciliation is a clean no-op. It is required when
142
+ [`ARMADA_QUEUE_BY_USER` or `ARMADA_QUEUE_BY_PROJECT`](#armada_queue_by_user-and-armada_queue_by_project)
143
+ name a queue other than `ARMADA_QUEUE`.
144
+
145
+ #### `ARMADA_AUTH_USERNAME` and `ARMADA_AUTH_PASSWORD`
146
+
147
+ Basic auth to Armada and Lookout. Set both or neither.
148
+
149
+ #### `ARMADA_AUTH_TOKEN`
150
+
151
+ A bearer token, for example from OIDC, sent as is (trimmed) on every request.
152
+
153
+ #### `ARMADA_AUTH_TOKEN_FILE`
154
+
155
+ A file that holds a bearer token. It is read at startup, so a missing or empty file stops
156
+ marimohub, and again on every request, so a token that rotates on disk is picked up
157
+ without a restart. Prefer it for anything that rotates.
158
+
159
+ Configure at most one of the three mechanisms; two stop startup. With none, no
160
+ `Authorization` header is sent, which is what a server with `anonymousAuth: true` expects.
161
+ Auth credentials only ever travel in that header, never in a job submission.
162
+
163
+ ### Queues, namespace and priority
164
+
165
+ #### `ARMADA_QUEUE`
166
+
167
+ The Armada queue every sandbox goes to, unless its owner maps elsewhere. The queue must
168
+ exist, with permission for the configured credential to submit to it.
169
+
170
+ #### `ARMADA_QUEUE_BY_USER` and `ARMADA_QUEUE_BY_PROJECT`
171
+
172
+ JSON objects of marimohub user id, and project id, to queue name. Armada computes fair
173
+ share and priority per queue, so a queue per team or user is how tenants are told apart.
174
+ The user's entry wins over the project's. Every queue named must already exist.
175
+
176
+ ```bash
177
+ ARMADA_QUEUE_BY_PROJECT='{"proj-risk": "risk", "proj-research": "research"}'
178
+ ARMADA_QUEUE_BY_USER='{"user-alice": "research-priority"}'
179
+ ```
180
+
181
+ The owner places a sandbox that does not exist yet. For one that does, the queue it is in
182
+ is the answer, whatever the map says today: the adapter remembers it, learns it from
183
+ Lookout during `listActive`, and asks Lookout for a sandbox it has never seen, since
184
+ marimohub addresses sandboxes by id alone on several paths. So a map that names any queue
185
+ other than `ARMADA_QUEUE` requires `ARMADA_LOOKOUT_URL`, and a call Lookout cannot answer
186
+ fails rather than guesses; marimohub retries it.
187
+
188
+ #### `ARMADA_NAMESPACE`
189
+
190
+ The Kubernetes namespace the executor creates kernel pods in. Every Secret, ConfigMap and
191
+ service account the other settings name must be in this namespace.
192
+
193
+ #### `ARMADA_PRIORITY_CLASS`
194
+
195
+ An Armada priority class, not a Kubernetes one. It must be in the server's
196
+ `allowedPriorityClassNames`. Unset, jobs get the server's default, which ships as
197
+ `armada-default` and is not preemptible. Only choose one that is at least as protected:
198
+ a preempted kernel loses the session.
199
+
200
+ ### Images and the agent
201
+
202
+ #### `MARIMOHUB_COMPUTE_IMAGE`
203
+
204
+ marimohub's comma-separated list of kernel images. The first is the default, and a
205
+ kernel runs whichever image of the list marimohub asks for. Unset, it is
206
+ `ghcr.io/marimo-team/marimo-sandbox:latest`, marimo's own kernel image, public and amd64
207
+ only, with `latest-vscode`, `latest-opencode` and `latest-tools` variants for
208
+ [surfaces](#marimohub_surfaces). Set but empty stops startup. Use your own build of
209
+ marimohub's `examples/sandbox-image` when the nodes are arm64, cannot reach the internet,
210
+ or need a pinned marimo.
211
+
212
+ #### `ARMADA_AGENT_IMAGE`
213
+
214
+ The image of the kernel agent, which an init container copies into every kernel pod.
215
+ Required: no image is published. Build it from the npm package's `dist/agent` (see the
216
+ README's "From the npm package") and push it where the worker clusters pull from. Tag it
217
+ with the package version and upgrade both together: a newer adapter can call an agent
218
+ route an older agent lacks.
219
+
220
+ #### `ARMADA_AGENT_TOKEN_SECRET`
221
+
222
+ The key each sandbox's agent token is derived from, with the sandbox id. At least 32
223
+ characters; `openssl rand -hex 32` prints 64. Every marimohub process running the adapter
224
+ must have the same value, since marimohub stops and snapshots a session through whichever
225
+ process gets there, and a process with another secret is refused by the pod. Changing it
226
+ cuts every running session off from its agent, so their unsaved edits are lost: rotate it
227
+ when no sessions are running. Only a SHA-256 of each derived token reaches the pod spec.
228
+
229
+ #### `ARMADA_KERNEL_PORT`
230
+
231
+ The port marimo serves on inside the pod, 1 to 65535.
232
+
233
+ #### `ARMADA_AGENT_PORT`
234
+
235
+ The port the agent listens on inside the pod, 1 to 65535. It must differ from the kernel
236
+ port and from every surface port. It is exposed exactly as the kernel port is, so
237
+ whatever reaches one reaches the other.
238
+
239
+ ### Exposure
240
+
241
+ #### `ARMADA_EXPOSE`
242
+
243
+ How the kernel, agent and surface ports are reached from marimohub: `nodeport` or
244
+ `ingress`.
245
+
246
+ - `nodeport` asks Armada for a NodePort service. Each port is reached as
247
+ `hostIP:nodePort`, plaintext HTTP on the cluster's own network. It is what a local
248
+ cluster offers with nothing installed, and is enough when marimohub runs beside the
249
+ cluster in `proxy` exposure.
250
+ - `ingress` asks for an Ingress: one hostname per port, named by the executor's
251
+ `podDefaults.ingress.hostnameSuffix`, served by the cluster's ingress controller.
252
+ Armada's Ingress names no class, so the cluster needs a default IngressClass or an
253
+ annotation naming one. The executor's suffix must be a wildcard DNS record for the
254
+ controller.
255
+
256
+ The `ARMADA_INGRESS_*` variables only apply with `ingress`; set beside `nodeport`, they stop
257
+ startup.
258
+
259
+ #### `ARMADA_INGRESS_TLS`
260
+
261
+ `true` or `false`, for `ingress` only. With `true` the URLs are `https`, and the Ingress
262
+ names a TLS secret: Armada's `<namespace>-`, or
263
+ [`ARMADA_INGRESS_CERT_NAME`](#armada_ingress_cert_name), with the executor's
264
+ `certNameSuffix` appended. That secret must hold a wildcard certificate for
265
+ `*.<namespace>.<suffix>` that marimohub trusts (`NODE_EXTRA_CA_CERTS` for a private CA).
266
+ The controller forwards to the pod in plaintext either way.
267
+
268
+ #### `ARMADA_INGRESS_CERT_NAME`
269
+
270
+ The TLS secret name prefix, for `ingress` only, in place of Armada's `<namespace>-`.
271
+
272
+ #### `ARMADA_INGRESS_ANNOTATIONS`
273
+
274
+ A JSON object of annotations put on every job's Ingress, on top of the executor's
275
+ cluster-wide ones, for `ingress` only. A longer websocket read timeout, or a source
276
+ allowlist that lets only marimohub's egress address reach the agent, go here. Values must
277
+ be non-empty strings. They are public in Lookout: name a Kubernetes Secret
278
+ (`nginx.ingress.kubernetes.io/auth-secret`), never put a credential in one.
279
+
280
+ ```bash
281
+ ARMADA_INGRESS_ANNOTATIONS='{"nginx.ingress.kubernetes.io/proxy-read-timeout": "3600", "nginx.ingress.kubernetes.io/whitelist-source-range": "10.0.0.5/32"}'
282
+ ```
283
+
284
+ ### The kernel pod
285
+
286
+ #### `ARMADA_IMAGE_PULL_SECRETS`
287
+
288
+ Comma-separated names of Secrets in `ARMADA_NAMESPACE`, listed as `imagePullSecrets` on
289
+ every pod. The worker cluster pulls both the kernel and the agent image, never marimohub,
290
+ so a private registry needs a credential the cluster holds. A secret's registry host must
291
+ match the image's host exactly (`ghcr.io` is not `https://ghcr.io/v2/`); a mismatch shows
292
+ later as `ImagePullBackOff`, not at startup. Set but naming nothing stops startup.
293
+
294
+ #### `ARMADA_RUN_AS_USER`, `ARMADA_RUN_AS_GROUP` and `ARMADA_FS_GROUP`
295
+
296
+ Whole numbers, `0` or more, for the pod-level `securityContext` (`runAsUser`,
297
+ `runAsGroup`, `fsGroup`). For a cluster whose admission policy rejects a pod that does not
298
+ say who it runs as (`runAsUser not specified`). Pod-level, so the init container that
299
+ copies the agent runs with the same ids as the kernel. None has a default: which uid a
300
+ kernel image tolerates is a property of that image.
301
+
302
+ Set `ARMADA_FS_GROUP` with a non-root `ARMADA_RUN_AS_USER`. The agent's volume is an
303
+ `emptyDir`, mounted root-owned, and only `fsGroup` makes it writable for a non-root user.
304
+ Without it, the init container fails with a permission error before the kernel starts.
305
+
306
+ #### `ARMADA_POD_LABELS` and `ARMADA_POD_ANNOTATIONS`
307
+
308
+ JSON objects of fixed labels and annotations for every kernel pod, for cost allocation,
309
+ admission policies or `kubectl -l`. Armada copies them onto the pod; the pod's Service and
310
+ Ingress do not get them. Armada does not check them at submit, so the adapter applies
311
+ Kubernetes' rules at startup: an invalid key or label value stops startup. Keys starting
312
+ with `armada_` or `armadaproject.io/`, and `marimohub/sandbox`, are reserved. Both are
313
+ public in Lookout.
314
+
315
+ ```bash
316
+ ARMADA_POD_LABELS='{"team": "quant", "example.com/cost-center": "cc-1234"}'
317
+ ARMADA_POD_ANNOTATIONS='{"example.com/contact": "quant@example.com"}'
318
+ ```
319
+
320
+ #### `ARMADA_POD_TEMPLATE_FILE`
321
+
322
+ The path of a partial Pod manifest, YAML or JSON, read once at startup and added to every
323
+ kernel pod. A change to the file applies after a restart, to new sessions. The format is
324
+ the one marimohub's Kubernetes backend reads from
325
+ `MARIMOHUB_COMPUTE_KUBERNETES_POD_TEMPLATE_FILE`, and the kernel container may be named
326
+ `kernel` or `marimo`, so a template written for that backend works here unchanged as long
327
+ as it uses only these fields:
328
+
329
+ | Field | What it does |
330
+ | ----------------------------------- | ------------------------------------------------------------ |
331
+ | `spec.volumes` | Volumes of any source (CSI, Secret, ConfigMap, ...), by name |
332
+ | `spec.containers[0].volumeMounts` | `mountPath`, `readOnly`, `subPath(Expr)`, `mountPropagation` |
333
+ | `spec.containers[0].env` | A `value`, or `valueFrom` a Secret, ConfigMap or field |
334
+ | `spec.containers[0].envFrom` | Every key of a Secret or ConfigMap, by name |
335
+ | `spec.serviceAccountName` | The service account kernel pods run as |
336
+ | `spec.automountServiceAccountToken` | `false` keeps the API token out of the pod |
337
+ | `spec.enableServiceLinks` | `false` keeps the namespace's Service variables out |
338
+
339
+ A `resourceFieldRef` that names a container, in `env` or in a `downwardAPI` or `projected`
340
+ volume, must name the kernel container, as `kernel` or `marimo`. Either name is submitted
341
+ as `kernel`, the container's name in the pod, because the kubelet looks the name up
342
+ exactly. Any other name stops startup.
343
+
344
+ [`examples/kernel-pod.yaml`](../examples/kernel-pod.yaml) is a complete template: network
345
+ shares through a CSI driver, a Kerberos configuration and credential cache from Secrets,
346
+ and a service account of the kernels' own.
347
+
348
+ Kernel pods run user code. Without a template they run as the namespace's `default`
349
+ service account, with its API token mounted at
350
+ `/var/run/secrets/kubernetes.io/serviceaccount/`, so every notebook can read that token.
351
+ Set `automountServiceAccountToken: false` to stop that, and `serviceAccountName` to give
352
+ kernels an identity of their own, apart from the hub's. Armada does not check either at
353
+ submit: a service account that does not exist in `ARMADA_NAMESPACE` fails the pod, and the
354
+ session start fails with that event.
355
+
356
+ Mount a Secret that is renewed, like a credential cache, without `subPath`: Kubernetes
357
+ updates a Secret volume in place, but never a `subPath` mount of one.
358
+
359
+ The template adds to the pod and replaces nothing. Its volumes, mounts and variables come
360
+ after the adapter's own. Startup fails, naming `ARMADA_POD_TEMPLATE_FILE` and the field,
361
+ when the template:
362
+
363
+ - touches a part the adapter owns: the `mh-agent` volume, a mount at or under
364
+ `/mh-agent`, the `MH_AGENT_TOKEN_SHA256` variable, the container's `image`, `command`,
365
+ `args`, `ports` or `resources`, init containers, a second container, or the restart
366
+ policy, grace period or deadline;
367
+ - sets a field another variable sets: `imagePullSecrets`
368
+ ([`ARMADA_IMAGE_PULL_SECRETS`](#armada_image_pull_secrets)), `securityContext`
369
+ ([`ARMADA_RUN_AS_USER`](#armada_run_as_user-armada_run_as_group-and-armada_fs_group)),
370
+ `nodeSelector` ([`ARMADA_GPU_NODE_SELECTORS`](#armada_gpu_node_selectors)),
371
+ `priorityClassName` ([`ARMADA_PRIORITY_CLASS`](#armada_priority_class)), or pod
372
+ `metadata` ([`ARMADA_POD_LABELS`](#armada_pod_labels-and-armada_pod_annotations));
373
+ - uses any field not in the table above;
374
+ - mounts a volume it does not define, or has two volumes, mounts or variables with one
375
+ name;
376
+ - is not one YAML or JSON document.
377
+
378
+ YAML is read as 1.1, as Kubernetes manifests are, so `defaultMode: 0444` is octal. Quote a
379
+ value such as `"true"` or `"123"` that must stay a string.
380
+
381
+ The template is part of the submission, so everyone with Lookout access reads it, for good
382
+ (see [What Armada shows everyone](#what-armada-shows-everyone)). Name things in it: a Secret
383
+ by name, a key in it, a path. Never put a credential in it, above all not as an `env`
384
+ `value`, which is copied into the pod spec as written; take a secret value `valueFrom` a
385
+ `secretKeyRef` instead.
386
+
387
+ ### Compute profiles and GPUs
388
+
389
+ #### `MARIMOHUB_COMPUTE_PROFILES`
390
+
391
+ marimohub's list of compute profiles, which let editors pick hardware per notebook. A
392
+ profile's CPU and memory become the kernel container's requests and limits, which Armada
393
+ requires to be equal. So a kernel that outgrows its memory is OOM-killed, and every session
394
+ is charged its full profile against the queue's fair share, idle or not: offer a short list
395
+ of sizes rather than one large default. Without profiles, a kernel gets 1 CPU and `2Gi`.
396
+ Users can only pick when marimohub's `MARIMOHUB_COMPUTE_PROFILE_OVERRIDE=editors`.
397
+
398
+ ```bash
399
+ MARIMOHUB_COMPUTE_PROFILES='small:cpu=1;mem=4Gi,large:cpu=4;mem=32Gi,a100:cpu=8;mem=64Gi;gpu=A100'
400
+ MARIMOHUB_COMPUTE_PROFILE_OVERRIDE=editors
401
+ ARMADA_GPU_NODE_SELECTORS='{"A100": {"nvidia.com/gpu.product": "NVIDIA-A100-SXM4-80GB"}}'
402
+ ```
403
+
404
+ The adapter reads the list only for the GPU types it names, which
405
+ [`ARMADA_GPU_NODE_SELECTORS`](#armada_gpu_node_selectors) must map.
406
+
407
+ #### `MARIMOHUB_COMPUTE_APP_PROFILES`
408
+
409
+ marimohub's separate profile list for apps, in the same syntax. Without it, apps use the
410
+ editing list. Its GPU types must be mapped too.
411
+
412
+ #### `ARMADA_GPU_NODE_SELECTORS`
413
+
414
+ A JSON object of GPU type, as the profiles name it, to the `nodeSelector` that puts a pod
415
+ on a node with that GPU. A profile's GPU count becomes an `nvidia.com/gpu` request, and its
416
+ type becomes this selector. GPU profiles are only on when this is set: without it,
417
+ marimohub drops the GPUs from every profile and says so at startup. With it, a profile
418
+ whose type it does not map stops startup. Types are matched case-insensitively.
419
+
420
+ The label values are the cluster's (`kubectl get nodes -L nvidia.com/gpu.product`), and
421
+ every label used must be in each executor's `kubernetes.trackedNodeLabels`: the scheduler
422
+ only sees tracked labels, so a selector on any other stays queued for good.
423
+
424
+ ### Surfaces
425
+
426
+ #### `MARIMOHUB_SURFACES`
427
+
428
+ marimohub's comma-separated list of session surfaces: `marimo`, the kernel itself, plus
429
+ `vscode` or `opencode`. Each surface after the kernel needs a port of its own, which the
430
+ adapter declares on every pod so Armada exposes it like the kernel's; it then advertises
431
+ `multiPort`. A surface this adapter does not know stops startup. The kernel image must ship
432
+ the surface's binary (marimo's `latest-vscode` and `latest-opencode` images do). Surfaces
433
+ have no token: anyone who can reach a surface's address can use it, so enable them only
434
+ where the network keeps everyone but marimohub away from the kernel pods.
435
+
436
+ #### `MARIMOHUB_SURFACE_VSCODE_PORT`
437
+
438
+ The VS Code surface's port, when `vscode` is enabled. It may not be the kernel's or the
439
+ agent's port.
440
+
441
+ #### `MARIMOHUB_SURFACE_OPENCODE_PORT`
442
+
443
+ The OpenCode surface's port, when `opencode` is enabled. It may not be the kernel's or the
444
+ agent's port.
445
+
446
+ ### Time limits
447
+
448
+ #### `ARMADA_START_TIMEOUT_SECONDS`
449
+
450
+ How long a session start waits for its job to run, in whole seconds, at least 1. It covers
451
+ the time in the Armada queue, scheduling, the image pull and the agent's init container.
452
+ A start that runs out fails with the last event the job reported, which tells a job still
453
+ queued from a pod that will not start. Raise it on a busy cluster.
454
+
455
+ marimohub's own clocks sit around it:
456
+
457
+ - `MARIMOHUB_SANDBOX_STARTUP_TIMEOUT_SECONDS` (marimohub's default 120) starts only once
458
+ the pod answers, and covers installing the notebook's dependencies and starting marimo.
459
+ It does not extend the queue wait.
460
+ - The browser tab that started a session times out after 150 seconds while the server goes
461
+ on waiting. marimohub fixes that limit; no setting changes it.
462
+ - A tab that picks up a session already starting (a reload, a second tab) gives up after
463
+ `MARIMOHUB_SANDBOX_STARTUP_TIMEOUT_SECONDS` plus 30 seconds, so keep that at least as long
464
+ as a typical queue wait.
465
+ - marimohub marks a session still starting after 15 minutes as failed. Keep this value
466
+ plus `MARIMOHUB_SANDBOX_STARTUP_TIMEOUT_SECONDS` plus about 90 seconds below that.
467
+
468
+ #### `ARMADA_KERNEL_MAX_LIFETIME_SECONDS`
469
+
470
+ The hard cap on one kernel pod, in whole seconds, submitted as its `activeDeadlineSeconds`.
471
+ Kubernetes kills the pod at this deadline without a save, so it is only a backstop for a
472
+ pod marimohub has lost track of. Session length is marimohub's to decide, with its
473
+ `MARIMOHUB_SESSION_MAX_LIFETIME_SECONDS` (default `14400`, 4 hours): at that deadline
474
+ marimohub moves it 30 minutes on while editors are connected
475
+ (`MARIMOHUB_SESSION_LIFETIME_EXTENSION_SECONDS`), and otherwise saves the notebook and
476
+ ends the session.
477
+
478
+ Unset, the deadline is twice marimohub's session lifetime, 8 hours by default, as on
479
+ marimohub's own CoreWeave, E2B and W&B backends. A session still being edited at that
480
+ point is ended without a save, so raise `MARIMOHUB_SESSION_MAX_LIFETIME_SECONDS`, or set
481
+ this, if sessions run longer. A value below the session lifetime stops startup: it would
482
+ kill sessions before marimohub saves them. Without marimohub (the smoke test) the default
483
+ is `86400`. Every pod carries a deadline, because without one Armada gives it the server
484
+ default, 72 hours as shipped.
485
+
486
+ #### `ARMADA_COMMAND_MAX_SECONDS`
487
+
488
+ A backstop for one command marimohub runs in the kernel, in whole seconds; `0` turns it
489
+ off. Not a timeout: marimohub's own commands carry their own, and many deliberately carry
490
+ none, because unpacking a workspace takes minutes. This catches a command still running
491
+ hours after anyone expected it. Streams are exempt.
492
+
493
+ ### Ignored
494
+
495
+ #### `MARIMOHUB_COMPUTE_SANDBOX_HOSTNAME`
496
+
497
+ marimohub's setting for a public kernel hostname. It has no effect with this adapter:
498
+ Armada names each kernel's address, through the NodePort or the executor's ingress
499
+ hostname suffix.
500
+
501
+ ## What Armada shows everyone
502
+
503
+ Armada keeps every job submission and serves it back whole: its API returns the pod spec,
504
+ and Lookout shows the submission to everyone who can open the job. Once submitted, nothing
505
+ takes it back. Treat every value below as readable by everyone with Lookout access, for
506
+ good, and never put a credential in one. The two tables are the whole submission.
507
+
508
+ What configuration decides:
509
+
510
+ | In the submission | Comes from |
511
+ | ----------------------- | ------------------------------------------------------------------------------------------------------ |
512
+ | Queue and namespace | `ARMADA_QUEUE` (or the owner's entry in `ARMADA_QUEUE_BY_*`), `ARMADA_NAMESPACE` |
513
+ | Kernel and agent images | `MARIMOHUB_COMPUTE_IMAGE` (the one marimohub asks for), `ARMADA_AGENT_IMAGE` |
514
+ | Pod labels | `ARMADA_POD_LABELS` |
515
+ | Pod annotations | `ARMADA_POD_ANNOTATIONS` |
516
+ | Exposure | `ARMADA_EXPOSE`: a NodePort service or an Ingress |
517
+ | Ingress settings | `ARMADA_INGRESS_TLS`, `ARMADA_INGRESS_CERT_NAME`, `ARMADA_INGRESS_ANNOTATIONS` |
518
+ | Ports | `ARMADA_KERNEL_PORT`, `ARMADA_AGENT_PORT`, `MARIMOHUB_SURFACE_<ID>_PORT` |
519
+ | Surfaces | `MARIMOHUB_SURFACES`, which picks the surfaces whose ports are declared |
520
+ | Resources | The compute profile's CPU, memory and GPU count, else 1 CPU and `2Gi` |
521
+ | Node selector | `ARMADA_GPU_NODE_SELECTORS`, the entry for the profile's GPU type |
522
+ | Priority class | `ARMADA_PRIORITY_CLASS` |
523
+ | Pull secrets | `ARMADA_IMAGE_PULL_SECRETS`, the secret names only |
524
+ | Pod security context | `ARMADA_RUN_AS_USER`, `ARMADA_RUN_AS_GROUP`, `ARMADA_FS_GROUP` |
525
+ | Extra volumes | `ARMADA_POD_TEMPLATE_FILE`, `spec.volumes`, with every Secret by name |
526
+ | Kernel mounts and env | `ARMADA_POD_TEMPLATE_FILE`, the kernel container's `volumeMounts`, `env(From)` |
527
+ | Service account | `ARMADA_POD_TEMPLATE_FILE`, `serviceAccountName`, `automountServiceAccountToken`, `enableServiceLinks` |
528
+ | Deadline | `ARMADA_KERNEL_MAX_LIFETIME_SECONDS`, else twice marimohub's session lifetime |
529
+
530
+ What the adapter fixes:
531
+
532
+ | In the submission | Value |
533
+ | --------------------------------------- | ------------------------------------------------------------------------- |
534
+ | Job set id, client id, external job URI | The sandbox id |
535
+ | Annotations | `armadaproject.io/failFast: "true"`, `marimohub/sandbox` set to the queue |
536
+ | One pod environment variable | `MH_AGENT_TOKEN_SHA256`, the SHA-256 of the agent token, never the token |
537
+ | Pod lifecycle | Restart policy `Never`, a 30s grace period |
538
+ | Agent install | The `mh-agent` volume and the init container that copies the agent in |
539
+ | Init container resources | `100m` CPU and `64Mi` memory |
540
+ | Container commands | `/agent install …` and `/mh-agent/agent --port <ARMADA_AGENT_PORT>` |
541
+ | Ingress service | `useClusterIP: true` |
542
+
543
+ Every configured value is copied in as written. The adapter checks each one's shape, such
544
+ as a valid label key or a nonblank name, and nothing more: it cannot tell a credential from
545
+ any other string. The free-form values are where one is most likely to be pasted:
546
+ `ARMADA_POD_ANNOTATIONS`, `ARMADA_INGRESS_ANNOTATIONS`, the `env` values and CSI
547
+ `volumeAttributes` in `ARMADA_POD_TEMPLATE_FILE`, and `ARMADA_POD_LABELS` within the label
548
+ character set. Some ingress annotations invite a credential: an ingress-nginx
549
+ `configuration-snippet` that sets an `Authorization` header, or an `auth-url` with a key in
550
+ its query string. Name a Kubernetes Secret instead (`nginx.ingress.kubernetes.io/auth-secret`),
551
+ the way `ARMADA_IMAGE_PULL_SECRETS` does for registries.
552
+
553
+ `ARMADA_POD_TEMPLATE_FILE` is the one setting that puts environment variables on the pod,
554
+ and its whole file is in the spec. A variable's `value` is copied as written, so it is for
555
+ paths and names such as `KRB5CCNAME`. A secret goes in a Kubernetes Secret, which the
556
+ template names (`valueFrom.secretKeyRef`, `envFrom.secretRef`, a `secret` volume), and only
557
+ the name reaches the submission. `ARMADA_AGENT_TOKEN_SECRET`, the agent tokens and the
558
+ `ARMADA_AUTH_*` credentials never enter a submission.
559
+
560
+ Notebook users cannot put anything in a submission: they pick a compute profile and an
561
+ image from lists the operator wrote. The credentials they give marimohub for an
562
+ integration, such as a database password or a cloud key, become the session's environment,
563
+ which the adapter hands to the pod through the agent, as `export` statements in front of
564
+ each command. So those credentials:
565
+
566
+ - stay out of the submission and out of Lookout;
567
+ - cross the cluster network as plain HTTP, readable by anyone who can watch it. The agent
568
+ speaks only HTTP, so under `ARMADA_EXPOSE=nodeport` the whole way is plaintext, and
569
+ under `ingress` with TLS only the hop from marimohub to the ingress controller is
570
+ encrypted: the controller forwards to the pod in plaintext;
571
+ - are visible to every process in the kernel container, as on any marimohub backend;
572
+ - never appear in the adapter's own error messages. Those name the command marimohub
573
+ asked for at most, never the `export` statements put in front of it, so a credential
574
+ written into the command itself would still show.
575
+
576
+ What a notebook prints stays out of Lookout as well. The kernel's output goes to a log file
577
+ inside the pod and command output goes back over the agent, so the container log, which is
578
+ what Lookout's log view shows, holds only the agent's own lines.
579
+
580
+ Before a deployment goes live, walk whoever sets these variables through this section. The
581
+ adapter keeps the credentials it handles out of the submission; it cannot stop a person
582
+ typing one into a variable that is public by design.
@@ -0,0 +1,79 @@
1
+ # A pod template for ARMADA_POD_TEMPLATE_FILE (docs/CONFIGURATION.md).
2
+ #
3
+ # Gives every kernel read-only network shares through a CSI driver, authenticated with a
4
+ # Kerberos credential cache, and runs kernels under a service account of their own with
5
+ # no Kubernetes API token in the pod.
6
+ #
7
+ # A CSI driver (Container Storage Interface) is a storage plugin a cluster administrator
8
+ # installs on the worker nodes. A pod names the driver in a `csi` volume, and the driver
9
+ # mounts the storage it serves, here network file shares, into the pod. Every worker
10
+ # cluster Armada can place a kernel on needs the same driver. List the drivers a cluster
11
+ # has with `kubectl get csidrivers`.
12
+ #
13
+ # Before using it, create in ARMADA_NAMESPACE:
14
+ # - the service account named in serviceAccountName;
15
+ # - a Secret with your krb5.conf under the key krb5.conf;
16
+ # - a Secret with the credential cache under the key ccache, renewed by whatever renews
17
+ # tickets today.
18
+ # Then replace the names below with yours.
19
+ #
20
+ # This whole file is part of every Armada job, which Lookout shows to everyone with access.
21
+ # It names Secrets and paths; it must never hold a credential.
22
+ apiVersion: v1
23
+ kind: Pod
24
+ spec:
25
+ # Kernels run user code: keep the namespace's token out, and give them their own identity.
26
+ serviceAccountName: marimohub-kernel
27
+ automountServiceAccountToken: false
28
+ containers:
29
+ # `marimo`, as marimohub's Kubernetes backend names it, or `kernel`: both mean the kernel
30
+ # container.
31
+ - name: marimo
32
+ env:
33
+ # Paths, not secrets: a literal value is copied into the job as written.
34
+ - name: KRB5CCNAME
35
+ value: FILE:/var/run/krb5/ccache
36
+ - name: KRB5_CONFIG
37
+ value: /etc/krb5/krb5.conf
38
+ volumeMounts:
39
+ - name: shares
40
+ mountPath: /mnt/shares
41
+ readOnly: true
42
+ # The CSI driver mounts each share after the pod starts; this makes them visible.
43
+ mountPropagation: HostToContainer
44
+ - name: krb5-config
45
+ mountPath: /etc/krb5/krb5.conf
46
+ subPath: krb5.conf
47
+ readOnly: true
48
+ # No subPath here: Kubernetes updates a Secret volume when the Secret changes, but
49
+ # never a subPath mount of one, and the credential cache is renewed.
50
+ - name: krb5-ccache
51
+ mountPath: /var/run/krb5
52
+ readOnly: true
53
+ volumes:
54
+ - name: shares
55
+ csi:
56
+ # The driver's name, as `kubectl get csidrivers` lists it.
57
+ driver: <your-csi-driver>
58
+ readOnly: true
59
+ # Settings the driver defines, such as which shares to mount. They are strings,
60
+ # and public in Lookout like the rest of this file. The driver's documentation
61
+ # lists them; leave this out if it needs none.
62
+ # volumeAttributes:
63
+ # shares: research
64
+ #
65
+ # Who authenticates to the shares depends on the driver:
66
+ # - In the kernel: the driver mounts the shares, and each access uses the
67
+ # credential cache that KRB5CCNAME above points at. This file is written for
68
+ # that case.
69
+ # - In the driver: it needs the credential when it mounts. Name the Secret here.
70
+ # Kubernetes hands it to the driver on the node, never to the kernel.
71
+ # nodePublishSecretRef:
72
+ # name: kernel-krb5-ccache
73
+ - name: krb5-config
74
+ secret:
75
+ secretName: kernel-krb5-config
76
+ defaultMode: 0444
77
+ - name: krb5-ccache
78
+ secret:
79
+ secretName: kernel-krb5-ccache