-
Notifications
You must be signed in to change notification settings - Fork 501
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
Add proxy server for Dashboard #2684
Conversation
if strings.HasPrefix(req.RequestURI, "/dashboard") { | ||
director(req) | ||
req.Host = req.URL.Host | ||
} |
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.
Ensuring no pdapi would be exposed.
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
how about passing the part、backend service、tls configs to the discovery service? then this discovery service can be a generic proxy server. |
That's ok for me but I think it is not necessary currently as I can't find out second service needed proxy to be exposed. |
pkg/discovery/server/proxy.go
Outdated
} | ||
proxy := httputil.NewSingleHostReverseProxy(url) | ||
if url.Scheme == "https" { | ||
tlsConfig, err := pdapi.GetTLSConfig(kubeCli, pdapi.Namespace(namespace), tcName, nil) |
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.
the client secret may be invalid or expired, we need to find a way to refresh HTTP server when the secret is updated
we can mount the secrets into the pod, and reload the TLS when necessary like PD, tidb
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.
good catch
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.
updated.
Co-authored-by: Yecheng Fu <[email protected]>
RootCAs: rootCAs, | ||
} | ||
proxy.Transport = &http.Transport{TLSClientConfig: tlsConfig} | ||
} |
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.
certs are loaded once at startup, I guess we should reload TLS certificates for every client request
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 is a simple mechanism to make sure this proxy will not fail when the certs are expired
we can also have some unit tests to verify this (this can be tracked in a separate issue)
ref: etcd-io/etcd#7829
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.
certs are loaded once at startup, I guess we should reload TLS certificates for every client request
Not sure whether this would be quite time-consuming but is this necessary?
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 is how PD/TiDB refresh TLS certificates too
it's possible to refresh on expiration (see etcd TODO), but I don't think it's necessary. just read certificates every time
actually these small disk files are cached in buffer in most time
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.
make sense. updated. now the proxy would be initialed each time
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
Signed-off-by: sre-bot <[email protected]>
cherry pick to release-1.1 in PR #2689 |
Signed-off-by: sre-bot <[email protected]> Co-authored-by: Song Gao <[email protected]>
What problem does this PR solve?
Close #2395
When
tlsCluster
is enabled, dashboard should be visited after loaded pd client cert in browser which didn't make sense.What is changed and how does it work?
This pr make
discovery
service as a proxy-server for the pd dashboard service like following.When
tlsCluster
is enabled, the proxy-server would automatically loaded cert from secret and expose the http api. Also, proxy-server ensured that only requestURI started with/dashboard
would be redirected. No pdapi would be exposed by proxy-server.Related changes
Does this PR introduce a user-facing change?: