Fix broken port forwarding on K8S 1.31+#218
Open
skissane-medallia wants to merge 1 commit intokubecost:mainfrom
Open
Fix broken port forwarding on K8S 1.31+#218skissane-medallia wants to merge 1 commit intokubecost:mainfrom
skissane-medallia wants to merge 1 commit intokubecost:mainfrom
Conversation
| http.MethodPost, | ||
| reqURL, | ||
| ) | ||
| var dialer httpstream.Dialer |
Member
There was a problem hiding this comment.
We can do something similar to how kubectl uses it? Ref: https://github.com/kubernetes/kubectl/blob/f290e4d08347157fe2a5586127820587c058eec6/pkg/cmd/portforward/portforward.go#L139-L156
It handles few important cases like: kubernetes/kubernetes#126231
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR change?
In K8S 1.31 and later, SPDY-based port forwarding is no longer supported – see project announcement. But the code in
pkg/query/portforward.gois written to use that. As a result, attempting to usekubectl costwill fail with this error:I modified the code in
pkg/query/portforward.goto use the new Websocket API instead.I was worried that might break things for anyone trying to use this with an older K8S version which doesn't support WebSockets. So I added an environment variable
KUBECOST_DISABLE_WEBSOCKETSto revert to the old code (if set totrue) if it breaks it for anybody. Maybe it should be a command line option instead, but I was just trying to do the minimal thing necessary to fix my own problem.Does this PR rely on any other PRs?
How does this PR impact users? (This is the kind of thing that goes in release notes!)
KUBECOST_DISABLE_WEBSOCKETS=trueadded to revert to the old pre-1.31 communication mechanism, in case this change breaks usingkubectl costwith older Kubernetes versionsLinks to Issues or ZD tickets this PR addresses or fixes
None
How was this PR tested?
I have kubecost running under Kubernetes 1.33.
Before this PR, any attempt to use
kubectl costfailed on it.With this PR, it works.
Have you made an update to documentation?
No