lastlight-core 0.21.11 → 0.21.13
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/deploy/k8s/README.md +111 -34
- package/deploy/k8s/architecture.md +199 -0
- package/deploy/k8s/configmap.yaml +14 -3
- package/deploy/k8s/harness-deployment.yaml +111 -0
- package/deploy/k8s/kustomization.yaml +10 -8
- package/deploy/k8s/sandbox-namespace.yaml +14 -0
- package/deploy/k8s/sandbox-quota.yaml +37 -0
- package/deploy/k8s/sandbox-rbac.yaml +60 -0
- package/dist/admin/routes.js +66 -10
- package/dist/admin/routes.js.map +1 -1
- package/dist/config/config.d.ts +36 -0
- package/dist/config/config.js +101 -3
- package/dist/config/config.js.map +1 -1
- package/dist/cron/review-discovery.d.ts +54 -0
- package/dist/cron/review-discovery.js +70 -0
- package/dist/cron/review-discovery.js.map +1 -0
- package/dist/engine/executors/orchestrator.js +124 -58
- package/dist/engine/executors/orchestrator.js.map +1 -1
- package/dist/engine/github/github.d.ts +8 -0
- package/dist/engine/github/github.js +14 -0
- package/dist/engine/github/github.js.map +1 -1
- package/dist/engine/github/profiles.d.ts +12 -1
- package/dist/engine/github/profiles.js +33 -1
- package/dist/engine/github/profiles.js.map +1 -1
- package/dist/index.js +55 -14
- package/dist/index.js.map +1 -1
- package/dist/sandbox/artifact-backend.d.ts +40 -0
- package/dist/sandbox/artifact-backend.js +67 -0
- package/dist/sandbox/artifact-backend.js.map +1 -0
- package/dist/sandbox/artifact-store.d.ts +55 -0
- package/dist/sandbox/artifact-store.js +203 -0
- package/dist/sandbox/artifact-store.js.map +1 -0
- package/dist/sandbox/docker.d.ts +2 -1
- package/dist/sandbox/docker.js +3 -3
- package/dist/sandbox/docker.js.map +1 -1
- package/dist/sandbox/k8s/agent-context-registry.d.ts +25 -0
- package/dist/sandbox/k8s/agent-context-registry.js +45 -0
- package/dist/sandbox/k8s/agent-context-registry.js.map +1 -0
- package/dist/sandbox/k8s/agent-context-route.d.ts +13 -0
- package/dist/sandbox/k8s/agent-context-route.js +21 -0
- package/dist/sandbox/k8s/agent-context-route.js.map +1 -0
- package/dist/sandbox/k8s/artifact-upload-route.d.ts +12 -0
- package/dist/sandbox/k8s/artifact-upload-route.js +40 -0
- package/dist/sandbox/k8s/artifact-upload-route.js.map +1 -0
- package/dist/sandbox/k8s/client.d.ts +22 -0
- package/dist/sandbox/k8s/client.js +35 -0
- package/dist/sandbox/k8s/client.js.map +1 -0
- package/dist/sandbox/k8s/egress-apply.d.ts +14 -0
- package/dist/sandbox/k8s/egress-apply.js +44 -0
- package/dist/sandbox/k8s/egress-apply.js.map +1 -0
- package/dist/sandbox/k8s/egress-ensurer.d.ts +37 -0
- package/dist/sandbox/k8s/egress-ensurer.js +54 -0
- package/dist/sandbox/k8s/egress-ensurer.js.map +1 -0
- package/dist/sandbox/k8s/egress-policy.d.ts +112 -0
- package/dist/sandbox/k8s/egress-policy.js +118 -0
- package/dist/sandbox/k8s/egress-policy.js.map +1 -0
- package/dist/sandbox/k8s/init-agent-context.d.ts +20 -0
- package/dist/sandbox/k8s/init-agent-context.js +35 -0
- package/dist/sandbox/k8s/init-agent-context.js.map +1 -0
- package/dist/sandbox/k8s/init-clone.d.ts +53 -0
- package/dist/sandbox/k8s/init-clone.js +114 -0
- package/dist/sandbox/k8s/init-clone.js.map +1 -0
- package/dist/sandbox/k8s/init-skills.d.ts +13 -0
- package/dist/sandbox/k8s/init-skills.js +28 -0
- package/dist/sandbox/k8s/init-skills.js.map +1 -0
- package/dist/sandbox/k8s/kubernetes-sandbox.d.ts +179 -0
- package/dist/sandbox/k8s/kubernetes-sandbox.js +418 -0
- package/dist/sandbox/k8s/kubernetes-sandbox.js.map +1 -0
- package/dist/sandbox/k8s/log-stream.d.ts +4 -0
- package/dist/sandbox/k8s/log-stream.js +43 -0
- package/dist/sandbox/k8s/log-stream.js.map +1 -0
- package/dist/sandbox/k8s/naming.d.ts +19 -0
- package/dist/sandbox/k8s/naming.js +35 -0
- package/dist/sandbox/k8s/naming.js.map +1 -0
- package/dist/sandbox/k8s/pod-lifecycle.d.ts +40 -0
- package/dist/sandbox/k8s/pod-lifecycle.js +151 -0
- package/dist/sandbox/k8s/pod-lifecycle.js.map +1 -0
- package/dist/sandbox/k8s/pod-status.d.ts +46 -0
- package/dist/sandbox/k8s/pod-status.js +83 -0
- package/dist/sandbox/k8s/pod-status.js.map +1 -0
- package/dist/sandbox/k8s/pod.d.ts +79 -0
- package/dist/sandbox/k8s/pod.js +115 -0
- package/dist/sandbox/k8s/pod.js.map +1 -0
- package/dist/sandbox/k8s/pvc.d.ts +20 -0
- package/dist/sandbox/k8s/pvc.js +26 -0
- package/dist/sandbox/k8s/pvc.js.map +1 -0
- package/dist/sandbox/k8s/quota.d.ts +34 -0
- package/dist/sandbox/k8s/quota.js +52 -0
- package/dist/sandbox/k8s/quota.js.map +1 -0
- package/dist/sandbox/k8s/reclaim.d.ts +50 -0
- package/dist/sandbox/k8s/reclaim.js +141 -0
- package/dist/sandbox/k8s/reclaim.js.map +1 -0
- package/dist/sandbox/k8s/resource-name.d.ts +33 -0
- package/dist/sandbox/k8s/resource-name.js +49 -0
- package/dist/sandbox/k8s/resource-name.js.map +1 -0
- package/dist/sandbox/k8s/run-agent-script.d.ts +60 -0
- package/dist/sandbox/k8s/run-agent-script.js +48 -0
- package/dist/sandbox/k8s/run-agent-script.js.map +1 -0
- package/dist/sandbox/k8s/run-id.d.ts +23 -0
- package/dist/sandbox/k8s/run-id.js +32 -0
- package/dist/sandbox/k8s/run-id.js.map +1 -0
- package/dist/sandbox/k8s/run-secrets.d.ts +75 -0
- package/dist/sandbox/k8s/run-secrets.js +115 -0
- package/dist/sandbox/k8s/run-secrets.js.map +1 -0
- package/dist/sandbox/k8s/secret.d.ts +20 -0
- package/dist/sandbox/k8s/secret.js +38 -0
- package/dist/sandbox/k8s/secret.js.map +1 -0
- package/dist/sandbox/k8s/skill-bundle-route.d.ts +10 -0
- package/dist/sandbox/k8s/skill-bundle-route.js +18 -0
- package/dist/sandbox/k8s/skill-bundle-route.js.map +1 -0
- package/dist/sandbox/k8s/skill-bundle.d.ts +36 -0
- package/dist/sandbox/k8s/skill-bundle.js +85 -0
- package/dist/sandbox/k8s/skill-bundle.js.map +1 -0
- package/dist/sandbox/k8s/sweep.d.ts +47 -0
- package/dist/sandbox/k8s/sweep.js +29 -0
- package/dist/sandbox/k8s/sweep.js.map +1 -0
- package/dist/sandbox/k8s/workspace-provisioner.d.ts +51 -0
- package/dist/sandbox/k8s/workspace-provisioner.js +64 -0
- package/dist/sandbox/k8s/workspace-provisioner.js.map +1 -0
- package/dist/sandbox/sandbox.d.ts +20 -1
- package/dist/sandbox/sandbox.js +22 -1
- package/dist/sandbox/sandbox.js.map +1 -1
- package/dist/state/workflow-run-store.d.ts +11 -0
- package/dist/state/workflow-run-store.js +19 -0
- package/dist/state/workflow-run-store.js.map +1 -1
- package/dist/workflows/admission.d.ts +19 -0
- package/dist/workflows/admission.js +81 -13
- package/dist/workflows/admission.js.map +1 -1
- package/dist/workflows/handlers/post-review.d.ts +21 -0
- package/dist/workflows/handlers/post-review.js +56 -13
- package/dist/workflows/handlers/post-review.js.map +1 -1
- package/dist/workflows/resume.js +6 -0
- package/dist/workflows/resume.js.map +1 -1
- package/dist/workflows/runner.d.ts +11 -2
- package/dist/workflows/runner.js +73 -15
- package/dist/workflows/runner.js.map +1 -1
- package/dist/workflows/simple.d.ts +13 -1
- package/dist/workflows/simple.js +46 -4
- package/dist/workflows/simple.js.map +1 -1
- package/package.json +21 -20
- package/skills/issue-triage/SKILL.md +17 -0
- package/workflows/cron-review.yaml +14 -1
- package/workflows/dependabot-pr-merge.yaml +14 -9
- package/workflows/issue-triage.yaml +6 -0
- package/workflows/prompts/dependabot-pr-merge.md +53 -11
- package/deploy/k8s/deployment.yaml +0 -63
- package/deploy/k8s/generic-device-plugin.yaml +0 -63
- package/deploy/k8s/namespace.yaml +0 -10
- package/deploy/k8s/pvc.yaml +0 -13
- package/deploy/k8s/service.yaml +0 -12
package/deploy/k8s/README.md
CHANGED
|
@@ -1,35 +1,86 @@
|
|
|
1
|
-
# Running Last Light on Kubernetes (
|
|
1
|
+
# Running Last Light on Kubernetes (`sandbox.backend: kubernetes`)
|
|
2
2
|
|
|
3
|
-
A complete, `kubectl apply -k`-able example for the **
|
|
4
|
-
backend
|
|
5
|
-
|
|
3
|
+
A complete, `kubectl apply -k`-able example for the **kubernetes sandbox
|
|
4
|
+
backend**: each workflow phase runs as its own Pod in a dedicated namespace,
|
|
5
|
+
instead of in a QEMU micro-VM inside the harness process (the default
|
|
6
|
+
`gondolin` backend — see the older `gondolin`/`docker`-oriented deployment
|
|
7
|
+
guidance if that's what you're running instead). The harness is a Kubernetes
|
|
8
|
+
client (`@kubernetes/client-node`); it creates a Pod per phase, streams its
|
|
9
|
+
JSONL stdout, and reaps it. See the [sandbox spec](../../spec/09-sandbox.md)
|
|
10
|
+
(the `kubernetes` backend section) for the full architecture and rationale, and
|
|
11
|
+
[`architecture.md`](./architecture.md) for the same in diagrams (topology, pod
|
|
12
|
+
lifecycle, and the domain-model information flow).
|
|
6
13
|
|
|
7
|
-
##
|
|
14
|
+
## Requirements / dependencies matrix
|
|
8
15
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
Everything the kubernetes sandbox backend needs from the cluster, and what
|
|
17
|
+
happens if a piece is missing:
|
|
18
|
+
|
|
19
|
+
| Requirement | Why | If missing |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| **`@kubernetes/client-node@1.4.0`** (bundled in the harness image) | The harness's only k8s client. In-cluster it uses `KubeConfig.loadFromCluster()` — the mounted ServiceAccount token, nothing to configure. | N/A — ships in the image. |
|
|
22
|
+
| **RBAC `Role` + `RoleBinding`** (`sandbox-rbac.yaml`) | Least-privilege grant of exactly the verbs the harness calls (pod create/list/delete, pods/status get, pods/log get, secret create/patch/delete, PVC create/get/list/delete, CiliumNetworkPolicy create/get/update). | Every sandboxed phase fails outright — the harness can't create the Pod. Not gracefully degradable; this is a hard requirement. |
|
|
23
|
+
| **`lastlight-sandboxes` namespace at PSA `restricted`** (`sandbox-namespace.yaml`) | Dedicated namespace: RBAC blast radius, one `ResourceQuota` ceiling, a namespace of uniformly-untrusted pods for network policy to select. The sandbox pod spec is restricted-compliant by construction (`runAsNonRoot`, `seccompProfile: RuntimeDefault`, `allowPrivilegeEscalation: false`, all capabilities dropped). | Pods can run in a laxer-PSA namespace, but you lose the admission-time guarantee that a future change can't accidentally request a broader security context. |
|
|
24
|
+
| **Pod-count `ResourceQuota` + `LimitRange`** (`sandbox-quota.yaml`) | The cluster — not an app-level `maxWorkflows` counter — is the single concurrency authority. A `403 exceeded quota` is treated as backpressure: the run stays queued and retries as capacity frees. The `LimitRange` supplies the per-pod requests/limits the (deliberately resource-less) sandbox pod spec needs to be schedulable, since the quota is pod-count only. | Without the quota, concurrency is unbounded (bounded only by a large sanity-fuse backstop in the app). Without the `LimitRange`, sandbox pods have no resource requests and the scheduler can't bin-pack them sensibly. |
|
|
25
|
+
| **RWO block/local `StorageClass`** (NOT NFS) | Two independent uses: the harness's own `lastlight-data` PVC holds the embedded SQLite DB (file locking needs a real block device); each `(repo, PR)` gets a reused workspace PVC (`ws-<owner>-<repo>-pr<N>`) that the harness's `WorkspaceProvisioner` creates on demand — RWO because only one sandbox pod per PR runs at a time. | SQLite locking is unsafe on NFS; a shared/RWX class doesn't buy anything here since sandbox pods never share a workspace concurrently. |
|
|
26
|
+
| **Reachable CoreDNS/kube-dns** | Every sandbox pod and the harness pod need cluster DNS to resolve Service names (the harness Service, `kubernetes.default.svc`) and, under Cilium, external FQDNs via the DNS proxy (below). | Pod-to-Service and FQDN-based egress resolution both break. |
|
|
27
|
+
| **Cilium, for *enforced* egress** — **current mechanism, not a permanent hard requirement** | The harness renders a `CiliumNetworkPolicy` pair (`strict`/`open`) per namespace from the same allowlist (`egress-allowlist.ts`) every backend uses, selected by a per-pod label. Cilium's DNS proxy is what makes the FQDN allowlist bite on IPs, closing the private-CIDR SSRF gap other backends can't close. | **Graceful degrade, not a hard failure.** On a non-Cilium cluster (or one where the harness SA lacks the CNP verb), applying the policy 403s, the harness logs one warning per namespace, and the run proceeds on the cluster's default network posture — sandbox pods get no allowlist enforcement, but nothing else breaks. A CNI-agnostic egress path (plain `NetworkPolicy` plus an out-of-band forward proxy, or a Gateway API implementation) is a known, tracked follow-up — Cilium is today's implementation, not a design commitment. |
|
|
28
|
+
| **Harness Service reachability from sandbox pods** | Sandbox pods reach the harness over three internal HTTP routes: `GET /internal/skill-bundle` (per-phase skill bundle, initContainer), `GET /internal/agent-context` (AGENTS.md context, initContainer), and `POST /internal/sandbox-artifacts` (build-artifact POST-back). All three are scoped-token-authenticated. `harness-deployment.yaml` ships a `Service` at `lastlight.lastlight.svc.cluster.local:8644` — exactly `sandbox.kubernetes.harnessEndpoint`'s default — so this works unmodified as long as you keep the harness namespace/name/pod-labels as shipped. | If the Service is missing, unreachable, or its DNS name doesn't match `sandbox.kubernetes.harnessEndpoint`, every phase's initContainer fails to fetch its skill bundle and the pod never starts the agent. |
|
|
29
|
+
| **Sandbox image pull** | `sandbox.kubernetes.image` (default `ghcr.io/nearform/lastlight-sandbox:latest`) is pulled once per sandbox pod. GHCR serves it publicly/anonymously by default. | On a cluster with restricted internet egress from nodes, or if you push the image to a private registry, add an `imagePullSecret` and reference it from the sandbox pod spec's `imagePullSecrets` (a harness config surface, not shipped here — see `sandbox.kubernetes` in `apps/server/src/config/config.ts` for what's currently configurable, or mirror the image into a registry your nodes can already pull from). |
|
|
30
|
+
| **Harness pod API-server egress, if the harness namespace is itself Cilium-selected** | The harness needs no special network rule to reach `kube-apiserver` under Cilium's *default-allow* posture — this only bites if your cluster (or a cluster-wide default-deny policy) also constrains the harness pod's own egress. | If the harness namespace has a default-deny egress policy, add an explicit allow rule from the harness pod to the API server (typically `kubernetes.default.svc.cluster.local:443`, i.e. the `kube-system`/default `kubernetes` Service) and to DNS — this manifest set does not ship one, since it's specific to whether/how your cluster's default network policy applies to the harness namespace. |
|
|
13
31
|
|
|
14
32
|
## What this set contains
|
|
15
33
|
|
|
16
|
-
- `namespace.yaml` — the `lastlight` namespace
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
- `deployment.yaml
|
|
34
|
+
- `sandbox-namespace.yaml` — the `lastlight-sandboxes` namespace, PSA `restricted`.
|
|
35
|
+
- `sandbox-quota.yaml` — `ResourceQuota` (pod-count) + `LimitRange` (default
|
|
36
|
+
per-pod cpu/memory requests+limits).
|
|
37
|
+
- `sandbox-rbac.yaml` — the harness `ServiceAccount`, the namespaced `Role`
|
|
38
|
+
(exactly the verbs the harness calls), and the `RoleBinding`.
|
|
39
|
+
- `harness-deployment.yaml` — the `lastlight` namespace, its data `PersistentVolumeClaim`,
|
|
40
|
+
the harness `Deployment` (SA-attached, no KVM/no privileged, `/health`
|
|
41
|
+
probes), and the `Service` sandbox pods reach it through.
|
|
42
|
+
- `configmap.yaml` — the config overlay: `managedRepos` + `sandbox.backend:
|
|
43
|
+
kubernetes` + `sandbox.kubernetes.*`.
|
|
44
|
+
- `kustomization.yaml` — ties the above together for `kubectl apply -k`.
|
|
45
|
+
|
|
46
|
+
Not shipped, by design:
|
|
47
|
+
|
|
48
|
+
- **The `lastlight-secrets` Secret** (GitHub App PEM + `.env`) — credentials,
|
|
49
|
+
created out-of-band (below).
|
|
50
|
+
- **`CiliumNetworkPolicy` objects** — the harness renders and applies these
|
|
51
|
+
itself at runtime from `egress-allowlist.ts`, once the RBAC verb is granted;
|
|
52
|
+
there's nothing to hand-author or keep in sync here.
|
|
53
|
+
- **Ingress/Gateway** for the GitHub webhook — cluster-specific; add your own
|
|
54
|
+
Ingress/Gateway/HTTPRoute fronting the `lastlight` Service on port 8644.
|
|
55
|
+
- **`imagePullSecret`** — only needed for a private registry; see the matrix
|
|
56
|
+
above.
|
|
57
|
+
|
|
58
|
+
## The values you edit
|
|
22
59
|
|
|
23
|
-
|
|
60
|
+
| Value | Where | Default | Edit when |
|
|
61
|
+
|---|---|---|---|
|
|
62
|
+
| Sandbox namespace | `sandbox-namespace.yaml`, `sandbox-rbac.yaml` (Role/RoleBinding namespace), `configmap.yaml` (`sandbox.kubernetes.namespace`) | `lastlight-sandboxes` | You need a non-default name — keep all three in sync, it's the one name code and manifests share. |
|
|
63
|
+
| Harness namespace/name/pod-labels | `harness-deployment.yaml`, `sandbox-rbac.yaml` (`ServiceAccount`/`RoleBinding` subject namespace) | `lastlight` namespace, `lastlight` Deployment/Service, `app.kubernetes.io/name: lastlight` pod label | You relabel/rename the harness — then also set `sandbox.kubernetes.harnessNamespace`/`harnessEndpoint`/`harnessPodLabels` (or the `LASTLIGHT_K8S_HARNESS_*` env vars) to match, or the skill-fetch egress rule and DNS name stop resolving. |
|
|
64
|
+
| `storageClassName` | `configmap.yaml` (`sandbox.kubernetes.storageClassName`) for the per-PR workspace PVCs; `harness-deployment.yaml`'s PVC (commented out) for the harness's own data PVC | empty (cluster default) | Your cluster's default `StorageClass` isn't RWO block/local (e.g. it's NFS-backed) — set an explicit block/local class in both places. |
|
|
65
|
+
| Sandbox image tag | `configmap.yaml` (`sandbox.kubernetes.image`) | `ghcr.io/nearform/lastlight-sandbox:latest` | Pin to a release tag for reproducibility. |
|
|
66
|
+
| Harness agent image tag | `harness-deployment.yaml` (`spec.template.spec.containers[0].image`) | `ghcr.io/nearform/lastlight-agent:latest` | Same — pin once you cut a deploy. |
|
|
67
|
+
| `ResourceQuota` pod count | `sandbox-quota.yaml` (`spec.hard.pods`) | `"4"` | Scale concurrency to your cluster's real capacity — this is the single concurrency knob (design §8), not an app-level setting. |
|
|
68
|
+
| `managedRepos` | `configmap.yaml` | placeholder `your-org/your-repo` | Always — the bot won't act on any repo until this (or the GitHub App's installation-repo list) is set. |
|
|
69
|
+
| `workspaceSize` | `configmap.yaml` (`sandbox.kubernetes.workspaceSize`) | `5Gi` | Your repos' checkouts (+ `node_modules` etc.) don't fit in 5Gi. |
|
|
24
70
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
71
|
+
Full env-var surface (each overrides the matching `sandbox.kubernetes.*` YAML
|
|
72
|
+
key; see `resolveKubernetesConfig` in `apps/server/src/config/config.ts`):
|
|
73
|
+
|
|
74
|
+
| Env var | Overrides |
|
|
75
|
+
|---|---|
|
|
76
|
+
| `LASTLIGHT_K8S_NAMESPACE` | `sandbox.kubernetes.namespace` |
|
|
77
|
+
| `K8S_SANDBOX_IMAGE` | `sandbox.kubernetes.image` |
|
|
78
|
+
| `LASTLIGHT_K8S_STORAGE_CLASS` | `sandbox.kubernetes.storageClassName` |
|
|
79
|
+
| `LASTLIGHT_K8S_WORKSPACE_SIZE` | `sandbox.kubernetes.workspaceSize` |
|
|
80
|
+
| `LASTLIGHT_K8S_RUN_AS_USER` | `sandbox.kubernetes.runAsUser` |
|
|
81
|
+
| `LASTLIGHT_K8S_HARNESS_ENDPOINT` | `sandbox.kubernetes.harnessEndpoint` |
|
|
82
|
+
| `LASTLIGHT_K8S_HARNESS_NAMESPACE` | `sandbox.kubernetes.harnessNamespace` |
|
|
83
|
+
| `LASTLIGHT_K8S_HARNESS_POD_LABELS` | `sandbox.kubernetes.harnessPodLabels` (`k=v,k=v` form) |
|
|
33
84
|
|
|
34
85
|
## Create the Secret
|
|
35
86
|
|
|
@@ -40,8 +91,25 @@ kubectl create secret generic lastlight-secrets \
|
|
|
40
91
|
--from-file=app.pem=instance/secrets/app.pem
|
|
41
92
|
```
|
|
42
93
|
|
|
43
|
-
(The namespace must exist first
|
|
44
|
-
|
|
94
|
+
(The `lastlight` namespace must exist first — apply the rest of the set, or
|
|
95
|
+
just `kubectl apply -f harness-deployment.yaml`, then create the Secret; the
|
|
96
|
+
harness pod stays `Pending`/`CreateContainerConfigError` until it exists.)
|
|
97
|
+
|
|
98
|
+
## Apply order
|
|
99
|
+
|
|
100
|
+
`kubectl apply -k .` applies everything in one pass — Kubernetes/kustomize
|
|
101
|
+
handle the namespace-before-namespaced-object ordering. If you're applying
|
|
102
|
+
files individually instead:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
kubectl apply -f sandbox-namespace.yaml # namespace must exist first
|
|
106
|
+
kubectl apply -f harness-deployment.yaml # creates the `lastlight` namespace too
|
|
107
|
+
kubectl apply -f sandbox-rbac.yaml # SA + Role + RoleBinding
|
|
108
|
+
kubectl apply -f sandbox-quota.yaml # ResourceQuota + LimitRange
|
|
109
|
+
kubectl apply -f configmap.yaml
|
|
110
|
+
# then create the Secret (above), then:
|
|
111
|
+
kubectl rollout status deployment/lastlight -n lastlight
|
|
112
|
+
```
|
|
45
113
|
|
|
46
114
|
## Apply
|
|
47
115
|
|
|
@@ -49,13 +117,22 @@ whole set and re-create the Secret — the pod stays pending until it exists.)
|
|
|
49
117
|
kubectl apply -k .
|
|
50
118
|
```
|
|
51
119
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
120
|
+
The harness Pod becomes ready once `/health` responds (no QEMU guest-image
|
|
121
|
+
download to wait on here, unlike the `gondolin` backend — startup should be
|
|
122
|
+
fast). The first sandboxed phase it runs will create a Pod in
|
|
123
|
+
`lastlight-sandboxes`; watch it with:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
kubectl get pods -n lastlight-sandboxes -w
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Validate the manifests yourself
|
|
56
130
|
|
|
57
|
-
|
|
131
|
+
```bash
|
|
132
|
+
kustomize build apps/server/deploy/k8s | kubeconform -strict -ignore-missing-schemas
|
|
133
|
+
```
|
|
58
134
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
`
|
|
135
|
+
`-ignore-missing-schemas` is needed only because the `CiliumNetworkPolicy`
|
|
136
|
+
custom resource's CRD schema isn't bundled with kubeconform's default schema
|
|
137
|
+
set (its RBAC `Role` rule referencing it, shipped here, needs no such
|
|
138
|
+
schema — only the CNP *objects* the harness generates at runtime would).
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Kubernetes sandbox backend — architecture
|
|
2
|
+
|
|
3
|
+
Diagrams for the `kubernetes` sandbox backend (`LASTLIGHT_SANDBOX=kubernetes`).
|
|
4
|
+
Every workflow phase runs as its own bare, hardened Pod in a dedicated
|
|
5
|
+
namespace; the harness is a Kubernetes API client that mints per-run
|
|
6
|
+
credentials, streams the agent's output back, and reaps the Pod when the phase
|
|
7
|
+
ends. Full prose contract: [`spec/09-sandbox.md`](../../spec/09-sandbox.md);
|
|
8
|
+
cluster prerequisites and manifests: [`README.md`](./README.md).
|
|
9
|
+
|
|
10
|
+
Adapter: `src/sandbox/k8s/kubernetes-sandbox.ts`.
|
|
11
|
+
|
|
12
|
+
## 1 · Structure — two namespaces, one API server between them
|
|
13
|
+
|
|
14
|
+
The harness lives in `lastlight` and holds every secret. It never shares a
|
|
15
|
+
filesystem with the agent, so three things ride HTTP `/internal/*` routes
|
|
16
|
+
instead. Sandboxes live in `lastlight-sandboxes`, one ephemeral Pod per phase,
|
|
17
|
+
each wrapped by a `CiliumNetworkPolicy`. The harness reaches the cluster with a
|
|
18
|
+
least-privilege `Role` bound to its `ServiceAccount` by a cross-namespace
|
|
19
|
+
`RoleBinding`.
|
|
20
|
+
|
|
21
|
+
```mermaid
|
|
22
|
+
flowchart TB
|
|
23
|
+
classDef harness fill:#e6edfa,stroke:#3f6fd0,color:#12233f;
|
|
24
|
+
classDef api fill:#eef1f6,stroke:#7b8db0,color:#1c2740;
|
|
25
|
+
classDef sandbox fill:#fbf1dd,stroke:#b1781a,color:#4a3306;
|
|
26
|
+
classDef store fill:#e2f1f8,stroke:#2f7fa6,color:#123043;
|
|
27
|
+
classDef net fill:#f0f2f5,stroke:#8a97ab,color:#333e50,stroke-dasharray:4 3;
|
|
28
|
+
|
|
29
|
+
subgraph NSH["namespace: lastlight"]
|
|
30
|
+
direction TB
|
|
31
|
+
H["Harness Pod · Last Light server<br/>@kubernetes/client-node<br/>ServiceAccount: lastlight"]:::harness
|
|
32
|
+
R["/internal routes (Hono)<br/>skill-bundle · agent-context · sandbox-artifacts"]:::store
|
|
33
|
+
PEM["GitHub App PEM — host-only, never crosses<br/>mints scoped install token per phase"]:::harness
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
API["Kubernetes API server<br/>RBAC Role: lastlight-sandbox-manager<br/>ResourceQuota + LimitRange"]:::api
|
|
37
|
+
|
|
38
|
+
subgraph NSS["namespace: lastlight-sandboxes"]
|
|
39
|
+
direction TB
|
|
40
|
+
subgraph POD["Sandbox Pod — one per phase · restartPolicy: Never · automountServiceAccountToken: false"]
|
|
41
|
+
direction LR
|
|
42
|
+
IC["initContainers<br/>clone → skills → agent-context"]:::sandbox
|
|
43
|
+
AG["agent container<br/>agentic-pi run --sandbox none"]:::sandbox
|
|
44
|
+
IC --> AG
|
|
45
|
+
end
|
|
46
|
+
CREDS["creds Secret — envFrom<br/>GIT_TOKEN · provider keys · fetch tokens"]:::store
|
|
47
|
+
PVC["workspace<br/>RWO PVC per repo,PR · or emptyDir"]:::store
|
|
48
|
+
CNP["CiliumNetworkPolicy · strict / open"]:::api
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
NET["Internet<br/>github.com · LLM providers · pkg registries"]:::net
|
|
52
|
+
|
|
53
|
+
H -->|"create · delete · status · log"| API
|
|
54
|
+
PEM -.->|"minted token only"| CREDS
|
|
55
|
+
API -->|"schedule Pod"| POD
|
|
56
|
+
CREDS -. envFrom .- POD
|
|
57
|
+
PVC -. mount .- POD
|
|
58
|
+
IC -->|"GET skill-bundle · agent-context (bearer)"| R
|
|
59
|
+
AG -->|"POST .lastlight artifacts (best-effort)"| R
|
|
60
|
+
AG -->|"egress :443"| CNP
|
|
61
|
+
CNP -->|"strict: DNS proxy + toFQDNs · open: 0.0.0.0/0 − private CIDRs"| NET
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 2 · Time — one phase, one Pod, provision to reap
|
|
65
|
+
|
|
66
|
+
`KubernetesSandbox` is a thin orchestrator over collaborators
|
|
67
|
+
(`WorkspaceProvisioner`, `RunSecrets`, `EgressEnsurer`, the free functions in
|
|
68
|
+
`pod-lifecycle.ts`). Secrets are created *before* the Pod — a Pod naming a
|
|
69
|
+
missing Secret never starts — then adopted by the Pod's `ownerReferences` so
|
|
70
|
+
deleting the Pod cascade-GCs them.
|
|
71
|
+
|
|
72
|
+
```mermaid
|
|
73
|
+
sequenceDiagram
|
|
74
|
+
autonumber
|
|
75
|
+
participant O as Orchestrator
|
|
76
|
+
participant K as KubernetesSandbox
|
|
77
|
+
participant API as K8s API
|
|
78
|
+
participant P as Sandbox Pod
|
|
79
|
+
participant H as Harness /internal
|
|
80
|
+
|
|
81
|
+
O->>K: provision(preClone?)
|
|
82
|
+
K->>API: reuse/create RWO PVC (or emptyDir)
|
|
83
|
+
O->>K: stageSkills() · runAgent(prompt)
|
|
84
|
+
K->>API: create creds + prompt Secrets
|
|
85
|
+
K->>API: createNamespacedPod
|
|
86
|
+
Note over API: 403 exceeded quota →<br/>QuotaExceededError → requeue run
|
|
87
|
+
API->>P: schedule
|
|
88
|
+
K->>API: patch Secret ownerRefs → Pod uid
|
|
89
|
+
P->>P: init: clone → skills → agent-context
|
|
90
|
+
P->>H: GET skill-bundle / agent-context (bearer)
|
|
91
|
+
K->>API: waitForContainerStart (poll status)
|
|
92
|
+
P->>P: agent runs · streams JSONL stdout
|
|
93
|
+
API-->>K: streamPodLog → parseLine → events
|
|
94
|
+
P->>H: POST .lastlight/ artifacts (best-effort)
|
|
95
|
+
O->>K: dispose()
|
|
96
|
+
K->>API: delete Pod → Secrets cascade-GC
|
|
97
|
+
K->>API: waitForPodGone (avoid RWO Multi-Attach)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 3 · Domain model — information flow between the objects
|
|
101
|
+
|
|
102
|
+
A classic *ports & adapters* slice. The engine speaks one ubiquitous language —
|
|
103
|
+
the `Sandbox` port and an intent-only `EgressPolicy` — and `KubernetesSandbox`
|
|
104
|
+
is the adapter that translates that intent into cluster objects. It owns almost
|
|
105
|
+
no logic itself; it routes messages between collaborators, each carrying a typed
|
|
106
|
+
value object rather than a loose bag of strings.
|
|
107
|
+
|
|
108
|
+
```mermaid
|
|
109
|
+
flowchart TB
|
|
110
|
+
classDef port fill:#e2f4ec,stroke:#2f8f5f,color:#123b28;
|
|
111
|
+
classDef adapter fill:#e6edfa,stroke:#3f6fd0,color:#12233f;
|
|
112
|
+
classDef service fill:#e2f1f8,stroke:#2f7fa6,color:#123043;
|
|
113
|
+
classDef agg fill:#fbf1dd,stroke:#b1781a,color:#4a3306;
|
|
114
|
+
|
|
115
|
+
ENG["Engine · orchestrator<br/>withSandbox"]:::port
|
|
116
|
+
PORT{{"Sandbox port · intent-only EgressPolicy"}}:::port
|
|
117
|
+
K["KubernetesSandbox<br/>adapter / thin orchestrator"]:::adapter
|
|
118
|
+
|
|
119
|
+
WP["WorkspaceProvisioner<br/>domain service"]:::service
|
|
120
|
+
RS["RunSecrets<br/>domain service"]:::service
|
|
121
|
+
EE["EgressEnsurer<br/>idempotent per namespace"]:::service
|
|
122
|
+
REG["Registries · gateways<br/>skill · agent-context · artifact"]:::service
|
|
123
|
+
LC["pod-lifecycle<br/>stateless ops"]:::service
|
|
124
|
+
|
|
125
|
+
POD["Pod — aggregate root<br/>Secrets = members via ownerRef"]:::agg
|
|
126
|
+
|
|
127
|
+
ENG --> PORT --> K
|
|
128
|
+
K -->|"PrePopulateSpec"| WP
|
|
129
|
+
WP -->|"Provisioned {workspace, pre}"| K
|
|
130
|
+
K -->|"skillPaths → tar"| REG
|
|
131
|
+
REG -->|"capability token"| K
|
|
132
|
+
K -->|"{podLabel, env, tokens, prompt}"| RS
|
|
133
|
+
RS -->|"RunSecretsResult"| K
|
|
134
|
+
K -->|"strictHosts + harness selector"| EE
|
|
135
|
+
K -->|"buildPodManifest → create · patchOwnerRefs · delete"| POD
|
|
136
|
+
LC -->|"waitForStart · streamPodLog · waitForPodGone"| POD
|
|
137
|
+
POD -->|"JSONL events → parseLine"| K
|
|
138
|
+
POD -. "bearer token → fetch / upload" .-> REG
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
| Object | Stereotype | Carries / produces |
|
|
142
|
+
|---|---|---|
|
|
143
|
+
| `Sandbox` | Port — published contract | `provision · stageSkills · runAgent · runCommand · dispose`; every backend speaks it |
|
|
144
|
+
| `KubernetesSandbox` | Adapter / thin orchestrator | transient per-run handles + skill / agent-context / artifact tokens |
|
|
145
|
+
| `WorkspaceProvisioner` | Domain service | `Provisioned` — the PVC-vs-`emptyDir` workspace + pre-clone coords |
|
|
146
|
+
| `RunSecrets` | Domain service | `RunSecretsResult` — creds + prompt Secret; owns create / ownerRef / delete |
|
|
147
|
+
| `EgressEnsurer` | Domain service (idempotent) | the `CiliumNetworkPolicy` pair, once per namespace per process |
|
|
148
|
+
| skill / agent-context / artifact registries | Gateways, keyed by capability token | the only reference that crosses the harness ↔ pod boundary |
|
|
149
|
+
| `Pod` (+ Secrets) | Aggregate root + members | `ownerRef` puts the Secrets inside the Pod's consistency boundary |
|
|
150
|
+
| `RunId` · `Rfc1123Label` · `EgressMode` | Value objects | make illegal states unrepresentable in the type system |
|
|
151
|
+
|
|
152
|
+
Four properties this buys:
|
|
153
|
+
|
|
154
|
+
- **The Pod is an aggregate.** Secrets are created *before* the Pod, then adopted
|
|
155
|
+
via `ownerReferences`; deleting the Pod cascade-GCs them. The root governs its
|
|
156
|
+
members' lifecycle.
|
|
157
|
+
- **Value objects, not conventions.** A Secret name is only ever derived from an
|
|
158
|
+
`Rfc1123Label` pod name — threaded as a type, so a raw string cannot reach
|
|
159
|
+
`RunSecrets` (F6). `RunId.matchLabels()` stamps Pod and PVC identically, so the
|
|
160
|
+
reclaim selector matches both by construction (F7).
|
|
161
|
+
- **Backpressure is an event, not a failure.** A quota `403` becomes
|
|
162
|
+
`QuotaExceededError`, translated layer by layer — adapter → `error_quota` →
|
|
163
|
+
`backpressure` → `requeueRunning`. The information flows *outward* and re-queues
|
|
164
|
+
the run rather than terminating it.
|
|
165
|
+
- **Anti-corruption at the port.** The engine never learns a Kubernetes noun. It
|
|
166
|
+
passes an intent-only `EgressPolicy.unrestricted`; the adapter alone maps it to
|
|
167
|
+
`strict` / `open` and a `CiliumNetworkPolicy`. Swap the backend and the
|
|
168
|
+
engine's language is unchanged.
|
|
169
|
+
|
|
170
|
+
## 4 · The filesystem seam — three HTTP channels replace a shared volume
|
|
171
|
+
|
|
172
|
+
A sandbox Pod can't see the harness's disk. Each channel is a per-run bearer
|
|
173
|
+
token, minted by the harness, carried in the Pod's creds Secret, and redeemed
|
|
174
|
+
against an `/internal/*` route on the harness's own Hono app. Every route
|
|
175
|
+
`401`s on a missing or unregistered token; `dispose` evicts them.
|
|
176
|
+
|
|
177
|
+
| Channel | Route | Direction | In-pod consumer |
|
|
178
|
+
|---|---|---|---|
|
|
179
|
+
| Skill bundle | `GET /internal/skill-bundle` | harness → pod | `skills` initContainer |
|
|
180
|
+
| Agent context (`AGENTS.md`) | `GET /internal/agent-context` | harness → pod | `agent-context` initContainer |
|
|
181
|
+
| Build artifacts | `POST /internal/sandbox-artifacts` | pod → harness | tail of the run script |
|
|
182
|
+
|
|
183
|
+
A `toEndpoints` identity rule in *both* egress policies scopes sandbox → harness
|
|
184
|
+
traffic to the harness Pod's namespace + labels — an identity selector, not a
|
|
185
|
+
CIDR hole — so all three channels stay reachable under strict or open egress.
|
|
186
|
+
|
|
187
|
+
## 5 · Least-privilege Role
|
|
188
|
+
|
|
189
|
+
Every verb maps to a real call the harness makes (`sandbox-rbac.yaml`). No `get`
|
|
190
|
+
on secrets (write-only), no `watch` on pods, no `delete` on the egress policies.
|
|
191
|
+
|
|
192
|
+
| Resource | Verbs |
|
|
193
|
+
|---|---|
|
|
194
|
+
| `pods` | create · list · delete |
|
|
195
|
+
| `pods/status` | get |
|
|
196
|
+
| `pods/log` | get |
|
|
197
|
+
| `secrets` | create · patch · delete |
|
|
198
|
+
| `persistentvolumeclaims` | create · get · list · delete |
|
|
199
|
+
| `ciliumnetworkpolicies` | create · get · update |
|
|
@@ -4,10 +4,21 @@ metadata:
|
|
|
4
4
|
name: lastlight-config
|
|
5
5
|
namespace: lastlight
|
|
6
6
|
data:
|
|
7
|
-
# Overlay layered over the image's config/default.yaml.
|
|
8
|
-
#
|
|
7
|
+
# Overlay layered over the image's config/default.yaml. EDIT managedRepos
|
|
8
|
+
# before applying. The sandbox.kubernetes.* block below is written out
|
|
9
|
+
# explicitly for clarity — every key here already matches K8S_DEFAULTS
|
|
10
|
+
# (apps/server/src/config/config.ts), so this is a no-op default you can
|
|
11
|
+
# trim once you've reviewed it; only storageClassName typically needs a
|
|
12
|
+
# real edit (see the README's requirements matrix).
|
|
9
13
|
config.yaml: |
|
|
10
14
|
managedRepos:
|
|
11
15
|
- your-org/your-repo
|
|
12
16
|
sandbox:
|
|
13
|
-
backend:
|
|
17
|
+
backend: kubernetes
|
|
18
|
+
kubernetes:
|
|
19
|
+
namespace: lastlight-sandboxes
|
|
20
|
+
image: ghcr.io/nearform/lastlight-sandbox:latest
|
|
21
|
+
# EDIT: an RWO block/local StorageClass (not NFS — see README).
|
|
22
|
+
# Empty uses the cluster's default StorageClass.
|
|
23
|
+
storageClassName: ""
|
|
24
|
+
workspaceSize: 5Gi
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# The harness namespace, its data PVC, the Deployment wired for
|
|
2
|
+
# sandbox.backend: kubernetes, and the Service the sandbox pods reach it
|
|
3
|
+
# through. Distinct from lastlight-sandboxes (sandbox-namespace.yaml), where
|
|
4
|
+
# the ephemeral per-phase sandbox pods run — see README.md (this directory)
|
|
5
|
+
# and apps/server/spec/09-sandbox.md for the full architecture.
|
|
6
|
+
apiVersion: v1
|
|
7
|
+
kind: Namespace
|
|
8
|
+
metadata:
|
|
9
|
+
name: lastlight
|
|
10
|
+
# No pod-security label: the agent image's entrypoint starts as root, then
|
|
11
|
+
# `exec gosu lastlight` (UID 10001) — restricted PSA requires
|
|
12
|
+
# runAsNonRoot=true at admission, which this pod spec doesn't declare. The
|
|
13
|
+
# isolation boundary for untrusted work is the sandbox namespace's pods, not
|
|
14
|
+
# the harness pod itself, so this namespace runs at the cluster's default
|
|
15
|
+
# PSA level (unset here — set your own baseline if your cluster requires it).
|
|
16
|
+
---
|
|
17
|
+
apiVersion: v1
|
|
18
|
+
kind: PersistentVolumeClaim
|
|
19
|
+
metadata:
|
|
20
|
+
name: lastlight-data
|
|
21
|
+
namespace: lastlight
|
|
22
|
+
spec:
|
|
23
|
+
accessModes: ["ReadWriteOnce"] # single embedded-SQLite writer
|
|
24
|
+
resources:
|
|
25
|
+
requests:
|
|
26
|
+
storage: 20Gi
|
|
27
|
+
# EDIT: a local/block StorageClass so SQLite file locking is safe (not NFS).
|
|
28
|
+
# Leaving this unset uses the cluster's default StorageClass.
|
|
29
|
+
# storageClassName: your-block-storage-class
|
|
30
|
+
---
|
|
31
|
+
apiVersion: apps/v1
|
|
32
|
+
kind: Deployment
|
|
33
|
+
metadata:
|
|
34
|
+
name: lastlight
|
|
35
|
+
namespace: lastlight
|
|
36
|
+
labels: { app.kubernetes.io/name: lastlight }
|
|
37
|
+
spec:
|
|
38
|
+
replicas: 1
|
|
39
|
+
strategy: { type: Recreate } # single embedded-SQLite writer on an RWO PVC
|
|
40
|
+
selector:
|
|
41
|
+
matchLabels: { app.kubernetes.io/name: lastlight }
|
|
42
|
+
template:
|
|
43
|
+
metadata:
|
|
44
|
+
# This label is what sandbox.kubernetes.harnessPodLabels defaults to
|
|
45
|
+
# (K8S_DEFAULTS in apps/server/src/config/config.ts) — it's how the
|
|
46
|
+
# harness-generated CiliumNetworkPolicy `toEndpoints` rule finds this
|
|
47
|
+
# pod for the sandbox->harness skill/context/artifact channel. Change
|
|
48
|
+
# both together if you relabel.
|
|
49
|
+
labels: { app.kubernetes.io/name: lastlight }
|
|
50
|
+
spec:
|
|
51
|
+
serviceAccountName: lastlight # sandbox-rbac.yaml — RBAC to manage sandbox pods
|
|
52
|
+
containers:
|
|
53
|
+
- name: agent
|
|
54
|
+
# EDIT: pin to a release tag, e.g. :v0.21.8. This is the PLAIN agent
|
|
55
|
+
# image (no QEMU) — the kubernetes sandbox backend isolates at the
|
|
56
|
+
# Pod level (KubernetesSandbox), not gondolin's in-harness micro-VM,
|
|
57
|
+
# so it needs neither QEMU nor a docker socket in this pod.
|
|
58
|
+
image: ghcr.io/nearform/lastlight-agent:latest
|
|
59
|
+
# No runAsUser/runAsNonRoot, no added capabilities, no
|
|
60
|
+
# privileged:true, no /dev/kvm device: the entrypoint starts as
|
|
61
|
+
# root then `exec gosu lastlight` (UID 10001).
|
|
62
|
+
ports:
|
|
63
|
+
- { name: http, containerPort: 8644 }
|
|
64
|
+
env:
|
|
65
|
+
- { name: LASTLIGHT_OVERLAY_DIR, value: /app/instance }
|
|
66
|
+
- { name: STATE_DIR, value: /app/data }
|
|
67
|
+
resources:
|
|
68
|
+
requests:
|
|
69
|
+
cpu: "500m"
|
|
70
|
+
memory: 1Gi
|
|
71
|
+
limits:
|
|
72
|
+
cpu: "2"
|
|
73
|
+
memory: 3Gi
|
|
74
|
+
volumeMounts:
|
|
75
|
+
- { name: data, mountPath: /app/data }
|
|
76
|
+
- { name: secrets, mountPath: /app/instance/secrets, readOnly: true }
|
|
77
|
+
- { name: config, mountPath: /app/instance/config.yaml, subPath: config.yaml, readOnly: true }
|
|
78
|
+
startupProbe:
|
|
79
|
+
httpGet: { path: /health, port: 8644 }
|
|
80
|
+
periodSeconds: 10
|
|
81
|
+
failureThreshold: 30
|
|
82
|
+
readinessProbe:
|
|
83
|
+
httpGet: { path: /health, port: 8644 }
|
|
84
|
+
periodSeconds: 15
|
|
85
|
+
livenessProbe:
|
|
86
|
+
httpGet: { path: /health, port: 8644 }
|
|
87
|
+
periodSeconds: 30
|
|
88
|
+
failureThreshold: 4
|
|
89
|
+
volumes:
|
|
90
|
+
- name: data
|
|
91
|
+
persistentVolumeClaim: { claimName: lastlight-data }
|
|
92
|
+
- name: secrets
|
|
93
|
+
secret: { secretName: lastlight-secrets }
|
|
94
|
+
- name: config
|
|
95
|
+
configMap: { name: lastlight-config }
|
|
96
|
+
---
|
|
97
|
+
# Reached by sandbox pods' initContainers (skill bundle + agent-context fetch)
|
|
98
|
+
# and by the main container's artifact POST-back — see the README's
|
|
99
|
+
# "harness Service reachability" section. This Service's DNS name
|
|
100
|
+
# (lastlight.lastlight.svc.cluster.local:8644) is exactly
|
|
101
|
+
# sandbox.kubernetes.harnessEndpoint's default, so no override is needed if
|
|
102
|
+
# you keep this namespace/name.
|
|
103
|
+
apiVersion: v1
|
|
104
|
+
kind: Service
|
|
105
|
+
metadata:
|
|
106
|
+
name: lastlight
|
|
107
|
+
namespace: lastlight
|
|
108
|
+
spec:
|
|
109
|
+
selector: { app.kubernetes.io/name: lastlight }
|
|
110
|
+
ports:
|
|
111
|
+
- { name: http, port: 8644, targetPort: 8644 }
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
2
2
|
kind: Kustomization
|
|
3
|
-
# The Secret
|
|
4
|
-
# is created out-of-band (see README).
|
|
5
|
-
#
|
|
3
|
+
# The Secret (lastlight-secrets: GitHub App PEM + .env) is intentionally NOT
|
|
4
|
+
# here — it carries credentials and is created out-of-band (see README).
|
|
5
|
+
# Everything else the harness and its sandbox pods depend on ships in this
|
|
6
|
+
# set. Apply order is handled by kubectl/kustomize dependency ordering
|
|
7
|
+
# (namespaces before namespaced objects); see the README for the explicit
|
|
8
|
+
# sequence if you're applying files individually instead of `kubectl apply -k`.
|
|
6
9
|
resources:
|
|
7
|
-
- namespace.yaml
|
|
8
|
-
-
|
|
10
|
+
- sandbox-namespace.yaml
|
|
11
|
+
- sandbox-quota.yaml
|
|
12
|
+
- sandbox-rbac.yaml
|
|
9
13
|
- configmap.yaml
|
|
10
|
-
-
|
|
11
|
-
- deployment.yaml
|
|
12
|
-
- service.yaml
|
|
14
|
+
- harness-deployment.yaml
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
apiVersion: v1
|
|
2
|
+
kind: Namespace
|
|
3
|
+
metadata:
|
|
4
|
+
name: lastlight-sandboxes
|
|
5
|
+
labels:
|
|
6
|
+
# The kubernetes sandbox backend's pod spec is restricted-PSA compliant by
|
|
7
|
+
# construction: runAsNonRoot, seccompProfile RuntimeDefault,
|
|
8
|
+
# allowPrivilegeEscalation false, all capabilities dropped
|
|
9
|
+
# (KubernetesSandbox, apps/server/src/sandbox/k8s/kubernetes-sandbox.ts).
|
|
10
|
+
# No privileged component runs in this namespace.
|
|
11
|
+
pod-security.kubernetes.io/enforce: restricted
|
|
12
|
+
pod-security.kubernetes.io/enforce-version: latest
|
|
13
|
+
pod-security.kubernetes.io/audit: restricted
|
|
14
|
+
pod-security.kubernetes.io/warn: restricted
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Concurrency ceiling for the kubernetes sandbox backend. Pod-count only (NOT
|
|
2
|
+
# requests.cpu/requests.memory): the sandbox pod spec the harness creates
|
|
3
|
+
# declares no resources of its own, so a requests-based ResourceQuota would
|
|
4
|
+
# reject every pod with a "must specify requests" admission error — which the
|
|
5
|
+
# harness's quota-backpressure detection (isQuotaExceeded,
|
|
6
|
+
# apps/server/src/sandbox/k8s/quota.ts) does NOT match, turning graceful
|
|
7
|
+
# backpressure into a hard failure. A `pods` quota instead yields the
|
|
8
|
+
# `exceeded quota` message the harness requeues the run on. Scale by editing
|
|
9
|
+
# this one number.
|
|
10
|
+
apiVersion: v1
|
|
11
|
+
kind: ResourceQuota
|
|
12
|
+
metadata:
|
|
13
|
+
name: lastlight-sandboxes-quota
|
|
14
|
+
namespace: lastlight-sandboxes
|
|
15
|
+
spec:
|
|
16
|
+
hard:
|
|
17
|
+
pods: "4"
|
|
18
|
+
---
|
|
19
|
+
# Because the ResourceQuota above is pod-count only, every sandbox pod's
|
|
20
|
+
# containers (init + main) still need requests/limits or the scheduler has
|
|
21
|
+
# nothing to bin-pack on. This LimitRange injects a per-pod default so the
|
|
22
|
+
# resource-less pod spec is bounded and schedulable without the harness
|
|
23
|
+
# needing to know cluster capacity.
|
|
24
|
+
apiVersion: v1
|
|
25
|
+
kind: LimitRange
|
|
26
|
+
metadata:
|
|
27
|
+
name: lastlight-sandboxes-limits
|
|
28
|
+
namespace: lastlight-sandboxes
|
|
29
|
+
spec:
|
|
30
|
+
limits:
|
|
31
|
+
- type: Container
|
|
32
|
+
defaultRequest:
|
|
33
|
+
cpu: 500m
|
|
34
|
+
memory: 1Gi
|
|
35
|
+
default:
|
|
36
|
+
cpu: "2"
|
|
37
|
+
memory: 4Gi
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# The harness authenticates as this ServiceAccount (attached to the harness
|
|
2
|
+
# Deployment in harness-deployment.yaml); @kubernetes/client-node's
|
|
3
|
+
# KubeConfig.loadFromCluster() reads its mounted token in-cluster — nothing to
|
|
4
|
+
# configure in app config beyond the namespace it lives in.
|
|
5
|
+
apiVersion: v1
|
|
6
|
+
kind: ServiceAccount
|
|
7
|
+
metadata:
|
|
8
|
+
name: lastlight
|
|
9
|
+
namespace: lastlight
|
|
10
|
+
---
|
|
11
|
+
# Least-privilege management of ephemeral sandbox objects, confined to the
|
|
12
|
+
# lastlight-sandboxes namespace (a Role, not a ClusterRole). Every verb below
|
|
13
|
+
# maps to a real call the harness makes against
|
|
14
|
+
# apps/server/src/sandbox/k8s/*.ts — no get/watch on pods (only
|
|
15
|
+
# readNamespacedPodStatus + readNamespacedPodLog are used), no get on secrets
|
|
16
|
+
# (write-only: create/patch/delete), no delete on CiliumNetworkPolicy (the
|
|
17
|
+
# egress policy pair is created once per namespace and updated in place, never
|
|
18
|
+
# torn down per run). Nothing here is speculative — this is the audited
|
|
19
|
+
# minimum, not the design doc's original pre-implementation draft.
|
|
20
|
+
apiVersion: rbac.authorization.k8s.io/v1
|
|
21
|
+
kind: Role
|
|
22
|
+
metadata:
|
|
23
|
+
name: lastlight-sandbox-manager
|
|
24
|
+
namespace: lastlight-sandboxes
|
|
25
|
+
rules:
|
|
26
|
+
- apiGroups: [""]
|
|
27
|
+
resources: ["pods"]
|
|
28
|
+
verbs: ["create", "list", "delete"]
|
|
29
|
+
- apiGroups: [""]
|
|
30
|
+
resources: ["pods/status"]
|
|
31
|
+
verbs: ["get"]
|
|
32
|
+
- apiGroups: [""]
|
|
33
|
+
resources: ["pods/log"]
|
|
34
|
+
verbs: ["get"]
|
|
35
|
+
- apiGroups: [""]
|
|
36
|
+
resources: ["secrets"]
|
|
37
|
+
verbs: ["create", "patch", "delete"]
|
|
38
|
+
- apiGroups: [""]
|
|
39
|
+
resources: ["persistentvolumeclaims"]
|
|
40
|
+
verbs: ["create", "get", "list", "delete"]
|
|
41
|
+
- apiGroups: ["cilium.io"]
|
|
42
|
+
resources: ["ciliumnetworkpolicies"]
|
|
43
|
+
verbs: ["create", "get", "update"]
|
|
44
|
+
---
|
|
45
|
+
# The RoleBinding lives in the sandbox namespace (same as the Role); the
|
|
46
|
+
# subject ServiceAccount lives in the harness namespace — a cross-namespace
|
|
47
|
+
# subject reference is valid RBAC.
|
|
48
|
+
apiVersion: rbac.authorization.k8s.io/v1
|
|
49
|
+
kind: RoleBinding
|
|
50
|
+
metadata:
|
|
51
|
+
name: lastlight-sandbox-manager
|
|
52
|
+
namespace: lastlight-sandboxes
|
|
53
|
+
subjects:
|
|
54
|
+
- kind: ServiceAccount
|
|
55
|
+
name: lastlight
|
|
56
|
+
namespace: lastlight
|
|
57
|
+
roleRef:
|
|
58
|
+
apiGroup: rbac.authorization.k8s.io
|
|
59
|
+
kind: Role
|
|
60
|
+
name: lastlight-sandbox-manager
|