feat(security): enable secure defaults for kagent chart#1468
Open
tzhukov wants to merge 12 commits intokagent-dev:mainfrom
Open
feat(security): enable secure defaults for kagent chart#1468tzhukov wants to merge 12 commits intokagent-dev:mainfrom
tzhukov wants to merge 12 commits intokagent-dev:mainfrom
Conversation
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>
Contributor
There was a problem hiding this comment.
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.runAsNonRootandsecurityContext.readOnlyRootFilesystem, with component-level override support. - Update the UI runtime to work with a read-only root filesystem (init script + emptyDir volumes for
/tmpand Next.js cache). - Make
securityContextoptional 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.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add security context defaults to improve pod and container security:
This change enables secure-by-default configuration while maintaining backward compatibility through values.yaml overrides.