Skip to content

K8s worker security hardening#234

Merged
MichielDean merged 11 commits into
mainfrom
feat/sc-hpqh8
Apr 15, 2026
Merged

K8s worker security hardening#234
MichielDean merged 11 commits into
mainfrom
feat/sc-hpqh8

Conversation

@MichielDean
Copy link
Copy Markdown
Owner

Closes droplet sc-hpqh8.

Cistern Agent added 11 commits April 14, 2026 23:07
- Add SecurityContext to worker containers (non-root, read-only FS, drop ALL caps)
- Add configurable resource requests/limits (CPU/memory) via env vars
- Move worker token from plain env var to K8s Secret with secretKeyRef
- Add ExecutionReconciler loop to detect and fail orphaned running executions
- Add ListRunning to ExecutionsStore for reconciliation queries
- Wire up reconciler in server startup with graceful shutdown
…ecret cleanup, resourceQty validation, ListRunning LIMIT, MarkFailed WHERE guard, nil K8sJobName reconciliation
… parseResources, fix ReconcileOnce doc comment
…tests

- Store worker_token_secret in DB alongside k8s_job_name so cleanup
  always references the correct Secret name
- Cancel handler only deletes Secret if it was auto-created (name
  starts with st-worker-token- prefix), not pre-existing Secrets
- Reconciler only deletes Secret if WorkerTokenSecret starts with
  the auto-created prefix, preventing deletion of pre-existing Secrets
- RunningExecution now carries WorkerTokenSecret from DB
- CreateJob returns CreateJobResult with secret metadata
  (WorkerTokenSecret name, AutoCreatedSecret flag)
- Add DB migration 000023 for worker_token_secret column
- Add comprehensive CreateJob tests using fake.NewSimpleClientset
  covering security context, resource limits, SecretKeyRef token
  injection, AutomountServiceAccountToken=false, pre-existing Secret
  behaviour, and Secret cleanup on Job creation failure
- Add reconciler tests for pre-existing Secret and nil Secret cases
- Update all DB scan queries to include worker_token_secret column
- Change Client.clientset from *kubernetes.Clientset to
  kubernetes.Interface for testability
… eliminate duplicated label maps in CreateJob
…add status guard to markExecutionFailed, add team-scoped lookups
@MichielDean MichielDean merged commit 49ab00e into main Apr 15, 2026
11 checks passed
@MichielDean MichielDean deleted the feat/sc-hpqh8 branch April 15, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant