diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml new file mode 100644 index 00000000000..03617da3c59 --- /dev/null +++ b/.github/actionlint.yaml @@ -0,0 +1,6 @@ +# Runner labels actionlint cannot know: GitHub larger runners defined for this +# organization. Workflows that pick one through a CI_PROVIDER expression were never +# checked; a workflow that names one directly is. +self-hosted-runner: + labels: + - linux-x64-8-core diff --git a/.github/actions/attest-image/action.yml b/.github/actions/attest-image/action.yml new file mode 100644 index 00000000000..372c35c1c35 --- /dev/null +++ b/.github/actions/attest-image/action.yml @@ -0,0 +1,57 @@ +name: attest-image +description: >- + Attest and sign one pushed image by digest: an SPDX SBOM attestation when + sbom-image is set, build provenance, and a keyless Cosign signature, all pushed to + the registry beside the image. Needs a registry login and the job permissions + id-token, attestations, artifact-metadata, and packages write. + +inputs: + image: + description: Image repository, without tag or digest. + required: true + digest: + description: Digest of the pushed image or index (sha256:...). + required: true + sbom-image: + description: Reference to generate the SBOM from. Empty attests provenance only. + required: false + default: '' + +runs: + using: composite + steps: + - name: Generate SBOM + if: inputs.sbom-image != '' + uses: anchore/sbom-action@dfcb83b97731532d72be422cbc51ee64adb6fd56 # v0.24.4 + with: + image: ${{ inputs.sbom-image }} + format: spdx-json + output-file: sbom.spdx.json + upload-artifact: false + upload-release-assets: false + + - name: Attest SBOM + if: inputs.sbom-image != '' + uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2 + with: + subject-name: ${{ inputs.image }} + subject-digest: ${{ inputs.digest }} + sbom-path: sbom.spdx.json + push-to-registry: true + + - name: Attest build provenance + uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2 + with: + subject-name: ${{ inputs.image }} + subject-digest: ${{ inputs.digest }} + push-to-registry: true + + - name: Install Cosign + uses: sigstore/cosign-installer@881c63bd87e38389154debd8331404ce7ca8a3ab # v4.1.4 + + - name: Sign image + shell: bash + env: + IMAGE: ${{ inputs.image }} + DIGEST: ${{ inputs.digest }} + run: cosign sign --yes "${IMAGE}@${DIGEST}" diff --git a/.github/actions/image/action.yml b/.github/actions/image/action.yml index 73654b5fae4..06d8e9111c8 100644 --- a/.github/actions/image/action.yml +++ b/.github/actions/image/action.yml @@ -17,8 +17,16 @@ inputs: description: Target platforms, e.g. linux/amd64. required: true tags: - description: Comma-separated list of tags to push. + description: Comma-separated list of tags to push (or to load, when push is off). required: true + push: + description: Push the tags to their registries. 'false' builds without publishing, for validation. + required: false + default: 'true' + load: + description: Load the built image into the runner's Docker daemon, so later steps can run it. + required: false + default: 'false' build-args: description: Newline-separated Docker build arguments. required: false @@ -27,6 +35,13 @@ inputs: description: Dockerfile stage to build. Empty builds the final stage. required: false default: '' + cache-key-suffix: + description: >- + Appended to the Blacksmith layer cache key, so a caller that must not share + the deploy pipeline's sticky disk (a pull request build) gets its own. Empty + keeps the shared key. + required: false + default: '' max-cache-size-mb: description: >- Layer cache to retain after this action prunes, in MB. Must stay above one @@ -58,7 +73,8 @@ runs: env: FILE: ${{ inputs.file }} PLATFORMS: ${{ inputs.platforms }} - run: echo "value=${GITHUB_REPOSITORY##*/}/${FILE#./}/${PLATFORMS//\//-}" >> "$GITHUB_OUTPUT" + SUFFIX: ${{ inputs.cache-key-suffix }} + run: echo "value=${GITHUB_REPOSITORY##*/}/${FILE#./}/${PLATFORMS//\//-}${SUFFIX}" >> "$GITHUB_OUTPUT" # This action does NOT bound the disk — see the prune step below. BuildKit's # own GC is time-based only (layers unused for 8 days), and these disks are @@ -78,7 +94,8 @@ runs: context: ${{ inputs.context }} file: ${{ inputs.file }} platforms: ${{ inputs.platforms }} - push: true + push: ${{ inputs.push }} + load: ${{ inputs.load }} tags: ${{ inputs.tags }} build-args: ${{ inputs.build-args }} target: ${{ inputs.target }} @@ -185,7 +202,8 @@ runs: context: ${{ inputs.context }} file: ${{ inputs.file }} platforms: ${{ inputs.platforms }} - push: true + push: ${{ inputs.push }} + load: ${{ inputs.load }} tags: ${{ inputs.tags }} build-args: ${{ inputs.build-args }} target: ${{ inputs.target }} diff --git a/.github/actions/k3s-diagnostics/action.yml b/.github/actions/k3s-diagnostics/action.yml new file mode 100644 index 00000000000..2825d403aa5 --- /dev/null +++ b/.github/actions/k3s-diagnostics/action.yml @@ -0,0 +1,41 @@ +name: k3s-diagnostics +description: >- + Collect what explains a failed k3s run into $RUNNER_TEMP/diagnostics: every pod, + pod descriptions for the given namespaces, the app's and its migrations' logs when + a release namespace is given, cluster events, the k3s journal, and disk usage. + Each command writes its own error into its file, so one failing never hides the rest. + +inputs: + describe-namespaces: + description: Space-separated namespaces whose pods to describe. + required: true + app-namespace: + description: Namespace of the Helm release whose app logs to collect. Empty skips them. + required: false + default: '' + +runs: + using: composite + steps: + - name: Collect diagnostics + shell: bash + env: + DESCRIBE_NAMESPACES: ${{ inputs.describe-namespaces }} + APP_NAMESPACE: ${{ inputs.app-namespace }} + run: | + # Best effort by design: a command that fails records its error in its file + # and the collection goes on. + set +e + out="$RUNNER_TEMP/diagnostics" + mkdir -p "$out" + kubectl get pods --all-namespaces -o wide > "$out/pods.txt" 2>&1 + for namespace in $DESCRIBE_NAMESPACES; do + kubectl describe pods --namespace "$namespace" > "$out/pods-${namespace}.txt" 2>&1 + done + if [ -n "$APP_NAMESPACE" ]; then + kubectl logs --namespace "$APP_NAMESPACE" deploy/sim-app -c migrations --tail=200 > "$out/migrations.log" 2>&1 + kubectl logs --namespace "$APP_NAMESPACE" deploy/sim-app --tail=2000 > "$out/app.log" 2>&1 + fi + kubectl get events --all-namespaces --sort-by=.lastTimestamp > "$out/events.txt" 2>&1 + sudo journalctl --unit k3s --no-pager --lines 2000 > "$out/k3s.log" 2>&1 + df -h / > "$out/disk.txt" 2>&1 diff --git a/.github/actions/k3s-gvisor/action.yml b/.github/actions/k3s-gvisor/action.yml new file mode 100644 index 00000000000..081593b00ee --- /dev/null +++ b/.github/actions/k3s-gvisor/action.yml @@ -0,0 +1,130 @@ +name: k3s-gvisor +description: >- + Start a single-node k3s cluster whose containerd carries gVisor (runsc) as a runtime + handler, with k3s's built-in kube-router NetworkPolicy controller, plus Helm. Exports + KUBECONFIG (cluster-admin) and NODE_IP to later steps. For ephemeral GitHub-hosted VMs. + +# Pinned with their published checksums; bump each version and checksum together. +inputs: + k3s-version: + description: k3s release. + required: false + default: v1.36.6+k3s1 + k3s-sha256: + description: sha256 of that release's amd64 `k3s` binary (sha256sum-amd64.txt). + required: false + default: 66ceb8e67edfa547195135d74783bfadc2ecc04a91059e90ae5f70a3dbc98c15 + gvisor-release: + description: gVisor release (storage.googleapis.com/gvisor/releases/release/). + required: false + default: '20261123.2' + gvisor-sha512: + description: sha512 of that release's x86_64 gvisor.tar.bz2. + required: false + default: bd0c27a0ad9489d5df82bce740512311db01755e2bc5be66564bbdf8febddf8eec46881a1d02fc79f7b2d167b6a320dc7596259df4d20f2e8dcf36db2273e967 + +outputs: + node-ip: + description: The node's address, which pods reach the runner at. + value: ${{ steps.k3s.outputs.node-ip }} + +runs: + using: composite + steps: + # Sandbox images are several GB and live twice (Docker, then containerd). + - name: Free disk space + shell: bash + run: | + set -euo pipefail + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL + df -h / + + - name: Install gVisor + shell: bash + env: + GVISOR_RELEASE: ${{ inputs.gvisor-release }} + GVISOR_SHA512: ${{ inputs.gvisor-sha512 }} + run: | + set -euo pipefail + workdir="$(mktemp -d)" + curl -fsSL --retry 3 --retry-all-errors \ + "https://storage.googleapis.com/gvisor/releases/release/${GVISOR_RELEASE}/x86_64/gvisor.tar.bz2" \ + -o "${workdir}/gvisor.tar.bz2" + echo "${GVISOR_SHA512} ${workdir}/gvisor.tar.bz2" | sha512sum -c - + tar -xjf "${workdir}/gvisor.tar.bz2" -C "$workdir" + sudo install -m 0755 "${workdir}/runsc" "${workdir}/containerd-shim-runsc-v1" /usr/local/bin/ + # runsc runs its sentry and helpers from gvisor-bin/ beside its own binary. + sudo install -d -m 0755 /usr/local/bin/gvisor-bin + sudo install -m 0755 "${workdir}"/gvisor-bin/* /usr/local/bin/gvisor-bin/ + runsc --version + + - name: Install and start k3s + id: k3s + shell: bash + env: + K3S_VERSION: ${{ inputs.k3s-version }} + K3S_SHA256: ${{ inputs.k3s-sha256 }} + run: | + set -euo pipefail + curl -fsSL --retry 3 --retry-all-errors \ + "https://github.com/k3s-io/k3s/releases/download/${K3S_VERSION//+/%2B}/k3s" -o /tmp/k3s + echo "${K3S_SHA256} /tmp/k3s" | sha256sum -c - + sudo install -m 0755 /tmp/k3s /usr/local/bin/k3s + # k3s's embedded kubectl, so the client matches the server exactly. + sudo ln -sf /usr/local/bin/k3s /usr/local/bin/kubectl + + # runsc must use the same cgroup driver as the kubelet. k3s picks it at + # start and exposes it to the template as .SystemdCgroup, so one runsc + # config exists per value and the template selects the matching one. + sudo mkdir -p /etc/containerd /var/lib/rancher/k3s/agent/etc/containerd + printf '[runsc_config]\n systemd-cgroup = "true"\n' | sudo tee /etc/containerd/runsc-systemd-true.toml > /dev/null + printf '[runsc_config]\n systemd-cgroup = "false"\n' | sudo tee /etc/containerd/runsc-systemd-false.toml > /dev/null + sudo tee /var/lib/rancher/k3s/agent/etc/containerd/config-v3.toml.tmpl > /dev/null <<'EOF' + {{ template "base" . }} + + [plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.runsc] + runtime_type = "io.containerd.runsc.v1" + [plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.runsc.options] + TypeUrl = "io.containerd.runsc.v1.options" + ConfigPath = "/etc/containerd/runsc-systemd-{{ .SystemdCgroup }}.toml" + EOF + + node_ip="$(ip -4 route get 1.1.1.1 | awk '{for (i = 1; i < NF; i++) if ($i == "src") print $(i + 1)}')" + echo "NODE_IP=${node_ip}" >> "$GITHUB_ENV" + echo "node-ip=${node_ip}" >> "$GITHUB_OUTPUT" + + # NetworkPolicy enforcement is k3s's default (its embedded kube-router + # controller); only --disable-network-policy turns it off, and it is + # deliberately absent. + sudo systemd-run --unit=k3s --description='k3s server' \ + -p Type=notify -p Delegate=yes -p KillMode=process -p TimeoutStartSec=300 \ + -p LimitNOFILE=1048576 -p LimitNPROC=infinity -p LimitCORE=infinity -p TasksMax=infinity \ + /usr/local/bin/k3s server \ + --node-ip "$node_ip" \ + --disable=traefik,metrics-server,servicelb \ + --write-kubeconfig-mode=0600 + + mkdir -p "$HOME/.kube" + sudo install -m 0600 -o "$(id -u)" -g "$(id -g)" /etc/rancher/k3s/k3s.yaml "$HOME/.kube/admin.yaml" + echo "KUBECONFIG=$HOME/.kube/admin.yaml" >> "$GITHUB_ENV" + + - name: Wait for the cluster + shell: bash + run: | + set -euo pipefail + # The node and CoreDNS objects appear a few seconds after the API does. + for _ in $(seq 1 60); do + if kubectl get node -o name | grep -q . && kubectl -n kube-system get deployment coredns > /dev/null 2>&1; then + break + fi + sleep 3 + done + kubectl wait --for=condition=Ready node --all --timeout=180s + kubectl -n kube-system rollout status deployment/coredns --timeout=180s + kubectl version + sudo grep -A3 "runtimes.runsc" /var/lib/rancher/k3s/agent/etc/containerd/config.toml + + - name: Set up Helm + uses: azure/setup-helm@2f5e7bc67f1f9972ab16657bb795f36d8f04de0e # v5.1.0 + with: + version: v3.16.4 diff --git a/.github/actions/k3s-image/action.yml b/.github/actions/k3s-image/action.yml new file mode 100644 index 00000000000..9b6d1059396 --- /dev/null +++ b/.github/actions/k3s-image/action.yml @@ -0,0 +1,89 @@ +name: k3s-image +description: >- + Put one image into the local k3s containerd, so pods start from it without a + registry. With `kind`, a sandbox image at the content-addressed reference + images.generated.json names: with `archive: 'true'`, imported from the workflow's + `sandbox-image-` artifact (a `ref` file naming the image, plus its + `docker save` archive as `image.tar`), else pulled from GHCR, where that + reference already holds the same image. With `artifact` and `tag`, an image built + from this checkout, imported from that artifact in the same layout. + +inputs: + kind: + description: Sandbox image kind in images.generated.json (agent, function, pi). Instead of artifact and tag. + required: false + default: '' + archive: + description: With kind, 'true' when the workflow built the image and uploaded its archive. + required: false + default: 'false' + artifact: + description: Name of the artifact holding the image. Needs tag. + required: false + default: '' + tag: + description: Reference the artifact holds, exactly as pods will name it. + required: false + default: '' + +outputs: + ref: + description: The image reference now in k3s. + value: ${{ steps.ref.outputs.ref }} + +runs: + using: composite + steps: + - name: Resolve image reference + id: ref + shell: bash + env: + KIND: ${{ inputs.kind }} + ARCHIVE: ${{ inputs.archive }} + ARTIFACT: ${{ inputs.artifact }} + TAG: ${{ inputs.tag }} + MANIFEST: apps/sim/lib/execution/remote-sandbox/kubernetes/images.generated.json + run: | + set -euo pipefail + if [ -n "$KIND" ] && [ -z "$ARTIFACT" ] && [ -z "$TAG" ]; then + echo "ref=$(jq -er --arg kind "$KIND" '.[$kind]' "$MANIFEST")" >> "$GITHUB_OUTPUT" + if [ "$ARCHIVE" = "true" ]; then + echo "artifact=sandbox-image-${KIND}" >> "$GITHUB_OUTPUT" + fi + elif [ -z "$KIND" ] && [ -n "$ARTIFACT" ] && [ -n "$TAG" ]; then + echo "ref=${TAG}" >> "$GITHUB_OUTPUT" + echo "artifact=${ARTIFACT}" >> "$GITHUB_OUTPUT" + else + echo "::error::k3s-image takes kind, or artifact and tag" + exit 1 + fi + + - name: Pull image + if: steps.ref.outputs.artifact == '' + shell: bash + env: + IMAGE: ${{ steps.ref.outputs.ref }} + run: sudo k3s crictl pull "$IMAGE" + + - name: Download image + if: steps.ref.outputs.artifact != '' + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: ${{ steps.ref.outputs.artifact }} + path: ${{ runner.temp }}/${{ steps.ref.outputs.artifact }} + + - name: Import image + if: steps.ref.outputs.artifact != '' + shell: bash + env: + DIR: ${{ runner.temp }}/${{ steps.ref.outputs.artifact }} + IMAGE: ${{ steps.ref.outputs.ref }} + run: | + set -euo pipefail + if [ "$(cat "${DIR}/ref")" != "$IMAGE" ]; then + echo "::error::The ${DIR##*/} artifact holds $(cat "${DIR}/ref"), not ${IMAGE}" + exit 1 + fi + sudo k3s ctr -n k8s.io images import "${DIR}/image.tar" + rm -rf "$DIR" + df -h / diff --git a/.github/actions/sandbox-image/action.yml b/.github/actions/sandbox-image/action.yml new file mode 100644 index 00000000000..025d41a4fdf --- /dev/null +++ b/.github/actions/sandbox-image/action.yml @@ -0,0 +1,49 @@ +name: sandbox-image +description: >- + Build one sandbox image for one architecture into the local Docker daemon and + verify its contract. Pushes nothing: sandbox.yml's read-only build job and its + push-gated publish job both run these steps, so a pull request never builds in a + job that holds registry or signing credentials. + +inputs: + provider: + description: CI provider, as the image and setup actions take it. + required: false + default: '' + kind: + description: Sandbox image kind (agent, function, pi). + required: true + arch: + description: Target architecture (amd64, arm64). + required: true + tag: + description: Reference to load the built image under. + required: true + +runs: + using: composite + steps: + - name: Build image + uses: ./.github/actions/image + with: + provider: ${{ inputs.provider }} + file: ./docker/sandbox-${{ inputs.kind }}.Dockerfile + platforms: linux/${{ inputs.arch }} + tags: ${{ inputs.tag }} + push: 'false' + load: 'true' + + - name: Setup workspace + if: inputs.kind != 'agent' + uses: ./.github/actions/setup + with: + provider: ${{ inputs.provider }} + node-version: '' + + - name: Verify image contract + if: inputs.kind != 'agent' + shell: bash + env: + KIND: ${{ inputs.kind }} + TAG: ${{ inputs.tag }} + run: bun run apps/sim/scripts/verify-sandbox-image.ts --kind "$KIND" --image "$TAG" diff --git a/.github/sandbox-kubernetes-e2e/app-values.yaml b/.github/sandbox-kubernetes-e2e/app-values.yaml new file mode 100644 index 00000000000..19297f4ffb9 --- /dev/null +++ b/.github/sandbox-kubernetes-e2e/app-values.yaml @@ -0,0 +1,51 @@ +# Helm values for the e2e-app job in .github/workflows/sandbox.yml, +# layered on helm/sim/ci/default-values.yaml and values.yaml. The app, migrations, +# and sandbox images are built from this checkout and imported into k3s under these +# references, so nothing is pulled for them. Secrets are passed with --set from +# per-run random values. Dummy sizing for one CI node; never use in a deployment. +app: + image: + tag: sandbox-e2e + resources: + requests: + cpu: 200m + memory: 512Mi + limits: + cpu: 2000m + memory: 3Gi + +migrations: + image: + tag: sandbox-e2e + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + memory: 1Gi + +# Not needed to execute a workflow over the API; skipping it saves an image build. +realtime: + enabled: false + +# The job calls the session-sandbox sweep itself, at the moment it asserts on it. +cronjobs: + enabled: false + +postgresql: + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + memory: 1Gi + persistence: + size: 2Gi + +redis: + resources: + requests: + cpu: 25m + memory: 64Mi + limits: + memory: 256Mi diff --git a/.github/sandbox-kubernetes-e2e/guard-runtimeclass.yaml b/.github/sandbox-kubernetes-e2e/guard-runtimeclass.yaml new file mode 100644 index 00000000000..f865616247e --- /dev/null +++ b/.github/sandbox-kubernetes-e2e/guard-runtimeclass.yaml @@ -0,0 +1,8 @@ +# A shared-kernel RuntimeClass the provider's isolation guard must refuse. The +# chart never creates a runc or crun class, so the live suite's guard check +# brings its own. +apiVersion: node.k8s.io/v1 +kind: RuntimeClass +metadata: + name: sim-e2e-runc +handler: runc diff --git a/.github/sandbox-kubernetes-e2e/values.yaml b/.github/sandbox-kubernetes-e2e/values.yaml new file mode 100644 index 00000000000..188059975a0 --- /dev/null +++ b/.github/sandbox-kubernetes-e2e/values.yaml @@ -0,0 +1,31 @@ +# Helm values for the e2e jobs in .github/workflows/sandbox.yml, layered on +# helm/sim/ci/default-values.yaml. Rendered with envsubst for NODE_IP (the +# runner, which pods reach at that address) and ALLOWED_PORT (the live suite's +# stand-in object store). Dummy sizing for one CI node; never use in a deployment. +sandbox: + kubernetes: + enabled: true + # k3s has no RuntimeClass of its own, so the chart creates `gvisor` (handler + # runsc), which the k3s-gvisor action registers with containerd. + runtimeClass: + preset: gvisor + create: true + resources: + cpu: "1" + memory: 1Gi + ephemeralStorage: 2Gi + egress: + profile: internet + # The operator allowlist entry for object storage: URL mounts are fetched + # from inside the sandbox, so a private object store stays reachable. + # Here that is the live suite's stand-in on the node, one port only. + extraRules: + - to: + - ipBlock: + cidr: ${NODE_IP}/32 + ports: + - protocol: TCP + port: ${ALLOWED_PORT} + +networkPolicy: + enabled: true diff --git a/.github/workflows/helm.yml b/.github/workflows/helm.yml index 65580e12bb9..d5192c37c17 100644 --- a/.github/workflows/helm.yml +++ b/.github/workflows/helm.yml @@ -121,23 +121,24 @@ jobs: echo "95f14e87aa28c09d5941f11bd024c1d02fdc0303ccaa23f61cef67bc92619d73 /tmp/kubeconform.tar.gz" | sha256sum -c - tar -xzf /tmp/kubeconform.tar.gz -C /tmp kubeconform - - name: Render and validate manifests (default configuration) + # The sandbox provider's admission policy is admissionregistration.k8s.io/v1, + # which Kubernetes 1.30 introduced, so its render validates against 1.30. + - name: Render and validate manifests run: | - helm template sim helm/sim --namespace sim \ - --values helm/sim/ci/default-values.yaml \ - | /tmp/kubeconform -strict -summary \ - -kubernetes-version 1.29.0 \ - -schema-location default \ - -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' - - - name: Render and validate manifests (all components enabled) - run: | - helm template sim helm/sim --namespace sim \ - --values helm/sim/ci/full-values.yaml \ - | /tmp/kubeconform -strict -summary \ - -kubernetes-version 1.29.0 \ - -schema-location default \ - -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' + set -euo pipefail + for values in default full sandbox-kubernetes; do + kubernetes_version=1.29.0 + if [ "$values" = sandbox-kubernetes ]; then + kubernetes_version=1.30.0 + fi + echo "--- ci/${values}-values.yaml (Kubernetes ${kubernetes_version})" + helm template sim helm/sim --namespace sim \ + --values "helm/sim/ci/${values}-values.yaml" \ + | /tmp/kubeconform -strict -summary \ + -kubernetes-version "$kubernetes_version" \ + -schema-location default \ + -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' + done - name: Render every example values file run: | diff --git a/.github/workflows/sandbox.yml b/.github/workflows/sandbox.yml new file mode 100644 index 00000000000..745c12d9c7f --- /dev/null +++ b/.github/workflows/sandbox.yml @@ -0,0 +1,1166 @@ +name: sandbox + +# The self-hosted Kubernetes sandbox provider: its images, their publishing and +# release verification, and its end-to-end tests on a real cluster. One workflow, so +# a pull request builds each sandbox image once and both e2e jobs run that build. +# +# Images. ghcr.io/simstudioai/sandbox-function, sandbox-pi and sandbox-agent are +# content-addressed: `bun run generate:sandbox-dockerfiles` hashes each image's +# build inputs into its tag and commits the references to +# apps/sim/lib/execution/remote-sandbox/kubernetes/images.generated.json, which the +# app and the Helm chart default to. A Sim release therefore references exact images +# and needs no per-release build, and no mutable tag (latest, version) ever moves. +# Every change to an image's inputs changes that file (check:sandbox-dockerfiles +# fails otherwise), so it is the push path filter. +# +# pull_request Builds each image whose reference differs from the base branch's, +# for both architectures, and verifies it; a change to the +# verification itself rebuilds amd64 only. Runs the e2e jobs when +# the provider's inputs change. Never publishes. +# push (main, staging) Publishes each reference that is missing from GHCR +# or not yet signed by this workflow, then signs and attests it. +# release Verifies every reference at the release commit is published, +# multi-arch, and signed, waiting out a publish still in flight. +# schedule The same check, daily, for the default branch and latest release. +# workflow_dispatch +# mode=publish publishes from main or staging, and is a dry run (build +# and verify, no push) from any other branch. mode=verify only +# verifies. mode=e2e runs both e2e jobs. +# +# e2e. k3s with gVisor (runsc) as the sandbox RuntimeClass and k3s's built-in +# kube-router NetworkPolicy controller (.github/actions/k3s-gvisor); the sandbox +# namespace, RBAC, and NetworkPolicies come from the Helm chart. +# +# e2e-provider The provider driven through the app's own code paths by +# apps/sim/lib/execution/remote-sandbox/kubernetes.live.test.ts, from +# the runner, as the chart's least-privilege app service account. +# e2e-app The real app image installed by the chart, executing Function +# blocks through the public API +# (apps/sim/scripts/test-sandbox-kubernetes-app-e2e.ts), with the +# chart's admission policy active. +# app-image The app and migrations images, built as ci.yml builds them (runner +# class, image action, layer cache budget) on their own cache key. +# PR CI otherwise never builds the app image, so a dependency that +# breaks docker/app.Dockerfile's hoisted install fails here. +# +# Its own workflow rather than ci.yml jobs: the multi-arch builds run far longer than +# a deploy, ci.yml's concurrency group would hold the next deploy behind them, and +# nothing in ci.yml (promote, ghcr, attest, release) may wait on these images. No job +# here is a required check. Neither e2e job runs for an E2B- or Daytona-only change; +# the exclusions below and in `plan` are the same list. + +on: + push: + branches: [main, staging] + paths: + - 'apps/sim/lib/execution/remote-sandbox/kubernetes/images.generated.json' + - '.github/workflows/sandbox.yml' + pull_request: + branches: [main, staging, dev] + paths: + # The provider, its agent handle, and the shared sandbox code the suites drive + # (index.ts, code-process.ts, login-shell.ts, process-environment.ts, ...), not + # the E2B and Daytona providers or their tests. Order matters: an exclusion + # applies to the patterns above it. + - 'apps/sim/lib/execution/remote-sandbox/*.ts' + - '!apps/sim/lib/execution/remote-sandbox/e2b*.ts' + - '!apps/sim/lib/execution/remote-sandbox/daytona*.ts' + - '!apps/sim/lib/execution/remote-sandbox/conformance*.ts' + - 'apps/sim/lib/execution/remote-sandbox/kubernetes/**' + - 'apps/sim/lib/execution/remote-sandbox/agent/**' + - 'apps/sim/app/api/cron/cleanup-session-sandboxes/**' + - 'apps/sim/scripts/test-sandbox-kubernetes-e2e.ts' + - 'apps/sim/scripts/test-sandbox-kubernetes-app-e2e.ts' + # The sandbox images' recipes, content-addressed tags, and verification. + - 'apps/sim/scripts/generate-sandbox-dockerfiles.ts' + - 'apps/sim/scripts/function-sandbox-packages.ts' + - 'apps/sim/scripts/pi-sandbox-packages.ts' + - 'apps/sim/scripts/verify-sandbox-image.ts' + - 'apps/sim/scripts/function-sandbox-parity-manifest.ts' + - 'apps/sandbox-agent/**' + - 'packages/sandbox-agent-protocol/**' + - 'docker/sandbox-*.Dockerfile' + - 'helm/sim/templates/**/*sandbox*' + - 'helm/sim/templates/networkpolicy.yaml' + - 'helm/sim/templates/deployment-app.yaml' + - 'helm/sim/templates/serviceaccount.yaml' + - 'helm/sim/templates/_helpers.tpl' + - 'helm/sim/values.yaml' + - 'helm/sim/values.schema.json' + - 'helm/sim/ci/default-values.yaml' + - '.github/sandbox-kubernetes-e2e/**' + - '.github/actions/image/**' + - '.github/actions/sandbox-image/**' + - '.github/actions/attest-image/**' + - '.github/actions/k3s-*/**' + - '.github/actions/setup/**' + - '.github/workflows/sandbox.yml' + # The app and migrations images' inputs, for e2e-app alone. + - 'docker/app.Dockerfile' + - 'docker/db.Dockerfile' + - 'bun.lock' + - 'apps/sim/package.json' + release: + types: [published] + schedule: + - cron: '17 6 * * *' + workflow_dispatch: + inputs: + mode: + description: publish (a dry run off main and staging), verify, or e2e + type: choice + options: [publish, verify, e2e] + default: publish + +permissions: + contents: read + +# Pull requests cancel a superseded run. Publishing never does, so a newer push +# cannot cut off a publish in flight, and verification and e2e runs queue apart from +# it on the same ref. +concurrency: + group: >- + ${{ github.event_name == 'pull_request' && format('sandbox-pr-{0}', github.event.pull_request.number) + || format('sandbox-{0}-{1}', + (github.event_name == 'release' || github.event_name == 'schedule' || inputs.mode == 'verify') && 'verify' + || inputs.mode == 'e2e' && 'e2e' || 'publish', + github.ref_name) }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +env: + IMAGE_MANIFEST: apps/sim/lib/execution/remote-sandbox/kubernetes/images.generated.json + # The keyless identity build and publish sign with. Only main and staging publish, + # so only their runs are trusted, here and in the operator docs. + SIGNER_IDENTITY_REGEXP: ^https://github\.com/${{ github.repository }}/\.github/workflows/sandbox\.yml@refs/heads/(main|staging)$ + SIGNER_OIDC_ISSUER: https://token.actions.githubusercontent.com + RELEASE_NAMESPACE: sim + SANDBOX_NAMESPACE: sim-sandboxes + ALLOWED_PORT: '18080' + DENIED_PORT: '18081' + +jobs: + # Decides every other job's work, once. A pull request builds an image whose + # reference differs from the base branch's, plus an amd64 build of any image an e2e + # job needs that GHCR does not have; amd64 builds an e2e job needs upload their + # archive. A publish skips an image whose index exists and carries this workflow's + # signature, only joins and signs the index when both per-arch images are already + # published and signed (a publish that failed before signing), and otherwise builds + # both architectures. + plan: + name: plan + if: >- + github.event_name == 'pull_request' || github.event_name == 'push' || + (github.event_name == 'workflow_dispatch' && inputs.mode != 'verify') + runs-on: ubuntu-24.04 + timeout-minutes: 10 + permissions: + contents: read + packages: read + pull-requests: read + outputs: + publish: ${{ steps.plan.outputs.publish }} + legs: ${{ steps.plan.outputs.legs }} + kinds: ${{ steps.plan.outputs.kinds }} + archives: ${{ steps.plan.outputs.archives }} + e2e_provider: ${{ steps.plan.outputs.e2e_provider }} + e2e_app: ${{ steps.plan.outputs.e2e_app }} + steps: + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 + with: + persist-credentials: false + + # e2e_provider is the trigger's list without the app image's inputs. An + # exclusion is final under some-with-excludes, unlike in the `paths` trigger. + - name: Filter changed paths + id: filter + if: github.event_name == 'pull_request' + uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4 + with: + predicate-quantifier: some-with-excludes + filters: | + e2e_provider: + - 'apps/sim/lib/execution/remote-sandbox/*.ts' + - '!apps/sim/lib/execution/remote-sandbox/e2b*.ts' + - '!apps/sim/lib/execution/remote-sandbox/daytona*.ts' + - '!apps/sim/lib/execution/remote-sandbox/conformance*.ts' + - 'apps/sim/lib/execution/remote-sandbox/kubernetes/**' + - 'apps/sim/lib/execution/remote-sandbox/agent/**' + - 'apps/sim/app/api/cron/cleanup-session-sandboxes/**' + - 'apps/sim/scripts/test-sandbox-kubernetes-e2e.ts' + - 'apps/sim/scripts/test-sandbox-kubernetes-app-e2e.ts' + - 'apps/sim/scripts/generate-sandbox-dockerfiles.ts' + - 'apps/sim/scripts/function-sandbox-packages.ts' + - 'apps/sim/scripts/pi-sandbox-packages.ts' + - 'apps/sandbox-agent/**' + - 'packages/sandbox-agent-protocol/**' + - 'docker/sandbox-*.Dockerfile' + - 'helm/sim/templates/**/*sandbox*' + - 'helm/sim/templates/networkpolicy.yaml' + - 'helm/sim/templates/serviceaccount.yaml' + - 'helm/sim/templates/_helpers.tpl' + - 'helm/sim/values.yaml' + - 'helm/sim/values.schema.json' + - 'helm/sim/ci/default-values.yaml' + - '.github/sandbox-kubernetes-e2e/**' + - '.github/actions/k3s-*/**' + - '.github/actions/setup/**' + - '.github/workflows/sandbox.yml' + e2e_app: + - 'apps/sim/lib/execution/remote-sandbox/kubernetes/**' + - 'apps/sim/lib/execution/remote-sandbox/agent/**' + - 'apps/sim/scripts/test-sandbox-kubernetes-app-e2e.ts' + - 'apps/sandbox-agent/**' + - 'packages/sandbox-agent-protocol/**' + - 'helm/sim/templates/sandbox-kubernetes.yaml' + - 'helm/sim/templates/sandbox-admission-policy.yaml' + - 'helm/sim/templates/networkpolicy.yaml' + - 'helm/sim/templates/deployment-app.yaml' + - 'helm/sim/templates/serviceaccount.yaml' + - 'helm/sim/templates/_helpers.tpl' + - 'helm/sim/ci/default-values.yaml' + - '.github/sandbox-kubernetes-e2e/**' + - '.github/actions/image/**' + - '.github/actions/k3s-*/**' + - '.github/actions/setup/**' + - '.github/workflows/sandbox.yml' + - 'docker/app.Dockerfile' + - 'docker/db.Dockerfile' + - 'bun.lock' + - 'apps/sim/package.json' + verification: + - '.github/workflows/sandbox.yml' + - '.github/actions/image/**' + - '.github/actions/sandbox-image/**' + - 'apps/sim/scripts/verify-sandbox-image.ts' + - 'apps/sim/scripts/function-sandbox-parity-manifest.ts' + + - name: Login to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Install Cosign + if: github.event_name != 'pull_request' + uses: sigstore/cosign-installer@881c63bd87e38389154debd8331404ce7ca8a3ab # v4.1.4 + + - name: Plan builds + id: plan + env: + GH_TOKEN: ${{ github.token }} + EVENT_NAME: ${{ github.event_name }} + MODE: ${{ inputs.mode }} + REPO: ${{ github.repository }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + CHANGED_E2E_PROVIDER: ${{ steps.filter.outputs.e2e_provider }} + CHANGED_E2E_APP: ${{ steps.filter.outputs.e2e_app }} + CHANGED_VERIFICATION: ${{ steps.filter.outputs.verification }} + run: | + set -euo pipefail + + # Succeeds when the reference exists and fails when the registry says it + # is absent. "denied" is what GHCR answers for a package not created yet, + # and reading it as absent only rebuilds. A publish aborts on anything + # else, since reading a registry hiccup as "present" would skip a publish; + # a pull request or e2e plan reads every failure as absent, which only + # costs a build. + image_exists() { + local ref="$1" attempt err absent=0 + for attempt in 1 2 3; do + if docker buildx imagetools inspect "$ref" > /dev/null 2> /tmp/inspect.err; then + return 0 + fi + err="$(cat /tmp/inspect.err)" + case "$err" in + *"not found"*|*MANIFEST_UNKNOWN*|*"no such manifest"*|*NAME_UNKNOWN*|*denied*) absent=1 ;; + *) absent=0 ;; + esac + if [ "$absent" -eq 1 ] || [ "$publish" != "true" ]; then + return 1 + fi + if [ "$attempt" -lt 3 ]; then + sleep "$((attempt * 3))" + fi + done + echo "::error::Could not inspect ${ref} after 3 attempts: ${err}" >&2 + exit 1 + } + + # Any failure counts as unsigned, which only ever means more work. + is_signed() { + cosign verify \ + --certificate-identity-regexp "$SIGNER_IDENTITY_REGEXP" \ + --certificate-oidc-issuer "$SIGNER_OIDC_ISSUER" \ + "$1" > /dev/null 2>&1 + } + + arch_images_ready() { + local ref="$1" arch + for arch in amd64 arm64; do + image_exists "${ref}-${arch}" || return 1 + is_signed "${ref}-${arch}" || return 1 + done + } + + : > /tmp/legs.jsonl + : > /tmp/kinds.jsonl + : > /tmp/archives.txt + add_legs() { + local kind="$1" ref="$2" arch + shift 2 + for arch in "$@"; do + jq -nc --arg kind "$kind" --arg ref "$ref" --arg arch "$arch" \ + '{kind: $kind, ref: $ref, arch: $arch}' >> /tmp/legs.jsonl + done + } + has_leg() { + jq -e --arg kind "$1" --arg arch "$2" 'select(.kind == $kind and .arch == $arch)' \ + /tmp/legs.jsonl > /dev/null + } + + # Only main and staging publish; a dispatch anywhere else is a dry run. + publish=false + e2e_provider=false + e2e_app=false + case "$EVENT_NAME" in + push) + publish=true ;; + workflow_dispatch) + if [ "$MODE" = "e2e" ]; then + e2e_provider=true + e2e_app=true + elif [ "$GITHUB_REF" = "refs/heads/main" ] || [ "$GITHUB_REF" = "refs/heads/staging" ]; then + publish=true + fi ;; + pull_request) + e2e_provider="${CHANGED_E2E_PROVIDER:-false}" + e2e_app="${CHANGED_E2E_APP:-false}" + if base_json="$(gh api "repos/${REPO}/contents/${IMAGE_MANIFEST}?ref=${BASE_SHA}" --jq .content 2> /tmp/gh.err)"; then + base_manifest="$(printf '%s' "$base_json" | base64 -d)" + elif grep -q 'HTTP 404' /tmp/gh.err; then + base_manifest='{}' + else + echo "::error::Could not read the base branch's image references: $(cat /tmp/gh.err)" + exit 1 + fi ;; + esac + + for kind in $(jq -r 'keys_unsorted[]' "$IMAGE_MANIFEST"); do + ref="$(jq -r --arg kind "$kind" '.[$kind]' "$IMAGE_MANIFEST")" + if [ "$publish" = "true" ] || { [ "$EVENT_NAME" = "workflow_dispatch" ] && [ "$MODE" = "publish" ]; }; then + if image_exists "$ref" && is_signed "$ref"; then + echo "${ref} is published and signed; skipping." + continue + fi + if [ "$publish" = "true" ] && arch_images_ready "$ref"; then + echo "${ref}: both architectures are published and signed; publishing the index only." + else + echo "${ref} is missing or unsigned; building." + add_legs "$kind" "$ref" amd64 arm64 + fi + if [ "$publish" = "true" ]; then + jq -nc --arg kind "$kind" --arg ref "$ref" '{kind: $kind, ref: $ref}' >> /tmp/kinds.jsonl + fi + elif [ "$EVENT_NAME" = "pull_request" ]; then + base_ref="$(printf '%s' "$base_manifest" | jq -r --arg kind "$kind" '.[$kind] // empty')" + if [ "$ref" != "$base_ref" ]; then + echo "${kind} inputs changed (${base_ref:-none} -> ${ref}); building both architectures." + add_legs "$kind" "$ref" amd64 arm64 + elif [ "$CHANGED_VERIFICATION" = "true" ]; then + echo "Verification changed; building ${kind} for amd64." + add_legs "$kind" "$ref" amd64 + fi + fi + done + + # The images each e2e job runs: e2e-app the agent and Function, and + # e2e-provider Pi as well. One GHCR does not have is built for amd64 here, + # and every amd64 build of one uploads its archive for them. + e2e_kinds='' + if [ "$e2e_app" = "true" ]; then + e2e_kinds='agent function' + fi + if [ "$e2e_provider" = "true" ]; then + e2e_kinds='agent function pi' + fi + for kind in $e2e_kinds; do + ref="$(jq -er --arg kind "$kind" '.[$kind]' "$IMAGE_MANIFEST")" + if ! has_leg "$kind" amd64; then + if image_exists "$ref"; then + echo "${ref} is in GHCR; the e2e jobs pull it." + continue + fi + echo "${ref} is not in GHCR; building it for the e2e jobs." + add_legs "$kind" "$ref" amd64 + fi + echo "$kind" >> /tmp/archives.txt + done + + { + echo "publish=${publish}" + echo "legs=$(jq -sc . /tmp/legs.jsonl)" + echo "kinds=$(jq -sc . /tmp/kinds.jsonl)" + echo "archives=$(jq -Rsc 'split("\n") | map(select(. != ""))' /tmp/archives.txt)" + echo "e2e_provider=${e2e_provider}" + echo "e2e_app=${e2e_app}" + } >> "$GITHUB_OUTPUT" + cat /tmp/legs.jsonl + + # One leg per image and architecture, each on a native runner, built into the + # local daemon and verified. Every run that does not publish (pull requests, a + # dry-run or e2e dispatch) builds here, with a read-only token: a pull request's + # checkout controls this job's code, and GitHub grants a same-repository pull + # request's token whatever write permissions its job asks for. amd64 builds an + # e2e job needs upload their archive. + image: + name: image (${{ matrix.kind }}, ${{ matrix.arch }}) + needs: [plan] + if: needs.plan.outputs.legs != '[]' && needs.plan.outputs.publish != 'true' + runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && (matrix.arch == 'arm64' && 'blacksmith-4vcpu-ubuntu-2404-arm' || 'blacksmith-4vcpu-ubuntu-2404') || (matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest') }} + timeout-minutes: 45 + permissions: + contents: read + strategy: + fail-fast: false + matrix: + include: ${{ fromJSON(needs.plan.outputs.legs) }} + env: + ARCHIVE: ${{ matrix.arch == 'amd64' && contains(fromJSON(needs.plan.outputs.archives), matrix.kind) }} + ARCH_REF: ${{ matrix.ref }}-${{ matrix.arch }} + steps: + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 + with: + persist-credentials: false + + - name: Build and verify image + uses: ./.github/actions/sandbox-image + with: + provider: ${{ vars.CI_PROVIDER }} + kind: ${{ matrix.kind }} + arch: ${{ matrix.arch }} + tag: ${{ env.ARCH_REF }} + + # Under the reference the app defaults to, which is what pods name in k3s. + - name: Save image + if: env.ARCHIVE == 'true' + env: + REF: ${{ matrix.ref }} + run: | + set -euo pipefail + mkdir -p "$RUNNER_TEMP/sandbox-image" + docker tag "$ARCH_REF" "$REF" + printf '%s' "$REF" > "$RUNNER_TEMP/sandbox-image/ref" + docker save --output "$RUNNER_TEMP/sandbox-image/image.tar" "$REF" + + - name: Upload image + if: env.ARCHIVE == 'true' + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: sandbox-image-${{ matrix.kind }} + path: ${{ runner.temp }}/sandbox-image/ + if-no-files-found: error + retention-days: 1 + compression-level: 1 + + # The publishing legs: the same build and verification, then the pushed + # `-` is signed and attested in the same leg, so a later failure never + # leaves a published digest unsigned. The only job holding registry-write and + # signing permissions besides `publish`, and it never runs for a pull request: + # only for a push to, or a dispatch on, main or staging. + image-publish: + name: image-publish (${{ matrix.kind }}, ${{ matrix.arch }}) + needs: [plan] + if: >- + needs.plan.outputs.legs != '[]' && + needs.plan.outputs.publish == 'true' && + (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && + (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') + runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && (matrix.arch == 'arm64' && 'blacksmith-4vcpu-ubuntu-2404-arm' || 'blacksmith-4vcpu-ubuntu-2404') || (matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest') }} + timeout-minutes: 45 + permissions: + contents: read + packages: write + id-token: write + attestations: write + artifact-metadata: write + strategy: + fail-fast: false + matrix: + include: ${{ fromJSON(needs.plan.outputs.legs) }} + env: + ARCH_REF: ${{ matrix.ref }}-${{ matrix.arch }} + steps: + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 + with: + persist-credentials: false + + - name: Login to Docker Hub + uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GHCR + uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and verify image + uses: ./.github/actions/sandbox-image + with: + provider: ${{ vars.CI_PROVIDER }} + kind: ${{ matrix.kind }} + arch: ${{ matrix.arch }} + tag: ${{ env.ARCH_REF }} + + - name: Push image + id: push + run: | + set -euo pipefail + docker push "$ARCH_REF" + digest="$(docker buildx imagetools inspect "$ARCH_REF" --format '{{json .Manifest}}' | jq -r '.digest // empty')" + if [ -z "$digest" ]; then + echo "::error::Pushed ${ARCH_REF} but could not resolve its digest" + exit 1 + fi + echo "image=${ARCH_REF%:*}" >> "$GITHUB_OUTPUT" + echo "digest=${digest}" >> "$GITHUB_OUTPUT" + + - name: Attest and sign image + uses: ./.github/actions/attest-image + with: + image: ${{ steps.push.outputs.image }} + digest: ${{ steps.push.outputs.digest }} + sbom-image: ${{ env.ARCH_REF }} + + # Joins the two architectures under the content tag the app references, then signs + # and attests that index. Runs after a failed image-publish leg too, so the other + # kinds and the index-only retry still publish; a kind joins only when both + # architectures are published and signed by this workflow, so a leg that pushed but + # failed to attest or sign is never exposed, and the next run rebuilds it. + publish: + name: publish (${{ matrix.kind }}) + needs: [plan, image-publish] + if: >- + !cancelled() && + needs.plan.outputs.publish == 'true' && + needs.plan.outputs.kinds != '[]' && + (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && + (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') + runs-on: ubuntu-24.04 + timeout-minutes: 15 + permissions: + contents: read + packages: write + id-token: write + attestations: write + artifact-metadata: write + strategy: + fail-fast: false + matrix: + include: ${{ fromJSON(needs.plan.outputs.kinds) }} + steps: + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 + with: + persist-credentials: false + + - name: Login to GHCR + uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Install Cosign + uses: sigstore/cosign-installer@881c63bd87e38389154debd8331404ce7ca8a3ab # v4.1.4 + + - name: Publish the multi-arch content tag + id: index + env: + REF: ${{ matrix.ref }} + KIND: ${{ matrix.kind }} + run: | + set -euo pipefail + for arch in amd64 arm64; do + if ! docker buildx imagetools inspect "${REF}-${arch}" > /dev/null; then + echo "::error::${REF}-${arch} is not published; not publishing ${REF}" + exit 1 + fi + # The image-publish leg signs last, after both attestations, so a signature means + # the leg finished. + if ! cosign verify \ + --certificate-identity-regexp "$SIGNER_IDENTITY_REGEXP" \ + --certificate-oidc-issuer "$SIGNER_OIDC_ISSUER" \ + "${REF}-${arch}" > /dev/null; then + echo "::error::${REF}-${arch} is not signed by this workflow; not publishing ${REF}" + exit 1 + fi + done + docker buildx imagetools create -t "$REF" "${REF}-amd64" "${REF}-arm64" + digest="$(docker buildx imagetools inspect "$REF" --format '{{json .Manifest}}' | jq -r '.digest // empty')" + if [ -z "$digest" ]; then + echo "::error::Published ${REF} but could not resolve its digest" + exit 1 + fi + echo "image=${REF%:*}" >> "$GITHUB_OUTPUT" + echo "digest=${digest}" >> "$GITHUB_OUTPUT" + { + echo "### sandbox-${KIND}" + echo + echo "\`${REF}@${digest}\`" + } >> "$GITHUB_STEP_SUMMARY" + + - name: Attest and sign image + uses: ./.github/actions/attest-image + with: + image: ${{ steps.index.outputs.image }} + digest: ${{ steps.index.outputs.digest }} + + # Checks what an operator gets: every reference in images.generated.json at the + # commit, pulled anonymously, is a linux/amd64 + linux/arm64 index signed by a main + # or staging run of this workflow. Anonymous on purpose: a package GHCR serves only + # to members fails here exactly as it fails an operator's pull. A release waits for + # a publish still in flight, since the release and the images' publish start from + # the same push. + verify: + name: verify + if: >- + github.event_name == 'release' || github.event_name == 'schedule' || + (github.event_name == 'workflow_dispatch' && inputs.mode == 'verify') + runs-on: ubuntu-24.04 + timeout-minutes: 60 + permissions: + contents: read + steps: + - name: Install Cosign + uses: sigstore/cosign-installer@881c63bd87e38389154debd8331404ce7ca8a3ab # v4.1.4 + + - name: Verify published images + env: + GH_TOKEN: ${{ github.token }} + EVENT_NAME: ${{ github.event_name }} + REPO: ${{ github.repository }} + SHA: ${{ github.sha }} + run: | + set -euo pipefail + + # The commits to check, as "label commit" lines. + if [ "$EVENT_NAME" = "schedule" ]; then + default_branch="$(gh api "repos/${REPO}" --jq .default_branch)" + targets="${default_branch} $(gh api "repos/${REPO}/commits/${default_branch}" --jq .sha)" + if latest="$(gh api "repos/${REPO}/releases/latest" --jq .tag_name 2> /dev/null)"; then + targets+=$'\n'"${latest} ${latest}" + fi + else + targets="${GITHUB_REF_NAME} ${SHA}" + fi + + wait_minutes=0 + if [ "$EVENT_NAME" = "release" ]; then + wait_minutes=45 + fi + deadline=$(( $(date +%s) + 60 * wait_minutes )) + check_ref() { + local ref="$1" platforms + if ! platforms="$(docker buildx imagetools inspect "$ref" --format '{{json .Manifest}}' 2> /tmp/inspect.err \ + | jq -r '[.manifests[]?.platform | select(.os != "unknown") | "\(.os)/\(.architecture)"] | sort | join(",")')"; then + echo "not published ($(head -c 200 /tmp/inspect.err | tr '\n' ' '))" + return 1 + fi + if [ "$platforms" != "linux/amd64,linux/arm64" ]; then + echo "platforms are '${platforms}', not linux/amd64,linux/arm64" + return 1 + fi + if ! cosign verify \ + --certificate-identity-regexp "$SIGNER_IDENTITY_REGEXP" \ + --certificate-oidc-issuer "$SIGNER_OIDC_ISSUER" \ + "$ref" > /dev/null 2> /tmp/cosign.err; then + echo "not signed by sandbox.yml on main or staging" + return 1 + fi + echo "ok" + } + + { + echo "### Sandbox images" + echo + echo "| Commit | Image | Result |" + echo "|---|---|---|" + } >> "$GITHUB_STEP_SUMMARY" + failures=0 + # On fd 3, so nothing in the loop can read the list from stdin. + while read -r -u 3 label commit; do + if ! content="$(gh api "repos/${REPO}/contents/${IMAGE_MANIFEST}?ref=${commit}" --jq .content 2> /tmp/gh.err)"; then + if grep -q 'HTTP 404' /tmp/gh.err; then + echo "${label} has no ${IMAGE_MANIFEST}; nothing to verify." + echo "| ${label} | none | no sandbox images at this commit |" >> "$GITHUB_STEP_SUMMARY" + continue + fi + echo "::error::Could not read ${IMAGE_MANIFEST} at ${label}: $(cat /tmp/gh.err)" + exit 1 + fi + for ref in $(printf '%s' "$content" | base64 -d | jq -r '.[]'); do + while true; do + if result="$(check_ref "$ref")"; then + break + fi + if [ "$(date +%s)" -ge "$deadline" ]; then + break + fi + echo "${ref}: ${result}; waiting for its publish." + sleep 120 + done + echo "${label} ${ref}: ${result}" + echo "| ${label} | \`${ref}\` | ${result} |" >> "$GITHUB_STEP_SUMMARY" + if [ "$result" != "ok" ]; then + echo "::error::${ref} (${label}): ${result}" + failures=$((failures + 1)) + fi + done + done 3<<< "$targets" + if [ "$failures" -gt 0 ]; then + echo "::error::${failures} sandbox image reference(s) are not published and signed; operators on these commits cannot start sandboxes. Run this workflow with mode=publish on main or staging." + exit 1 + fi + + # A cold `next build` peaks near 51 GB (see checks.yml's `build` job), past what + # an 8-core GitHub VM has, let alone one also running k3s, where it was killed + # while collecting page data. So the app image builds where ci.yml builds it, with + # the same layer cache budget but its own sticky disk (the `-e2e` cache key), so a + # pull request never overwrites the deploy pipeline's cache, and e2e-app only + # imports it. Each leg uploads `app-image-` in the sandbox images' layout. + app-image: + name: app-image (${{ matrix.id }}) + needs: [plan] + if: needs.plan.outputs.e2e_app == 'true' + runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && matrix.bs_runner || matrix.gh_runner }} + timeout-minutes: 45 + strategy: + fail-fast: true + matrix: + include: + - id: app + dockerfile: ./docker/app.Dockerfile + tag: ghcr.io/simstudioai/simstudio:sandbox-e2e + cache_mb: '102400' + gh_runner: linux-x64-8-core + bs_runner: blacksmith-16vcpu-ubuntu-2404 + - id: migrations + dockerfile: ./docker/db.Dockerfile + tag: ghcr.io/simstudioai/migrations:sandbox-e2e + gh_runner: ubuntu-latest + bs_runner: blacksmith-2vcpu-ubuntu-2404 + steps: + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 + with: + persist-credentials: false + + # The references app-values.yaml points the chart at (global.imageRegistry + # ghcr.io + the chart's repositories + tag sandbox-e2e). + - name: Build image + uses: ./.github/actions/image + with: + provider: ${{ vars.CI_PROVIDER }} + file: ${{ matrix.dockerfile }} + platforms: linux/amd64 + tags: ${{ matrix.tag }} + push: 'false' + load: 'true' + cache-key-suffix: -e2e + max-cache-size-mb: ${{ matrix.cache_mb }} + + - name: Save image + env: + IMAGE: ${{ matrix.tag }} + run: | + set -euo pipefail + mkdir -p "$RUNNER_TEMP/app-image" + printf '%s' "$IMAGE" > "$RUNNER_TEMP/app-image/ref" + docker save --output "$RUNNER_TEMP/app-image/image.tar" "$IMAGE" + + - name: Upload image + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: app-image-${{ matrix.id }} + path: ${{ runner.temp }}/app-image/ + if-no-files-found: error + retention-days: 1 + compression-level: 1 + + e2e-provider: + name: e2e-provider + needs: [plan, image] + if: >- + !cancelled() && needs.plan.outputs.e2e_provider == 'true' && + (needs.image.result == 'success' || needs.image.result == 'skipped') + # GitHub-hosted: nested gVisor needs a plain VM, not a microVM runner. + runs-on: ubuntu-24.04 + timeout-minutes: 30 + steps: + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 + with: + persist-credentials: false + + - name: Start k3s with gVisor + uses: ./.github/actions/k3s-gvisor + + # The references the provider defaults to, so pods start without pulling. + - name: Load agent image + id: agent + uses: ./.github/actions/k3s-image + with: + kind: agent + archive: ${{ contains(fromJSON(needs.plan.outputs.archives), 'agent') }} + + - name: Load Function image + id: function + uses: ./.github/actions/k3s-image + with: + kind: function + archive: ${{ contains(fromJSON(needs.plan.outputs.archives), 'function') }} + + - name: Load Pi image + id: pi + uses: ./.github/actions/k3s-image + with: + kind: pi + archive: ${{ contains(fromJSON(needs.plan.outputs.archives), 'pi') }} + + # NODE_IP is the runner, which pods reach at that address; ALLOWED_PORT is the + # live suite's stand-in object store. + - &render-sandbox-values + name: Render the sandbox values + run: | + set -euo pipefail + envsubst "\$NODE_IP \$ALLOWED_PORT" < .github/sandbox-kubernetes-e2e/values.yaml > "$RUNNER_TEMP/sandbox-values.yaml" + + # Only the chart's sandbox objects and the app's ServiceAccount: the suite + # stands in for the app from the runner. The runc RuntimeClass is the guard + # check's own fixture, since the chart never creates one. The admission policy + # is left out: the guard check's trusted-handler case starts a sandbox under + # that runc class on purpose, which the policy would refuse. e2e-app installs + # it. + - name: Apply the chart's sandbox manifests + run: | + set -euo pipefail + kubectl create namespace "$RELEASE_NAMESPACE" + helm template sim helm/sim --namespace "$RELEASE_NAMESPACE" \ + --values helm/sim/ci/default-values.yaml \ + --values "$RUNNER_TEMP/sandbox-values.yaml" \ + --show-only templates/serviceaccount.yaml \ + --show-only templates/sandbox-kubernetes.yaml \ + | kubectl apply -f - + kubectl apply -f .github/sandbox-kubernetes-e2e/guard-runtimeclass.yaml + + - name: Verify pods run under gVisor + env: + FUNCTION_IMAGE: ${{ steps.function.outputs.ref }} + run: | + set -euo pipefail + kubectl run gvisor-check --namespace default --image "$FUNCTION_IMAGE" --restart Never \ + --overrides '{"apiVersion":"v1","spec":{"runtimeClassName":"gvisor"}}' --command -- dmesg + kubectl wait --namespace default --for=jsonpath='{.status.phase}'=Succeeded pod/gvisor-check --timeout=180s + kubectl logs --namespace default gvisor-check | tee /tmp/gvisor-dmesg.txt + grep -qi gvisor /tmp/gvisor-dmesg.txt + kubectl delete pod --namespace default gvisor-check --wait=false + + # The suite's denial checks pair with an allowed path, but this shows the + # controller enforces at all before any sandbox depends on it. + - name: Verify NetworkPolicy enforcement + env: + FUNCTION_IMAGE: ${{ steps.function.outputs.ref }} + run: | + set -euo pipefail + kubectl create namespace netpol-check + kubectl run server --namespace netpol-check --image "$FUNCTION_IMAGE" --restart Never \ + --labels app=server --command -- python3 -m http.server 8080 + kubectl wait --namespace netpol-check --for=condition=Ready pod/server --timeout=180s + server_ip="$(kubectl get pod server --namespace netpol-check -o jsonpath='{.status.podIP}')" + probe() { + kubectl run "client-$1" --namespace netpol-check --image "$FUNCTION_IMAGE" --restart Never \ + --rm --attach --quiet --command -- \ + python3 -c "import urllib.request; urllib.request.urlopen('http://${server_ip}:8080', timeout=5)" + } + # Ready only means the container started; wait until the server listens. + opened=false + for attempt in $(seq 1 6); do + if probe "open-${attempt}"; then + opened=true + break + fi + sleep 5 + done + if [ "$opened" != true ]; then + echo "::error::The NetworkPolicy check server never became reachable" + exit 1 + fi + kubectl apply --namespace netpol-check -f - <<'EOF' + apiVersion: networking.k8s.io/v1 + kind: NetworkPolicy + metadata: + name: deny-ingress + spec: + podSelector: + matchLabels: + app: server + policyTypes: [Ingress] + EOF + for attempt in $(seq 1 12); do + if ! probe "denied-${attempt}"; then + echo "Ingress denied after the policy applied." + kubectl delete namespace netpol-check --wait=false + exit 0 + fi + sleep 5 + done + echo "::error::NetworkPolicy is not enforced: the server stayed reachable" + exit 1 + + # The provider authenticates as the chart's app service account, not + # cluster-admin, so the suite also proves the chart's RBAC is enough. + - name: Create the app service account kubeconfig + run: | + set -euo pipefail + token="$(kubectl create token sim --namespace "$RELEASE_NAMESPACE" --duration 3h)" + server="$(kubectl config view --raw --minify -o jsonpath='{.clusters[0].cluster.server}')" + kubectl config view --raw --minify -o jsonpath='{.clusters[0].cluster.certificate-authority-data}' \ + | base64 -d > "$RUNNER_TEMP/cluster-ca.crt" + app_config="$RUNNER_TEMP/sim-app.kubeconfig" + kubectl config set-cluster e2e --server "$server" \ + --certificate-authority "$RUNNER_TEMP/cluster-ca.crt" --embed-certs --kubeconfig "$app_config" + kubectl config set-credentials sim-app --token "$token" --kubeconfig "$app_config" + kubectl config set-context e2e --cluster e2e --user sim-app \ + --namespace "$SANDBOX_NAMESPACE" --kubeconfig "$app_config" + kubectl config use-context e2e --kubeconfig "$app_config" + chmod 0600 "$app_config" + echo "APP_KUBECONFIG=${app_config}" >> "$GITHUB_ENV" + # A SelfSubjectAccessReview, not `kubectl auth can-i`, which misreports + # subresources on some kubectl versions. Schema validation is off because + # kubectl's lists CRDs first, which this account rightly cannot do. + expect_access() { + local verb="$1" subresource="$2" expected="$3" status + status="$(jq -n --arg namespace "$SANDBOX_NAMESPACE" --arg verb "$verb" \ + --arg subresource "$subresource" '{ + apiVersion: "authorization.k8s.io/v1", + kind: "SelfSubjectAccessReview", + spec: {resourceAttributes: ({namespace: $namespace, verb: $verb, resource: "pods"} + + if $subresource == "" then {} else {subresource: $subresource} end)} + }' \ + | KUBECONFIG="$app_config" kubectl create --validate=false -f - -o json \ + | jq -c '.status')" + if [ "$(jq -r '.allowed' <<< "$status")" != "$expected" ]; then + echo "::error::Expected allowed=${expected} for ${verb} pods${subresource:+/${subresource}} in ${SANDBOX_NAMESPACE}; the review returned ${status}" + exit 1 + fi + } + expect_access create '' true + for verb in create get; do + expect_access "$verb" exec false + done + + - name: Setup workspace + uses: ./.github/actions/setup + with: + provider: github + node-version: '' + + - name: Run the live suite + working-directory: apps/sim + env: + SANDBOX_PROVIDER: kubernetes + SANDBOX_K8S_NAMESPACE: ${{ env.SANDBOX_NAMESPACE }} + SANDBOX_K8S_RUNTIME_CLASS: gvisor + SANDBOX_K8S_AGENT_IMAGE: ${{ steps.agent.outputs.ref }} + SANDBOX_K8S_FUNCTION_IMAGE: ${{ steps.function.outputs.ref }} + SANDBOX_K8S_PI_IMAGE: ${{ steps.pi.outputs.ref }} + SANDBOX_K8S_CPU: '1' + SANDBOX_K8S_MEMORY: 1Gi + SANDBOX_K8S_EPHEMERAL_STORAGE: 2Gi + SANDBOX_K8S_E2E_RUNC_RUNTIME_CLASS: sim-e2e-runc + SANDBOX_K8S_E2E_CONCURRENCY: '4' + SANDBOX_K8S_E2E_ALLOWED_PORT: ${{ env.ALLOWED_PORT }} + SANDBOX_K8S_E2E_DENIED_PORT: ${{ env.DENIED_PORT }} + SANDBOX_K8S_E2E_REPORT_PATH: ${{ runner.temp }}/sandbox-kubernetes-e2e-report.json + run: | + set -euo pipefail + export SANDBOX_K8S_E2E_ADMIN_KUBECONFIG="$KUBECONFIG" + export SANDBOX_K8S_E2E_HOST_ADDRESS="$NODE_IP" + export KUBECONFIG="$APP_KUBECONFIG" + # The same entry point an operator runs against their own cluster. + bun run scripts/test-sandbox-kubernetes-e2e.ts --context e2e + + - name: Collect diagnostics + if: failure() + uses: ./.github/actions/k3s-diagnostics + with: + describe-namespaces: ${{ env.SANDBOX_NAMESPACE }} + + - name: Upload report + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: sandbox-kubernetes-e2e-report + path: | + ${{ runner.temp }}/sandbox-kubernetes-e2e-report.json + ${{ runner.temp }}/diagnostics/ + if-no-files-found: warn + retention-days: 14 + + - name: Tear down + if: always() + run: | + if kubectl get namespace "$SANDBOX_NAMESPACE" > /dev/null 2>&1; then + kubectl delete namespace "$SANDBOX_NAMESPACE" --timeout=120s + fi + sudo systemctl stop k3s + + e2e-app: + name: e2e-app + needs: [plan, image, app-image] + if: >- + !cancelled() && needs.plan.outputs.e2e_app == 'true' && + needs.app-image.result == 'success' && + (needs.image.result == 'success' || needs.image.result == 'skipped') + # GitHub-hosted: nested gVisor needs a plain VM, not a microVM runner. + runs-on: ubuntu-24.04 + timeout-minutes: 40 + steps: + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 + with: + persist-credentials: false + + - name: Start k3s with gVisor + uses: ./.github/actions/k3s-gvisor + + - name: Load app image + uses: ./.github/actions/k3s-image + with: + artifact: app-image-app + tag: ghcr.io/simstudioai/simstudio:sandbox-e2e + + - name: Load migrations image + uses: ./.github/actions/k3s-image + with: + artifact: app-image-migrations + tag: ghcr.io/simstudioai/migrations:sandbox-e2e + + - name: Load agent image + uses: ./.github/actions/k3s-image + with: + kind: agent + archive: ${{ contains(fromJSON(needs.plan.outputs.archives), 'agent') }} + + - name: Load Function image + uses: ./.github/actions/k3s-image + with: + kind: function + archive: ${{ contains(fromJSON(needs.plan.outputs.archives), 'function') }} + + # Fresh per run and masked; they exist only inside this ephemeral cluster. + - name: Generate app secrets + run: | + set -euo pipefail + for name in AUTH ENCRYPTION INTERNAL CRON DB; do + value="$(openssl rand -hex 32)" + echo "::add-mask::${value}" + echo "E2E_${name}_SECRET=${value}" >> "$GITHUB_ENV" + done + + - *render-sandbox-values + + - name: Install the chart + run: | + set -euo pipefail + helm install sim helm/sim \ + --namespace "$RELEASE_NAMESPACE" --create-namespace \ + --values helm/sim/ci/default-values.yaml \ + --values "$RUNNER_TEMP/sandbox-values.yaml" \ + --values .github/sandbox-kubernetes-e2e/app-values.yaml \ + --set "app.env.BETTER_AUTH_SECRET=${E2E_AUTH_SECRET}" \ + --set "app.env.ENCRYPTION_KEY=${E2E_ENCRYPTION_SECRET}" \ + --set "app.env.INTERNAL_API_SECRET=${E2E_INTERNAL_SECRET}" \ + --set "app.env.CRON_SECRET=${E2E_CRON_SECRET}" \ + --set "postgresql.auth.password=${E2E_DB_SECRET}" \ + --wait --timeout 20m + kubectl get pods --namespace "$RELEASE_NAMESPACE" -o wide + + # The Function blocks below prove the policy admits the app's sandbox pods; + # this proves it is enforced at all. A server-side dry run passes admission + # without creating anything, and Pod Security admits this plain pod, so only + # the policy can refuse it. + - name: Verify the admission policy refuses an unisolated pod + run: | + set -euo pipefail + if output="$(kubectl run admission-check --namespace "$SANDBOX_NAMESPACE" --image busybox \ + --restart Never --dry-run=server \ + --overrides '{"apiVersion":"v1","spec":{"automountServiceAccountToken":false}}' 2>&1)"; then + echo "::error::The sandbox namespace admitted a pod with no RuntimeClass" + exit 1 + fi + echo "$output" + grep -q "ValidatingAdmissionPolicy" <<< "$output" + + - name: Forward the app port + run: | + set -euo pipefail + nohup kubectl port-forward --namespace "$RELEASE_NAMESPACE" svc/sim-app 3000:3000 \ + > "$RUNNER_TEMP/port-forward.log" 2>&1 & + for _ in $(seq 1 60); do + if curl -fsS http://localhost:3000/api/health > /dev/null; then + exit 0 + fi + sleep 2 + done + cat "$RUNNER_TEMP/port-forward.log" + echo "::error::The app did not answer through the port-forward" + exit 1 + + - name: Setup workspace + uses: ./.github/actions/setup + with: + provider: github + node-version: '' + + - name: Run Function blocks through the app + working-directory: apps/sim + env: + SANDBOX_K8S_APP_E2E_BASE_URL: http://localhost:3000 + SANDBOX_K8S_APP_E2E_REPORT_PATH: ${{ runner.temp }}/sandbox-kubernetes-app-e2e-report.json + SANDBOX_K8S_NAMESPACE: ${{ env.SANDBOX_NAMESPACE }} + SANDBOX_K8S_RUNTIME_CLASS: gvisor + run: SANDBOX_K8S_APP_E2E_CRON_SECRET="$E2E_CRON_SECRET" bun run scripts/test-sandbox-kubernetes-app-e2e.ts + + - name: Collect diagnostics + if: failure() + uses: ./.github/actions/k3s-diagnostics + with: + describe-namespaces: ${{ env.RELEASE_NAMESPACE }} ${{ env.SANDBOX_NAMESPACE }} + app-namespace: ${{ env.RELEASE_NAMESPACE }} + + - name: Upload report + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: sandbox-kubernetes-app-e2e-report + path: | + ${{ runner.temp }}/sandbox-kubernetes-app-e2e-report.json + ${{ runner.temp }}/diagnostics/ + if-no-files-found: warn + retention-days: 14 + + - name: Tear down + if: always() + run: | + helm uninstall sim --namespace "$RELEASE_NAMESPACE" --wait --timeout 5m + sudo systemctl stop k3s diff --git a/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx b/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx index 3483be41e3e..aacb657e361 100644 --- a/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx +++ b/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx @@ -182,12 +182,22 @@ Who may sign up and sign in — the allowlists, blocklists, `REGISTRATION_MODE`, | Variable | Description | |----------|-------------| -| `SANDBOX_PROVIDER` | Remote sandbox provider: `e2b` (default) or `daytona` | +| `SANDBOX_PROVIDER` | Remote sandbox provider: `e2b` (default), `daytona`, or `kubernetes` | | `E2B_ENABLED` / `E2B_API_KEY` | Enable E2B remote execution | | `DAYTONA_API_KEY` | Daytona API key (used when `SANDBOX_PROVIDER=daytona`) | | `E2B_FUNCTION_TEMPLATE_ID` | Immutable `