-
Notifications
You must be signed in to change notification settings - Fork 34
Custom SecurityContexts for envoy DaemonSet and contour Deployment #398
Conversation
650cce5
to
06e3b97
Compare
Codecov Report
@@ Coverage Diff @@
## main #398 +/- ##
===========================================
- Coverage 79.82% 59.34% -20.48%
===========================================
Files 29 19 -10
Lines 2235 2071 -164
===========================================
- Hits 1784 1229 -555
- Misses 331 815 +484
+ Partials 120 27 -93
Continue to review full report at Codecov.
|
d6db195
to
dc0e198
Compare
I've been trying to run the e2e tests locally but I'm getting inconsistent results, even on the main branch:
I just added a change to the e2e tests to use an empty PodSecurityContext for the contour pods since port 80 appears to be in the mix. However, I'm unable to get through the entire e2e test suite because of the above two issues. |
ah, this is probably not related to your change at all, i think this is related to this change in Contour being merged: projectcontour/contour@9e98a72 We need to fix this up on main and then you should be able to merge main and your change go green |
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 also wanted this feature! Thank you 👍
@@ -304,7 +304,6 @@ func DesiredDeployment(contour *operatorv1alpha1.Contour, image string) *appsv1. | |||
ServiceAccountName: objutil.ContourRbacName, | |||
RestartPolicy: corev1.RestartPolicyAlways, | |||
SchedulerName: "default-scheduler", | |||
SecurityContext: objutil.NewUnprivilegedPodSecurity(), |
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 think we don't need to move this line.
If contour.ContourSecurityContextExists()
is true
, we just overrides deploy.Spec.Template.Spec.SecurityContext
otherwise, use the default set here.
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.
It might be premature optimization but I was hoping to avoid an unnecessary allocation.
api/v1alpha1/contour_types.go
Outdated
// +optional | ||
ContourSecurityContext *corev1.PodSecurityContext `json:"contourSecurityContext,omitempty"` | ||
|
||
//EnvoySecurityContext defines a PodSecurityContext for Envoy pods. |
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.
//EnvoySecurityContext defines a PodSecurityContext for Envoy pods. | |
// EnvoySecurityContext defines a PodSecurityContext for Envoy pods. |
nit
@@ -95,3 +95,11 @@ func (c *Contour) EnvoyTolerationsExist() bool { | |||
|
|||
return false | |||
} | |||
|
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 think ContourSecurityContextExists
and EnvoySecurityContextExists
should have a comment line as these are public functions. I wonder why lint check does not produce the error 🤔
@dmorgan81 I think this PR might be placed on a lower priority to merge at the moment since the Operator/Contour relationship is going through a rework as part of our Gateway API support work. Apologies for that, but we will try to get to this soon! |
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.
Added projectcontour/contour#4039 and projectcontour/contour#4040 to track we want to make sure this is captured in the new world where Contour can manage the Envoy daemonset etc.
@dmorgan81 The jobs created by the operator will also have to use the custom security context. For reference. |
d81aadc
to
87b76dd
Compare
Signed-off-by: David Morgan <[email protected]>
Allow setting custom security contexts for both contour deployments and envoy daemonsets. The default value is unpriviledged and is equivalent to the following: contourSecurityContext: runAsUser: 65534 runAsGroup: 65534 runAsNonRoot: true Fixes projectcontour#112 Updates projectcontour#378 Signed-off-by: David Morgan <[email protected]>
Signed-off-by: David Morgan <[email protected]>
Signed-off-by: David Morgan <[email protected]>
Signed-off-by: David Morgan <[email protected]>
87b76dd
to
263c7c4
Compare
This is stale, closing out. |
Allow users to specify a security context for both envoy daemonsets and contour deployments. The default value is unprivileged and is equivalent to the following:
Note that this does change the default behavior for envoy daemonsets. Currently an envoy daemonset has an empty security context, meaning it will run with the user/group specified in the envoy image, which is commonly root. Switching to a non-root user by default will prevent the envoy container from binding to a low port. Existing setups will need to be updated by adding a
envoySecurityContext
entry with the appropriate settings if they need to bind to a low port.Fixes #112
Updates #378