-
Notifications
You must be signed in to change notification settings - Fork 174
Adding option to enable Back End HTTPS for Prow Ingress #573
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
base: main
Are you sure you want to change the base?
Adding option to enable Back End HTTPS for Prow Ingress #573
Conversation
✅ Deploy Preview for k8s-prow ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
|
|
Welcome @NiJuFirenzia! |
|
Hi @NiJuFirenzia. Thanks for your PR. I'm waiting for a github.com 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. DetailsInstructions 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-sigs/prow repository. |
|
This PR addresses Issue #328 |
|
@NiJuFirenzia thanks for your PR, can you check the CLA and sign it? |
|
/ok-to-test |
b32381d to
2cfbae6
Compare
cmd/hook/main.go
Outdated
| enableSSL bool | ||
| certFile string | ||
| keyFile string |
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.
let's group this into a small struct that we can embed at both places, we can share validation etc. similarly to how the ThingOptions bits above
cmd/hook/main.go
Outdated
| httpServer := &http.Server{ | ||
| Addr: ":" + strconv.Itoa(o.port), | ||
| Handler: hookMux, | ||
| } |
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.
this seems identical in both branches, so can be extracted before the condition
cmd/deck/pluginhelp.go
Outdated
| // cacheLife is the time that we keep a pluginhelp.Help struct before considering it stale. | ||
| // We consider help valid for a minute to prevent excessive calls to hook. | ||
| const cacheLife = time.Minute | ||
| const tlsEnabledScehma = "https" |
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.
| const tlsEnabledScehma = "https" | |
| const tlsEnabledSchema = "https" |
cmd/deck/pluginhelp.go
Outdated
| transport.TLSClientConfig = &tls.Config{ | ||
| RootCAs: caCertPool, | ||
| } | ||
| http.DefaultTransport = transport |
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.
helpAgent should get a custom client member with this transport instead of modifying the global default transport (this would affect anything else in deck that is a http client and relies on the default)
cmd/deck/pluginhelp.go
Outdated
| caCert, err := os.ReadFile(ha.cert) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("error decoding cert file: %w", err) | ||
| } | ||
| caCertPool := x509.NewCertPool() | ||
| caCertPool.AppendCertsFromPEM(caCert) |
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 am not entirely sure I like this coupling. This essentially reuses Deck's server cert as a CA cert to establish trust with Hook's server cert for this behavior where Deck is a client to hook's pluginhelp endpoint? That's a bit hacky and suprising.
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.
That would require having to add another option flag to take in a client cert right? I had been trying to limit the options that we would need
2cfbae6 to
9865cdd
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: NiJuFirenzia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Signed-off-by: Nikhil Jiju <Nikhil.Jiju@fmr.com>
9865cdd to
2ad6fa1
Compare
|
All change requests have been addressed and this PR is ready for a re-review |
petr-muller
left a comment
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's a flag name mismatch between error message and actual names. I have pointed out some opportunities to reduce stuttering (sslEnablement.EnableSSL and verbosity sslEnablement vs ssl) but treat them as non-blocking nits.
| func (o *SSLEnablementOptions) Validate(_ bool) error { | ||
| if o.EnableSSL { | ||
| if o.ServerCertFile == "" { | ||
| return errors.New("flag --enable-ssl was set to true but required flag --cert-file was not 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.
| return errors.New("flag --enable-ssl was set to true but required flag --cert-file was not set") | |
| return errors.New("flag --enable-ssl was set to true but required flag --server-cert-file was not set") |
actual flags are different
| return errors.New("flag --enable-ssl was set to true but required flag --cert-file was not set") | ||
| } | ||
| if o.ServerKeyFile == "" { | ||
| return errors.New("flag --enable-ssl was set to true but required flag --key-file was not 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.
| return errors.New("flag --enable-ssl was set to true but required flag --key-file was not set") | |
| return errors.New("flag --enable-ssl was set to true but required flag --server-key-file was not set") |
| } | ||
|
|
||
| func (o *SSLEnablementOptions) Validate(_ bool) error { | ||
| if o.EnableSSL { |
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 should either check also the opposite case (enabled is false but cert was passed, possibly confusing the admin they are using SSL when they are not), or make this an implied field from the presence of at least one file flags (if at least one is set, assume the user wants to have it enabled and validate both are set).
| bugzilla prowflagutil.BugzillaOptions | ||
| instrumentationOptions prowflagutil.InstrumentationOptions | ||
| jira prowflagutil.JiraOptions | ||
| sslEnablement prowflagutil.SSLEnablementOptions |
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.
| sslEnablement prowflagutil.SSLEnablementOptions | |
| ssl prowflagutil.SSLEnablementOptions |
| // HTTPS backend. If enableSSL is true, both certFile and keyFile must be set | ||
| // to the location of the cert and key files respectively. | ||
|
|
||
| type SSLEnablementOptions struct { |
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.
tbh I'd call this just SSLOptions or SSLServerOptions and the package flagutil/ssl
| EnableSSL bool | ||
| ServerCertFile string | ||
| ServerKeyFile string |
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.
| EnableSSL bool | |
| ServerCertFile string | |
| ServerKeyFile string | |
| Enabled bool | |
| CertFile string | |
| KeyFile string |
the instance of this struct will typically called ssl or something so meaning is typically provided by that context
Prow currently requires SSL connections to be terminated before connecting to the deck and hook pods. This does not enable users to run prow with backend https enabled on their ingress. This PR adds the option to enable backend https on ingresses by passing in specific flags to the hook and deck pods. The argument flags will look like as below:
hook:
deck:
In the example above, a secret containing the cert file and key file was mounted to the deck and hook pods. Additionally this has been tested to continue working as is with ingress backend to be set to just HTTP if the flags are not passed in.