Skip to content

Commit a4a8c0c

Browse files
committed
PortForward Websockets graduates to Beta
1 parent e9ce75a commit a4a8c0c

File tree

2 files changed

+28
-34
lines changed

2 files changed

+28
-34
lines changed

keps/sig-api-machinery/4006-transition-spdy-to-websockets/README.md

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ Currently, the bi-directional streaming protocols (either SPDY or WebSockets) ar
262262
initiated from clients, proxied by the API Server and Kubelet, and terminated at
263263
the Container Runtime (e.g. containerd or CRI-O). This enhancement proposes to 1)
264264
modify `kubectl` to request a WebSocket based streaming connection, and to 2) modify
265-
the current API Server proxy to translate the `kubectl` WebSockets data stream to
265+
the current API Server proxy to translate or tunnel the `kubectl` WebSockets data stream to
266266
a SPDY upstream connection. In this way, the cluster components upstream from the
267267
API Server will not initially need to be changed. We intend to extend the communication
268268
path for WebSockets streaming from `kubectl` to Kubelet once the the initial leg
@@ -317,22 +317,6 @@ is redirected to other API endpoints.
317317

318318
- Mitigation: Upgraded connections are disallowed from redirecting.
319319

320-
- Risk: Overloaded Concurrency
321-
322-
PortForward subrequests (e.g. `curl http://localhost:8080/index.html` after the connection
323-
upgrade) can occur concurrently over the the upgraded streaming connection, and these
324-
subrequests can be long-lasting. Each of these subrequests creates two streams (an
325-
error stream and a data stream) over the connection, and there are four goroutines spawned
326-
to service this subrequest and its associated streams. After the completion of the
327-
subrequest, the associated resources are reclaimed.
328-
329-
- Mitigation: Throttling the number of concurrent subrequests will limit the
330-
number of concurrent streams and the number of concurrent goroutines on the
331-
API Server. This throttling will ensure the server does not get overloaded.
332-
If we need to the reduce number of concurrent goroutines even further we can
333-
explore goroutine pools so that the number of goroutines will grow sublinearly
334-
with the number of subrequests and streams.
335-
336320
- Risk: Performance
337321

338322
When transitioning from the SPDY streaming protocol to WebSockets, there may be a
@@ -591,13 +575,16 @@ extending the production code to implement this enhancement.
591575
The following packages (including current test coverage) will be modified to implement
592576
this SDPY to WebSockets migration.
593577

578+
- `k8s.io/kubernetes/staging/src/k8s.io/client-go/tools/portforward`: `2024-05-27` - `86.3%`
594579
- `k8s.io/kubernetes/staging/src/k8s.io/client-go/tools/remotecommand`: `2023-05-31` - `57.3%`
595580
- `k8s.io/kubernetes/staging/src/k8s.io/client-go/transport`: `2023-05-31` - `57.7%`
596581
- `k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/httpstream`: `2023-05-31` - `76.7%`
597582
- `k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/proxy`: `2023-05-31` - `59.1%`
583+
- `k8s.io/kubernetes/staging/src/k8s.io/apiserver/pkg/util/proxy`: `2024-05-27` - `81.5%`
598584
- `k8s.io/kubernetes/staging/src/k8s.io/kubectl/pkg/cmd/attach`: `2023-06-05` - `43.4%`
599585
- `k8s.io/kubernetes/staging/src/k8s.io/kubectl/pkg/cmd/cp`: `2023-06-05` - `66.3%`
600586
- `k8s.io/kubernetes/staging/src/k8s.io/kubectl/pkg/cmd/exec`: `2023-06-05` - `70.0%`
587+
- `k8s.io/kubernetes/staging/src/k8s.io/kubectl/pkg/cmd/portforward`: `2024-05-27` - `74.7%`
601588

602589
An important set of tests for this migration will be **loopback** tests, which exercise the
603590
WebSocket client and the StreamTranslator proxy. These tests create two test servers: a
@@ -633,8 +620,7 @@ https://storage.googleapis.com/k8s-triage/index.html
633620
634621
-->
635622

636-
No integration tests are planned for alpha. Previously mentioned unit tests and current
637-
e2e tests provide sufficient.
623+
`PortForward: https://github.com/kubernetes/kubernetes/blob/master/test/integration/apiserver/portforward/portforward_test.go`
638624

639625
##### e2e tests
640626

@@ -650,7 +636,7 @@ We expect no non-infra related flakes in the last month as a GA graduation crite
650636
- `<test>: <link to test coverage>`
651637
-->
652638

653-
While there are already numerous current e2e tests for `kubectl exec, cp, attach`,
639+
While there are already numerous current e2e tests for `kubectl exec, cp, attach, and port-forward`,
654640
we will enhance these tests with the permutations of the feature flags for `kubectl`
655641
and the API Server. We will add e2e test coverage for flags and arguments that are
656642
not already covered for these commands.
@@ -740,9 +726,9 @@ in back-to-back releases.
740726
`kubectl port-forward` behind the `kubectl` environment variable KUBECTL_PORT_FORWARD_WEBSOCKETS
741727
which is **OFF** by default.
742728
- FallbackDialer is completed and functional behind the `kubectl` environment variable
743-
KUBECTL_PORT_FORWARD which if **OFF** by default. The FallbackDialer executes legacy
729+
KUBECTL_PORT_FORWARD which is **OFF** by default. The FallbackDialer executes legacy
744730
SPDY `port-forward` if the server does not support the new WebSockets functionality.
745-
- PortForward `StreamTranslatorProxy` successfully added and integrated, living
731+
- PortForward `StreamTunnelingProxy` successfully added and integrated, living
746732
behind the API Server feature flag `PortForwardWebsockets` which is **OFF** by default.
747733

748734
#### Beta
@@ -755,6 +741,13 @@ in back-to-back releases.
755741

756742
##### v1.31 PortForward Subprotocol (port-forward)
757743

744+
- `kubectl port-forward` is behind the `kubectl` environment variable KUBECTL_PORT_FORWARD_WEBSOCKETS
745+
which is **ON** by default.
746+
- FallbackDialer is completed and functional behind the `kubectl` environment variable
747+
KUBECTL_PORT_FORWARD which is **ON** by default. The FallbackDialer executes legacy
748+
SPDY `port-forward` if the server does not support the new WebSockets functionality.
749+
- PortForward `StreamTunnelingProxy` successfully added and integrated, living
750+
behind the API Server feature flag `PortForwardWebsockets` which is **ON** by default.
758751
- Additional `port-forward` unit tests completed and enabled.
759752
- Additional `port-forward` integration tests completed and enabled.
760753
- Additional `port-forward` e2e tests completed and enabled.
@@ -825,7 +818,7 @@ just as it has for the last several years.
825818
#### PortForward Subprotocol
826819

827820
1. A newer WebSockets enabled `kubectl` communicating with an older API Server that
828-
does not support the newer PortForward `StreamTranslator` proxy.
821+
does not support the newer PortForward `StreamTunneling` proxy.
829822

830823
In this case, the initial upgrade request for `PortForward` WebSockets will
831824
fail, because the `WebSockets` upgrade request `v2.portforward.k8s.io` will be proxied
@@ -835,19 +828,19 @@ legacy SPDY `v1.portforward.k8s.io`. In this fallback case, the PortForward stre
835828
functionality in this case will work exactly as it has for the last several years.
836829

837830
2. A legacy non-WebSockets enabled `kubectl` communicating with a newer API Server that
838-
supports the newer PortForward `StreamTranslator` proxy.
831+
supports the newer PortForward `StreamTunneling` proxy.
839832

840833
The `kubectl port-forward` will successfully request an upgrade for legacy
841834
`SPDY/PortForward - V1`, just as it has for the last several years.
842835

843836
#### Version Skew within the Control Plane and Nodes
844837

845838
These proposals do not modify intra-cluster version skew behavior. The entire reason
846-
for the current `StreamTranslatorProxy` design is to ensure no modifications
847-
to communication within the Control Plane. The `StreamTranslatorProxy` can update
839+
for the current `StreamTranslatorProxy` and `StreamTunnelingProxy` design is to ensure no modifications
840+
to communication within the Control Plane. The `StreamTranslatorProxy` or `StreamTunnelingProxy` can update
848841
streaming between the client and the API Server, but it is designed to provide legacy
849842
SPDY streaming from the API Server to the other components within the ControlPlane.
850-
Once this `StreamTranslatorProxy` is moved to the kubelet, we will have to address
843+
Once these `StreamTranslatorProxy` and `StreamTunnelingProxy` are moved to the kubelet, we will have to address
851844
the possibility of intra-cluster version skew.
852845

853846
## Production Readiness Review Questionnaire
@@ -917,10 +910,6 @@ KUBECTL_PORT_FORWARD_WEBSOCKETS environment variable must be set to **ON** for
917910
user unless the `kubectl`/API Server communication is communicating through an
918911
intermediary such as a proxy (which is the whole reason for the feature).
919912

920-
**NOTE** These two sets of feature flags are currently at different maturity levels.
921-
As of v1.30, `RemoteCommand` feature flags are **enabled** by default (Beta), while
922-
`PortFoward` features flags are **disabled** by default (Alpha).
923-
924913
###### Can the feature be disabled once it has been enabled (i.e. can we roll back the enablement)?
925914

926915
<!--
@@ -959,9 +948,13 @@ https://github.com/kubernetes/kubernetes/pull/97058/files#diff-7826f7adbc1996a05
959948
-->
960949

961950
- There will be unit tests for the `kubectl` environment variable KUBECTL_REMOTE_COMMAND_WEBSOCKETS.
951+
- There are unit tests for the `kubectl` environment variable KUBECTL_PORT_FORWARD_WEBSOCKETS.
962952
- There will be unit tests in the API Server which exercise the feature gate within
963953
the `UpgradeAwareProxy`, which conditionally delegates to the `StreamTranslator`
964954
proxy (depending on the feature gate and the upgrade parameters).
955+
- There are unit tests in the API Server which exercise the feature gate within
956+
the `UpgradeAwareProxy`, which conditionally delegates to the `StreamTunneling`
957+
proxy for the PortForward subprotocol.
965958

966959
### Rollout, Upgrade and Rollback Planning
967960

@@ -1459,6 +1452,7 @@ Major milestones might include:
14591452
- RemoteCommand over WebSockets shipped as beta: v1.30
14601453
- First Kubernetes release where PortForward over WebSockets described in KEP: v1.30
14611454
- PortForward over WebSockets shipped as alpha: v1.30
1455+
- PortForward over WebSockets shipped as beta: v1.31
14621456

14631457
## Drawbacks
14641458

keps/sig-api-machinery/4006-transition-spdy-to-websockets/kep.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ stage: beta
2222
# The most recent milestone for which work toward delivery of this KEP has been
2323
# done. This can be the current (upcoming) milestone, if it is being actively
2424
# worked on.
25-
latest-milestone: "v1.30"
25+
latest-milestone: "v1.31"
2626

2727
# The milestone at which this feature was, or is targeted to be, at each stage.
2828
milestone:
2929
alpha: "v1.29"
30-
beta: "v1.30"
31-
stable: "v1.31"
30+
beta: "v1.31"
31+
stable: "v1.32"
3232

3333
# The following PRR answers are required at alpha release
3434
# List the feature gate name and the components for which it must be enabled

0 commit comments

Comments
 (0)