-
Notifications
You must be signed in to change notification settings - Fork 420
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
Update eventlistener podSeurityContext to adhere to restricted pod se… #1740
Update eventlistener podSeurityContext to adhere to restricted pod se… #1740
Conversation
Hi @kristofferchr. Thanks for your PR. I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/kind feature |
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.
/ok-to-test
/retest |
1 similar comment
/retest |
cf0b25d
to
53e47ba
Compare
func getStrongerSecurityPolicy(cfg *config.Config) corev1.PodSecurityContext { | ||
securityContext := baseStrongerSecurityPolicy | ||
securityContext.RunAsUser = ptr.Int64(cfg.Defaults.DefaultRunAsUser) | ||
securityContext.RunAsGroup = ptr.Int64(cfg.Defaults.DefaultRunAsGroup) | ||
securityContext.FSGroup = ptr.Int64(cfg.Defaults.DefaultRunAsGroup) | ||
return securityContext | ||
} | ||
|
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.
We already setting these values here https://github.com/tektoncd/triggers/blob/main/pkg/reconciler/eventlistener/resources/container.go#L53-L68
except FSGroup
if you want to add FSGroup can you update this https://github.com/tektoncd/triggers/blob/main/pkg/reconciler/eventlistener/resources/container.go#L53-L68 part of the code
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.
I checked my specific use case again(istio injected sidecars) and it appears runAsGroup and runAsUser is set for that container.
However, i would like to keep seccompProfile as it is not set and therefore violates restricted pod security standards.
FSGroup is not available in container securityContext, only PodSecurityContext.
I can remove runAsGroup and runAsUser if you do not wish to have a pod level default.
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.
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 there anything that is missing or changes that is required for this PR before approval?
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.
Ping @savitaashture @khrm
53e47ba
to
38745aa
Compare
dedb181
to
c91c57b
Compare
bump @khrm @savitaashture |
securityContext.RunAsUser = ptr.Int64(cfg.Defaults.DefaultRunAsUser) | ||
securityContext.RunAsGroup = ptr.Int64(cfg.Defaults.DefaultRunAsGroup) |
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.
Hi @kristofferchr
For runAsUser and runAsGroup
can you handle similar to this https://github.com/tektoncd/triggers/blob/main/pkg/reconciler/eventlistener/resources/container.go#L71-L76
because In a platform like OpenShift we set ""
value so lets keep runAsUser and runAsGroup when its actually set
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.
Certainly. FSGroup as well?
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.
Implemented and added tests.
c91c57b
to
f669160
Compare
|
||
if !cfg.Defaults.IsDefaultRunAsGroupEmpty { | ||
securityContext.RunAsGroup = ptr.Int64(cfg.Defaults.DefaultRunAsGroup) | ||
securityContext.FSGroup = ptr.Int64(cfg.Defaults.DefaultRunAsGroup) |
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 FSGroup and runAsGroup same ??
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.
I set them as the same, as i do not need change it for my use case. Should i make it configurable through a Defaults or wait for a specific use case?
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.
IMO lets wait for a specific case
we can add it whenever we have usecase
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.
agreed. I will keep it as it is with FSGroup set to RunAsGroup
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.
Oh wait my point is can we completly remove FSGroup or is it required ?
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.
I need it for my usecase to adhere to aks policy: https://github.com/Azure/azure-policy/blob/master/built-in-policies/policySetDefinitions/Kubernetes/PSPRestrictedStandard.json#L256
Currently we need policy exemptions because of this requirement.
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.
I set them as the same, as i do not need change it for my use case. Should i make it configurable through a Defaults or wait for a specific use case?
Shall we configure it so that if someone wants they can set to different value
as both FSGroup and RUnAsGroup functionality is different
Once you add the configuration for FSGroup smilar to RunAsGroup I think we are good to merge
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.
@savitaashture updated :)
/retest |
f669160
to
10b5ec4
Compare
…curity standards Alter podSecurityContext to include seccompProfile, runAsUser, runAsGroup and fsGroup when set-security-context is set. As podSecurityContext only included runAsNonRoot, which could cause injected sidecars to miss some required restricted pod security standards securityContext fields.
10b5ec4
to
19b92f4
Compare
The following is the coverage report on the affected files.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: savitaashture The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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
…curityContext for Triggers as part of this PR tektoncd/triggers#1740 we've introduced an FSGroup setting to comply with restricted pod security standards for the podTemplate. But the default value 65532 won't work on OpenShift so setting by default for FSGroup Signed-off-by: Savita Ashture <sashture@redhat.com>
…curityContext for Triggers as part of this PR tektoncd/triggers#1740 we've introduced an FSGroup setting to comply with restricted pod security standards for the podTemplate. But the default value 65532 won't work on OpenShift so setting by default for FSGroup Signed-off-by: Savita Ashture <sashture@redhat.com>
Solves issue #1739
Currently, when
el-security-context
is enabled, thesecurityContext
forEventListener
in the pod template only setsrunAsNonRoot
. Expanding podTemplatesecurityContext
can make it easier to fulfill restricted pod security standards.Makes it possible to have a default
securityContext
set for injected sidecar containers that does not fulfill restricted pod security standars. An example of this is injected istio containers.Changes
Alter podSecurityContext to include seccompProfile, runAsUser, runAsGroup and fsGroup when set-security-context is set.
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
/kind <type>
. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes