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

Use port higher than 1024 to be able to run as a non-root user #960

Merged

Conversation

vpavlin
Copy link
Member

@vpavlin vpavlin commented Dec 11, 2019

What this PR does / why we need it:
This PR allows Katib Controller to run as a non-root user. This is important from security point of view and especially to enable Katib on enterprise distributions of Kubernetes like OpenShift.

This PR adds a parameter --webhook-port to allow configuring port > 1024 for admission webhooks and also changes the default port (443) to 8443.

It also changes the USER in Dockerfile as it is not necessary to run as root with this change even on the vanilla Kubernetes.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #959

Special notes for your reviewer:

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

No image changes

Release note:



This change is Reviewable

@k8s-ci-robot
Copy link

Hi @vpavlin. Thanks for your PR.

I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@hougangliu
Copy link
Member

/ok-to-test

@@ -83,7 +85,7 @@ func main() {
}

log.Info("Setting up webhooks")
if err := webhook.AddToManager(mgr); err != nil {
if err := webhook.AddToManager(mgr, int32(webhookPort)); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not var webhookPort int32 in line 42?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because defining the variable as int32 fails in flag.IntVar with

v1alpha3/main.go:47:14: cannot use &webhookPort (type *int32) as type *int in argument to flag.IntVar

So I tried flag.Var, but int32 does not have flag.Set method implemented

*int32 does not implement flag.Value (missing Set method)

So the simplest solution seemed to be to just load int and change the type. Do you have different suggestion for solution?


flag.StringVar(&experimentSuggestionName, "experiment-suggestion-name",
"default", "The implementation of suggestion interface in experiment controller (default|fake)")
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
flag.IntVar(&webhookPort, "webhook-port", 443, "The port number to be used for admission webhook server.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep 8443 as default value

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@vpavlin vpavlin force-pushed the feature/parameterize-webhook-port branch from 13ecd46 to 599ced1 Compare December 12, 2019 09:01
@johnugeorge
Copy link
Member

/lgtm

@hougangliu
Copy link
Member

/approve

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hougangliu

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Katib Controller fails to run as non-root user in OpenShift
4 participants