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
kubectl proxy: append context host path to request path #97350
Conversation
Welcome @FabianKramm! |
Hi @FabianKramm. Thanks for your PR. I'm waiting for a kubernetes 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. |
/cc @lavalamp |
/ok-to-test |
/triage accepted |
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.
Thanks for opening this PR!
I think we should consider this a breaking change and make it opt-in instead of opt-out.
We could deprecate the old behavior?
Thoughts @soltysh?
staging/src/k8s.io/apimachinery/pkg/util/proxy/upgradeaware_test.go
Outdated
Show resolved
Hide resolved
I won't be able to review right now (also this is SIG CLI) but I think you should make it opt-in rather than opt-out. |
/retest |
Hi,
@varshaprasad96 @FabianKramm I would suggest raise this PR in SIG-CLI meeting to get attention from the group. Here the data for the meeting: |
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'm fine with this as is, the only addition I'd consider is adding an information that when your config's cluster has a path to print an information suggesting to use this flag. But that's rather a small nit.
/lgtm
/approve
/assign @lavalamp
for apimachinery bits approval
@@ -173,8 +173,8 @@ func makeUpgradeTransport(config *rest.Config, keepalive time.Duration) (proxy.U | |||
|
|||
// NewServer creates and installs a new Server. | |||
// 'filter', if non-nil, protects requests to the api only. | |||
func NewServer(filebase string, apiProxyPrefix string, staticPrefix string, filter *FilterServer, cfg *rest.Config, keepalive time.Duration) (*Server, error) { | |||
proxyHandler, err := NewProxyHandler(apiProxyPrefix, filter, cfg, keepalive) | |||
func NewServer(filebase string, apiProxyPrefix string, staticPrefix string, filter *FilterServer, cfg *rest.Config, keepalive time.Duration, appendLocationPath bool) (*Server, error) { |
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.
Yeah, kubectl-wise I'm ok with extending this method signature.
@@ -189,7 +189,7 @@ func NewServer(filebase string, apiProxyPrefix string, staticPrefix string, filt | |||
} | |||
|
|||
// NewProxyHandler creates an api proxy handler for the cluster | |||
func NewProxyHandler(apiProxyPrefix string, filter *FilterServer, cfg *rest.Config, keepalive time.Duration) (http.Handler, error) { | |||
func NewProxyHandler(apiProxyPrefix string, filter *FilterServer, cfg *rest.Config, keepalive time.Duration, appendLocationPath bool) (http.Handler, error) { |
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.
Ditto.
/priority important-longterm |
087ad25
to
9399ea2
Compare
@soltysh thanks for the review, I added a warning that shows up if a server path is detected and the flag is not enabled |
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
return err | ||
} | ||
if target.Path != "" && target.Path != "/" { | ||
klog.Warning("Your kube context contains a server path " + target.Path + ", use --append-server-path to automatically append the path to each 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.
👍
Needs one more test, then I can approve for api machinery. |
Signed-off-by: fabiankramm <fab.kramm@googlemail.com>
@lavalamp I added the test like you requested |
/approve for api machinery code. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: FabianKramm, lavalamp, soltysh 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 |
/lgtm |
Signed-off-by: fabiankramm fab.kramm@googlemail.com
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR adds a new flag
--append-server-path
tokubectl proxy
that changes the way how kube contexts are handled that specify a server with an appended path, e.g.https://my-apiserver.com/path/to/kubernetes
. Before this change,kubectl proxy
would always expose the api athttp://127.0.0.1:8001/path/to/kubernetes/...
, with this change and flag enabled it exposes the api athttp://127.0.0.1:8001/...
and automatically appends the kube context server path.Which issue(s) this PR fixes:
Fixes #94280
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: