-
Notifications
You must be signed in to change notification settings - Fork 23
fix: configure security context for pods with pvc #1296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideThis PR centralizes pod security context configuration by introducing a generic helper that enforces run-as-non-root, disables privilege escalation, applies a default FSGroup for non-OpenShift clusters, and sets the runtime-default seccomp profile; it removes the legacy OpenShift-specific logic and updates all operator-managed workloads (Trillian DB, TUF deployments and init jobs, Rekor server and statefulset) to use the new helper, as well as adjusts the e2e TUF test to verify the security context. Sequence diagram for applying PodSecurityContext to operator-managed workloadssequenceDiagram
participant Controller
participant Workload (e.g. Deployment/StatefulSet/Job)
participant Ensure
Controller->>Workload: Create or update workload
Workload->>Ensure: Call PodSecurityContext helper
Ensure-->>Workload: Apply security context (runAsNonRoot, no privilege escalation, FSGroup, seccomp)
Workload-->>Controller: Workload created/updated with enforced security context
Class diagram for PodSecurityContext enforcement changesclassDiagram
class Ensure {
+PodSecurityContext(podSpec)
}
class Deployment {
+PodSecurityContext()
}
Ensure <|-- Deployment
Deployment : +PodSecurityContext() calls Ensure.PodSecurityContext
class TrillianDbDeployment {
-removed: GetOpenshiftPodSecurityContextRestricted
+uses: Deployment.PodSecurityContext
}
class TufDeployment {
+uses: Deployment.PodSecurityContext
}
class TufInitJob {
+uses: Ensure.PodSecurityContext
}
class RekorServerDeployment {
+uses: Deployment.PodSecurityContext
}
class RekorMonitorStatefulSet {
+uses: Ensure.PodSecurityContext
}
TrillianDbDeployment --> Deployment
TufDeployment --> Deployment
TufInitJob --> Ensure
RekorServerDeployment --> Deployment
RekorMonitorStatefulSet --> Ensure
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- ensure.PodSecurityContext only applies defaults to spec.Containers—consider extending it to initContainers (and other container lists) so all pod containers get consistent security settings.
- Hard-coding runAsUser/runAsGroup to 1001 might clash with some images—consider making these values configurable or deriving them from the pod spec rather than a fixed constant.
- Review the choice to skip setting FSGroup on OpenShift clusters, as PVC-backed pods often need an explicit FSGroup on all platforms to mount volumes correctly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- ensure.PodSecurityContext only applies defaults to spec.Containers—consider extending it to initContainers (and other container lists) so all pod containers get consistent security settings.
- Hard-coding runAsUser/runAsGroup to 1001 might clash with some images—consider making these values configurable or deriving them from the pod spec rather than a fixed constant.
- Review the choice to skip setting FSGroup on OpenShift clusters, as PVC-backed pods often need an explicit FSGroup on all platforms to mount volumes correctly.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
7214ec5 to
33be352
Compare
ba49996 to
8dd4ae0
Compare
eea3bd3 to
52618e2
Compare
Signed-off-by: Tomas Turek <tturek@redhat.com>
1994f8a to
25b0ce0
Compare
Summary by Sourcery
Standardize security contexts for operator-managed pods by introducing a generic PodSecurityContext ensure function, removing legacy OpenShift-specific SCC logic, and applying consistent security defaults across Trillian, TUF, and Rekor workloads.
Enhancements:
Tests: