Skip to content

feat(security): enable secure defaults for kagent chart#1468

Open
tzhukov wants to merge 12 commits intokagent-dev:mainfrom
tzhukov:tzhukov/security-context
Open

feat(security): enable secure defaults for kagent chart#1468
tzhukov wants to merge 12 commits intokagent-dev:mainfrom
tzhukov:tzhukov/security-context

Conversation

@tzhukov
Copy link
Contributor

@tzhukov tzhukov commented Mar 10, 2026

Add security context defaults to improve pod and container security:

  • Set runAsNonRoot: true for pod security context
  • Set readOnlyRootFilesystem: true for container security context
  • Add UI-specific security context overrides
  • Add emptyDir volumes for Next.js cache and tmp (required for read-only filesystem)
  • Update tool charts (grafana-mcp, querydoc) to make securityContext optional
  • Add comprehensive security context tests

This change enables secure-by-default configuration while maintaining backward compatibility through values.yaml overrides.

tzhukov and others added 8 commits March 9, 2026 15:36
Add security context defaults to improve pod and container security:
- Set runAsNonRoot: true for pod security context
- Set readOnlyRootFilesystem: true for container security context
- Add UI-specific security context overrides
- Add emptyDir volumes for Next.js cache and tmp (required for read-only filesystem)
- Update tool charts (grafana-mcp, querydoc) to make securityContext optional
- Add comprehensive security context tests

This change enables secure-by-default configuration while maintaining
backward compatibility through values.yaml overrides.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Timofey Zhukov-Khovanskiy <tzhukov87@gmail.com>
Signed-off-by: Timofey Zhukov-Khovanskiy <tzhukov87@gmail.com>
Signed-off-by: Timofey Zhukov-Khovanskiy <tzhukov87@gmail.com>
Signed-off-by: Timofey Zhukov-Khovanskiy <tzhukov87@gmail.com>
…agent into tzhukov/security-context

Signed-off-by: Timofey Zhukov-Khovanskiy <tzhukov87@gmail.com>
Resolved conflict in ui/Dockerfile by keeping init.sh script approach
for read-only filesystem support while incorporating node.js migration.

Changes from upstream:
- Migrated from bun to node.js
- Updated supervisord to use node instead of bun
- Updated package manager from bun to npm

Preserved security changes:
- USER 1001 (for runAsNonRoot compatibility)
- Init script for creating nginx temp directories
- CMD using init.sh wrapper

Signed-off-by: Timofey Zhukov-Khovanskiy <tzhukov87@gmail.com>
@tzhukov tzhukov marked this pull request as ready for review March 10, 2026 20:16
Copilot AI review requested due to automatic review settings March 10, 2026 20:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR makes the kagent Helm chart secure-by-default by enabling pod/container securityContext defaults (non-root + read-only root filesystem) and adding supporting runtime adjustments (notably for the UI) plus Helm unit tests to validate overrides and fallback behavior.

Changes:

  • Set global chart defaults for podSecurityContext.runAsNonRoot and securityContext.readOnlyRootFilesystem, with component-level override support.
  • Update the UI runtime to work with a read-only root filesystem (init script + emptyDir volumes for /tmp and Next.js cache).
  • Make securityContext optional in tool charts (querydoc, mcp-grafana) and add Helm unit tests covering securityContext behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ui/scripts/init.sh Adds init step to recreate nginx temp dirs under /tmp before starting supervisord (supports read-only rootfs).
ui/Dockerfile Copies/init script, switches to numeric non-root user, and uses init script as container CMD.
helm/tools/querydoc/templates/deployment.yaml Makes container securityContext block conditional when values are set.
helm/kagent/values.yaml Introduces global security defaults and UI-specific security/volume configuration values.
helm/kagent/tests/security-context_test.yaml Adds Helm unit tests for defaulting/overrides and UI volumes/mounts.
helm/kagent/templates/ui-deployment.yaml Applies UI-specific/global securityContext selection and adds UI emptyDir volumes + mounts.
helm/kagent/templates/controller-deployment.yaml Applies controller-specific/global securityContext selection and adds sqlite cache env var for read-only rootfs compatibility.
contrib/tools/mcp-grafana/templates/deployment.yaml Makes container securityContext block conditional when values are set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

tzhukov and others added 4 commits March 11, 2026 09:17
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Tim Zhukov <51675972+tzhukov@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Tim Zhukov <51675972+tzhukov@users.noreply.github.com>
Signed-off-by: Timofey Zhukov-Khovanskiy <tzhukov87@gmail.com>
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.

3 participants