-
Notifications
You must be signed in to change notification settings - Fork 6
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
Enable kdmp & NFS jobs to run in restricted PSA mode #378
Conversation
OSS Scan Results:
Total issues: 196 |
License Evaluation Results:
Total License Issues: 17 |
OSS Scan Results:
Total issues: 137 |
License Evaluation Results:
Total License Issues: 17 |
OSS Scan Results:
Total issues: 137 |
License Evaluation Results:
Total License Issues: 17 |
OSS Scan Results:
Total issues: 137 |
License Evaluation Results:
Total License Issues: 17 |
OSS Scan Results:
Total issues: 137 |
License Evaluation Results:
Total License Issues: 17 |
OSS Scan Results:
Total issues: 137 |
License Evaluation Results:
Total License Issues: 17 |
OSS Scan Results:
Total issues: 137 |
License Evaluation Results:
Total License Issues: 17 |
OSS Scan Results:
Total issues: 137 |
License Evaluation Results:
Total License Issues: 17 |
OSS Scan Results:
Total issues: 142 |
License Evaluation Results:
Total License Issues: 17 |
OSS Scan Results:
Total issues: 142 |
License Evaluation Results:
Total License Issues: 17 |
OSS Scan Results:
Total issues: 142 |
License Evaluation Results:
Total License Issues: 17 |
// if the job event reason is Failedcreate due to fobidden podSecurity violation | ||
// then return true | ||
for _, event := range events.Items { | ||
if event.Reason == "FailedCreate" && strings.Contains(event.Message, "violates PodSecurity") { |
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.
Is this message the same if there is no PodSecurity context and only container security context violation?
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.
Yes they are same. Thanks for asking I tried in 1.27 k8s at least in that version it is same.
pkg/drivers/utils/utils.go
Outdated
@@ -966,3 +997,91 @@ func GetShortUID(uid string) string { | |||
} | |||
return uid[:8] | |||
} | |||
|
|||
// Add container security Context to job pod if the PSA is enabled. | |||
// if static uids like kdmpJobUid or kdmpJobGid is used that means |
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.
nit: Sentence to start with caps
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.
done.
// of the backup pod filesystem. | ||
if !strings.Contains(job.Spec.Template.Spec.Containers[0].Command[0], kopiaBackupString) { | ||
job.Spec.Template.Spec.SecurityContext = &corev1.PodSecurityContext{ | ||
FSGroup: &uid, |
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.
If it is no OCP backup where runAsUser, runAsGroup and FsGroup was set and restoring to another vanila cluster, should we not add the same to kdmp job pods? If we don't add wouldn't the job pod runs as root?
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.
In case of a non-ocp based backup and restore user group is preserved anyway and it will be used.. May be I need to understand the comment better. Let me discus this in Monday.
job.Spec.Template.Spec.Containers[0].SecurityContext.RunAsGroup = &gid | ||
} | ||
// Add RunAsNonRoot to true and drop all capabilities and seccomp profile and allowPrivilegeEscalation to false | ||
job.Spec.Template.Spec.Containers[0].SecurityContext.RunAsNonRoot = ptr.To(true) |
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.
For a normal bakcup where no security context was set, kdmp pod will run as root. With this check on the restore side, are making it run as non-root, what would be the user after restore? During backup they would be as root
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.
So you are saying a scenario where in backup is taken for an app where in security context is not there So job will run as root . During restore we will check if volume info In backup if there is a UID mentioned there won't be anything used in data export CR as annotation and we will not add any security context bloc.
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.
LGTM after addressing review comments
- if psa enabled then extracted the uid and gid used by the POD. here the pod is choosen based on whichever PVC is used by that pod - applied those uid and GID to all relevant job pod spec - for baseline and privilege mode no restriction on UID/GID and default setting of SElinux and secomp is adopted in the job POD spec Signed-off-by: Lalatendu Das <[email protected]>
- checked job's event for a filedCreate reason and specifically for violating pod security standard. - the check is added for all the kdmp & nfs related job pods. Signed-off-by: Lalatendu Das <[email protected]>
OSS Scan Results:
Total issues: 142 |
License Evaluation Results:
Total License Issues: 17 |
What this PR does / why we need it: This PR brings changes of psa and azure chine changes to kdmp via vending from stork to kdmp
Which issue(s) this PR fixes (optional)
Closes # pb-6681
Special notes for your reviewer:
Unit tested backup and restore with 1.2.13 executor image with corresponding stork PR
Restore of the above non-psi and psi backups are as below