Skip to content

feat: pod annotation-based configuration overrides#26

Merged
miguelgila merged 8 commits intomainfrom
feat/annotations
Mar 1, 2026
Merged

feat: pod annotation-based configuration overrides#26
miguelgila merged 8 commits intomainfrom
feat/annotations

Conversation

@miguelgila
Copy link
Owner

Summary

  • Add pod annotation-based configuration overrides via reaper.runtime/* prefix (dns-mode, overlay-name)
  • Implement named overlay groups (reaper.runtime/overlay-name) for isolated overlay filesystems within a K8s namespace
  • Add shared annotations.rs module with parsing, validation, and security allowlist
  • Propagate pod annotations through containerd config to OCI bundle

Details

Annotation system:

  • reaper.runtime/dns-mode: Override DNS resolution mode per pod (host, kubernetes, k8s)
  • reaper.runtime/overlay-name: Create named overlay groups with isolated upper/work dirs and mount namespaces
  • Security: only user-overridable keys are honored; admin-only params cannot be overridden via annotations
  • Master switch: REAPER_ANNOTATIONS_ENABLED=false disables all annotation processing

Named overlay groups:

  • Adds a sub-group level within namespace isolation (e.g., production/pippo/)
  • Uses double-dash separator for namespace files (production--pippo)
  • DNS label validation for overlay names

Test coverage:

  • 44 unit tests in src/annotations.rs
  • 8 integration tests in tests/integration_annotations.rs
  • 6 e2e tests in Kind cluster (overlay-name isolation, dns-mode override, combined annotations, invalid values, unknown keys)

Test plan

  • cargo test — all unit and integration tests pass
  • cargo clippy -- -D warnings — no warnings
  • Kind e2e suite — 35/35 tests pass including new annotation tests

🤖 Generated with Claude Code

miguelgila and others added 8 commits March 1, 2026 14:42
Allow users to influence Reaper behavior per-pod via Kubernetes annotations
(e.g. `reaper.runtime/dns-mode: kubernetes`). Annotations are extracted by
the shim, stored in container state, and applied at start time.

Security model: compile-time allowlist restricts which keys users can set;
admin-only parameters (overlay paths, filter settings, isolation mode) cannot
be overridden. Administrators can disable all annotation processing with
REAPER_ANNOTATIONS_ENABLED=false.

Includes shared annotations module, 202 passing tests (unit + integration),
and user-facing documentation in README.md.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tion

Allow pods to specify a named overlay group within their namespace,
so different groups of pods use completely isolated overlays (separate
upper/work dirs, mount namespaces, and locks). This enables filesystem
isolation between workload groups sharing the same K8s namespace.

Path structure with overlay-name (e.g., ns=production, name=pippo):
  /run/reaper/overlay/production/pippo/{upper,work}
  /run/reaper/ns/production--pippo
  /run/reaper/overlay-production--pippo.lock

Without overlay-name, paths are unchanged (backward compatible).
In node isolation mode, overlay-name is logged as warning and ignored.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds test_overlay_name_isolation to the integration test suite:
- Writer pod with overlay-name=group-alpha writes a marker file
- Reader pod with overlay-name=group-beta (same namespace) verifies
  it CANNOT see the file (isolation between overlay groups)
- Same-group reader with overlay-name=group-alpha verifies it CAN
  see the file (sharing within an overlay group)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Containerd 1.7+ does not automatically propagate pod-level Kubernetes
annotations to the container OCI config.json. The runtime configuration
must explicitly declare which annotation patterns to pass through via
the `pod_annotations` field. Without this, the shim never sees
`reaper.runtime/*` annotations and overlay-name (and dns-mode via
annotations) silently does nothing.

Added `pod_annotations = ["reaper.runtime/*"]` to all containerd
configuration locations: Kind configs, Ansible installer,
configure-containerd.sh, and documentation. Also added diagnostics
to the overlay-name e2e test for easier debugging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…lid, unknown)

Add four new Kind e2e tests to close annotation coverage gaps:
- dns-mode annotation override: verifies host vs kubernetes resolv.conf
- combined annotations: dns-mode + overlay-name on same pod
- invalid annotation graceful fallback: bogus values don't crash pods
- unknown annotation keys silently ignored: security allowlist works

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Each binary includes the full annotations.rs but only uses a subset of
its public items, triggering clippy dead_code warnings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sync the fake runtime script to disk and yield before executing,
preventing "Text file busy" errors in CI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov outages (502s) should not block PRs. Coverage upload is
best-effort; actual test results are what matters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Mar 1, 2026

Codecov Report

❌ Patch coverage is 88.73239% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.18%. Comparing base (4da65e7) to head (2db1bd7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/annotations.rs 92.68% 3 Missing ⚠️
src/bin/containerd-shim-reaper-v2/main.rs 81.81% 2 Missing ⚠️
src/bin/reaper-runtime/overlay.rs 88.23% 2 Missing ⚠️
src/bin/reaper-runtime/main.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
- Coverage   88.09%   87.18%   -0.91%     
==========================================
  Files           5        6       +1     
  Lines         252      320      +68     
==========================================
+ Hits          222      279      +57     
- Misses         30       41      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@miguelgila miguelgila merged commit 78dae3a into main Mar 1, 2026
10 checks passed
@miguelgila miguelgila deleted the feat/annotations branch March 1, 2026 21:53
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