Skip to content

fix: make the security contexts configurable - #112

Merged
uniqueg merged 7 commits into
devfrom
fix/111-security-context
Nov 12, 2026
Merged

uniqueg merged 7 commits into
devfrom
fix/111-security-context

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Since 2026-11-10, CSC Rahti's admission controller rejects pods that set seccompProfile: type: RuntimeDefault. The chart hard-coded it in the containers' security context. Now:

  • pubgrade, builds.updater and mongodb each take podSecurityContext and securityContext values (Helm's usual names), rendered with toYaml through one helper; empty contexts render no key.
  • Defaults are unchanged: Pubgrade's and the updater's containers keep allowPrivilegeEscalation: false, capabilities.drop: [ALL], runAsNonRoot: true, seccompProfile.type: RuntimeDefault; pods and MongoDB have none. The default render is the same YAML as on dev (only the indentation of - ALL differs, from toYaml).
  • seccompProfile: null removes the profile; a profile left empty (seccompProfile.type: null) is left out too. An empty map ({}) can't remove it, as Helm merges it with the default; the docs and values comments say so.
  • Docs (docs/deployment.md, "Security contexts"): the values, the exact override for OpenShift/Rahti (--set pubgrade.securityContext.seccompProfile=null), and a warning against helm upgrade --reuse-values from charts up to 0.2.0, whose defaults had no such values.

Closes #111

Verification

  • mise exec [email protected] -- bash tests/chart.sh: new checks failed before the change (7 errors), pass after ("Chart checks passed"). New checks: defaults per workload (--show-only), MongoDB without context, seccompProfile=null and seccompProfile.type=null for Pubgrade and the updater, pod contexts for all three, whole contexts removed.
  • mise exec [email protected] -- helm lint helm --strict: passed.
  • Default render (with and without builds) compared with origin/dev: identical apart from the - ALL indentation.
  • mkdocs build --strict (docs group from the lock): passed.
  • CI: all checks passed (CI passed, Chart, Upgrade test, Docs, Read the Docs, scans).

Declined review findings

  • Byte-identical defaults (- ALL indentation from toYaml): equivalent YAML, no behaviour change.
  • Duplicated default context for pubgrade and builds.updater: kept, as Helm values can't share defaults; the tests check both workloads.
  • "Up to chart 0.2.0" in the docs: accurate, as every chart up to and including 0.2.0 has the fixed contexts.
  • Commit trailer model name: matches the model in use.
  • Template fallback to hardened defaults when the values are missing (for --reuse-values): a missing key can't be told apart from one removed with null, so the docs warn instead.

Open questions

None.

🤖 Generated with Claude Code

https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV

Summary by Sourcery

Make workload security contexts configurable while preserving existing container defaults and supporting clusters that provide their own seccomp profile.

New Features:

  • Allow pod and container security contexts to be configured independently for Pubgrade, the builds updater, and MongoDB.
  • Support removing default seccomp profiles through null-valued Helm overrides.

Bug Fixes:

  • Enable deployments on clusters such as CSC Rahti that reject explicitly configured RuntimeDefault seccomp profiles.

Enhancements:

  • Centralize security-context rendering while preserving hardened defaults for Pubgrade and the updater and no defaults for pods and MongoDB.

Documentation:

  • Document security-context configuration, Rahti-specific overrides, Helm merge behavior, and upgrade guidance for releases using older chart values.

Tests:

  • Add chart checks covering default contexts, context overrides and removal, seccomp-profile behavior, and pod-level contexts across all workloads.

uniqueg and others added 3 commits November 12, 2026 08:44
The chart hard-coded the containers' security context, with the seccomp
profile RuntimeDefault, which clusters that set their own profile reject
(e.g., CSC Rahti). Pubgrade, the updater and MongoDB now take
podSecurityContext and securityContext values, rendered with toYaml;
the defaults render as before. A seccompProfile set to null, or left
empty, is not rendered.

Closes #111

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Including the override for clusters that set their own seccomp
profile, such as CSC Rahti.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Correct the comments on empty seccomp profiles, check the defaults per
workload (none for MongoDB) and the removal for the updater too, and
warn against helm upgrade --reuse-values from charts with fixed
security contexts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
@uniqueg uniqueg self-assigned this Nov 12, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Configuration

Define configurable pod and container security-context defaults for each workload, preserving the hardened Pubgrade and updater defaults while leaving MongoDB and pod contexts empty.

  • helm/values.yaml L41-51, L67-81, L105-108

Render configured pod and container security contexts for MongoDB, Pubgrade, and the updater, omitting empty contexts and empty seccomp profiles.

  • helm/templates/_helpers.tpl L21-34
  • helm/templates/mongodb/deployment.yaml L19-22, L27-30
  • helm/templates/pubgrade/deployment.yaml L20-23, L28-31
  • helm/templates/updater/deployment.yaml L17-20, L25-28

Documentation

Explain the security-context values and merge behavior, show how to remove seccomp profiles on affected clusters, and advise against unsafe reuse of older Helm values.

  • docs/deployment.md L33-69

Tests

Check default contexts, seccomp-profile removal, custom pod and MongoDB container contexts, and removal of whole contexts across the workloads.

  • tests/chart.sh L108-165

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@read-the-docs-community

read-the-docs-community Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 Pubgrade | 🛠️ Build #35838638 | 📁 Comparing 149a095 against latest (5588ace)

  🔍 Preview build  

1 file changed
± deployment/index.html

@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c8087cb) to head (149a095).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #112   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           18        18           
  Lines         1545      1545           
=========================================
  Hits          1545      1545           

☔ View full report in Codecov by Harness.
📢 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.

@uniqueg
uniqueg marked this pull request as ready for review November 12, 2026 08:45
@sourcery-ai

sourcery-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit 149a095

#111 fix: make the pod security context configurable · 3 of 3 met

# Requirement Status Notes
1 Add per-component podSecurityContext and securityContext values, rendered with toYaml, retaining today's defaults. ✅ Met Values and rendering are provided for pubgrade, builds.updater, and mongodb; Pubgrade and updater retain the hardened container defaults, while pods and MongoDB have no defaults.
2 Test that removing the seccomp profile renders no seccompProfile and that defaults render as today. ✅ Met Chart tests check defaults for Pubgrade and updater, no security context by default for MongoDB, and profile removal via both seccompProfile=null and seccompProfile.type=null.
3 Document the exact override for OpenShift/Rahti. ✅ Met The deployment documentation gives the CLI override --set pubgrade.securityContext.seccompProfile=null and a values-file example.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/chart.sh" line_range="147" />
<code_context>
+  --set mongodb.podSecurityContext.fsGroup=1003 \
+  --set mongodb.securityContext.allowPrivilegeEscalation=false)"
+for id in 1001 1002 1003; do
+  count "${chart}" "fsGroup: ${id}" 1 "pod security context"
+done
+count "${chart}" 'allowPrivilegeEscalation: false' 3 "MongoDB security context"
</code_context>
<issue_to_address>
**Security context checks ignore placement**

When a template renders the requested context in the wrong workload or at the wrong YAML level, a broken template can emit these fields under the wrong workload or at the wrong YAML level; the global `count` assertions still find the expected strings, so the tests pass while the requested security settings are not applied to the intended pod or container.

Assert the contexts within each workload's rendered deployment and at the expected pod or container path.

Also at `tests/chart.sh:149`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and upgrading an existing release with --reuse-values can leave the new security-context values unset, so the app and updater containers may run without their previous restrictions. Reverting the chart restores the hard-coded contexts, but it cannot undo any security exposure that occurred before the rollback.

Blocking findings: tests/chart.sh:147


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread tests/chart.sh Resolved
uniqueg and others added 4 commits November 12, 2026 09:59
Assert the pod and container contexts in each Deployment at their
level, as Sourcery suggested.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
Other values, such as false, are rendered, so that Kubernetes rejects
them instead of the profile being dropped silently, as Sourcery
suggested.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
@uniqueg
uniqueg merged commit 9b5beba into dev Nov 12, 2026
32 of 33 checks passed
@uniqueg
uniqueg deleted the fix/111-security-context branch November 12, 2026 15:31
@uniqueg uniqueg added this to the v0.3.0 milestone Nov 17, 2026
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.

fix: make the pod security context configurable

1 participant