-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
✨ specify nonroot uid for manager (v3+ only) #1635
✨ specify nonroot uid for manager (v3+ only) #1635
Conversation
Welcome @harpratap! |
Hi @harpratap. Thanks for your PR. I'm waiting for a kubernetes-sigs 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. |
@harpratap can you make this change to |
/hold HI @harpratap, +1 for @estroz commands and then: Could you please raise an issue with the scenarios faced and ALL step performed to check them? Also, after we are able to reproduce the problems faced we need to discuss if it would be the best approach as well. |
Sorry about that, I have created an issue - #1637 |
@@ -67,6 +67,8 @@ spec: | |||
labels: | |||
control-plane: controller-manager | |||
spec: | |||
securityContext: | |||
runAsUser: 1337 |
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.
Could you please do it for v3 only and as it was done for the proxy in brancz/kube-rbac-proxy#86? We need to update the image as well. So the change will be:
- in /pkg/plugin/v3/scaffolds/internal/templates/manager/config.go
- in v3/scaffolds/internal/templates/dockerfile.go
And then, see that you need to run make generate
to update the samples.
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.
Okay, updated the PR
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 is great. could you please check the comment
ac14fa8
to
ab10f57
Compare
ab10f57
to
567993c
Compare
@@ -22,6 +22,8 @@ spec: | |||
labels: | |||
control-plane: controller-manager | |||
spec: | |||
securityContext: | |||
runAsUser: 65532 | |||
containers: | |||
- command: |
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.
Could we add in the manifests allowPrivilegeEscalation: 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.
Done
567993c
to
39544fa
Compare
/ok-to-test |
hi @harpratap, It shows great. 🥇 You just need to run Also, in the title of the issue could you please add the mojo? See: https://github.com/kubernetes-sigs/kubebuilder/blob/master/CONTRIBUTING.md#pr-process. also, could you please add (v3+ only) in the title for we know that it is done only for v3 by checking the git history? |
/hold cancel |
39544fa
to
a9b4fcb
Compare
/retest |
/test pull-kubebuilder-e2e-k8s-1-15-3 |
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.
/approve
Great work 👍
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86, harpratap 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
/test pull-kubebuilder-e2e-k8s-1-16-2 |
See kubernetes-sigs/kubebuilder#1635 for more info Signed-off-by: He Weiwei <hweiwei@vmware.com>
See kubernetes-sigs/kubebuilder#1635 for more info Signed-off-by: He Weiwei <hweiwei@vmware.com>
See kubernetes-sigs/kubebuilder#1635 for more info Signed-off-by: He Weiwei <hweiwei@vmware.com>
PR #983 changes the manager's user to nonroot but it doesn't work out of the box.
This change modifies the default behaviour of manager pod to use non-root uid for both kube-rbac-proxy container and the manager.
There are two issues when deploying the manager in non-root cluster if we try to use the config/default as-is
kube-rbac-proxy uses root by default instead of a nonroot image - https://github.com/brancz/kube-rbac-proxy/blob/master/Dockerfile#L1 which causes pod to request for root and fail.
Kubernetes cannot verify the
nonroot
user in manager because it is a string (https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugin/v2/scaffolds/internal/templates/dockerfile.go#L65) resulting incontainer has runAsNonRoot and image has non-numeric user (nonroot), cannot verify user is non-root