Skip to content
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

Allow seldon manager to run as non-root #2631

Closed
mo-saeed opened this issue Nov 12, 2020 · 14 comments · Fixed by #2853
Closed

Allow seldon manager to run as non-root #2631

mo-saeed opened this issue Nov 12, 2020 · 14 comments · Fixed by #2853
Assignees
Labels
Projects
Milestone

Comments

@mo-saeed
Copy link
Contributor

Describe the bug

the helm installation of seldon-core-operator failed coz seldon-controller-manager fails to start with this error

container has runAsNonRoot and image will run as root

So it seems that the image tries to run as a root and our pod security policy dissallow that.

Please have a look into this thread https://seldondev.slack.com/archives/CSVSD5S75/p1605193934193300

To reproduce

  • you need to have a pod security policy in place where it restricts running images as root
  • run the helm installation (for seldon-core-operator)

Expected behaviour

Installation completes successfully and all pods should run not with root user.

Environment

K8s cluster- AKS v1.18
seldon-core-operator version 1.4.0

@mo-saeed mo-saeed added bug triage Needs to be triaged and prioritised accordingly labels Nov 12, 2020
@ryandawsonuk
Copy link
Contributor

ryandawsonuk commented Nov 13, 2020

Makes sense, we need to add a section like https://github.com/helm/charts/blob/master/stable/ambassador/templates/deployment.yaml#L49

Not quite as simple as it sounds as our helm chart is generated from kustomize using python code

@mo-saeed
Copy link
Contributor Author

@ryandawsonuk Thank you for your update

As this is a blocker for us to proceed with seldon deployment, can the fix be a part of the next release?

@mo-saeed
Copy link
Contributor Author

@ryandawsonuk Any updates?

@ukclivecox ukclivecox added this to To do in 1.5 via automation Nov 19, 2020
@ukclivecox ukclivecox added this to the 1.5 milestone Nov 19, 2020
@ukclivecox ukclivecox removed the triage Needs to be triaged and prioritised accordingly label Nov 19, 2020
@ukclivecox ukclivecox self-assigned this Nov 19, 2020
@adriangonz
Copy link
Contributor

adriangonz commented Nov 26, 2020

Hey @mo-saeed, we've already started to cut the 1.5 release. However, we could include this for 1.6.

Given that you've already started to look into this locally, would you be willing to contribute a PR with the required changes?

@mo-saeed
Copy link
Contributor Author

mo-saeed commented Nov 27, 2020

Hi @adriangonz

Thanks for the updates, I hoped to have such an important fix in 1.5.

Can you please provide documentation on how to use this script so I can create the pull request, the change for me sounds to be easy which is adding this

                # SecurityContext
                res["spec"]["template"]["spec"]["securityContext"]["runAsUser"] = helm_value(
                    "defaultUserID"
                )

after this line https://github.com/SeldonIO/seldon-core/blob/master/operator/helm/split_resources.py#L156

But I dunno how to test this properly and I can't find any documentation.

Thanks

@ukclivecox
Copy link
Contributor

I agree we should document these steps in a developer section.

@mo-saeed
Copy link
Contributor Author

@cliveseldon @adriangonz Pull request created, please have a look.

There were also some other changes caused by the build process, I am not sure if it can be avoided or it's ok to have it.

@ukclivecox ukclivecox modified the milestones: 1.5, 1.6 Nov 30, 2020
@ukclivecox ukclivecox added this to To do in 1.6.0 via automation Nov 30, 2020
@ukclivecox ukclivecox removed this from To do in 1.5 Nov 30, 2020
@ukclivecox
Copy link
Contributor

closed by #2709
@mo-saeed Have you tested master in your context and this solves your issue?

1.6.0 automation moved this from To do to Done Dec 7, 2020
@ukclivecox ukclivecox reopened this Dec 7, 2020
1.6.0 automation moved this from Done to In progress Dec 7, 2020
@ukclivecox
Copy link
Contributor

The PR that fixed this was incorrect

  1. as manager needs to bind to port 443 by default for web hook
  2. it was adding runAsUser as string while it needs to be an int

@ukclivecox
Copy link
Contributor

reverted in #2752

@mo-saeed
Copy link
Contributor Author

mo-saeed commented Dec 7, 2020

And why was it reverted, instead of only fixing the issue?

I don't get the first point, coz nth was changed regarding the webhook port.

for the second point, how can that be configured properly in this python script?

@ukclivecox
Copy link
Contributor

ukclivecox commented Dec 7, 2020

The install is broken in master so have reverted. We can put the fix back in with corrections. Will need to look what we do for openshift where we change the webhook port to a non-root value such as 4443 and also ensure the value is correctly set.

@mo-saeed
Copy link
Contributor Author

mo-saeed commented Dec 7, 2020

when I look here , I see the webhook port is defined the same way using helm_value method. so not clear for me how to set it as an integer not string. even here sounds for me the same...

I hope we can have an easy and documented way of updating helm values so users can contribute and test properly.

@ukclivecox
Copy link
Contributor

Yes agreed. The issue was it was setting it as a string when it needs to be an int.

@ukclivecox ukclivecox changed the title seldon-controller-manager failed to start Allow seldon manager to run as non-root Dec 10, 2020
@ukclivecox ukclivecox added this to To do in Sprint 1 via automation Jan 7, 2021
@ukclivecox ukclivecox removed this from In progress in 1.6.0 Jan 7, 2021
@ukclivecox ukclivecox moved this from To do to In progress in Sprint 1 Jan 8, 2021
@ukclivecox ukclivecox moved this from In progress to Review in progress in Sprint 1 Jan 19, 2021
Sprint 1 automation moved this from Review in progress to Done Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

4 participants