@@ -262,7 +262,7 @@ Currently, the bi-directional streaming protocols (either SPDY or WebSockets) ar
262
262
initiated from clients, proxied by the API Server and Kubelet, and terminated at
263
263
the Container Runtime (e.g. containerd or CRI-O). This enhancement proposes to 1)
264
264
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
266
266
a SPDY upstream connection. In this way, the cluster components upstream from the
267
267
API Server will not initially need to be changed. We intend to extend the communication
268
268
path for WebSockets streaming from ` kubectl ` to Kubelet once the the initial leg
@@ -317,22 +317,6 @@ is redirected to other API endpoints.
317
317
318
318
- Mitigation: Upgraded connections are disallowed from redirecting.
319
319
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
-
336
320
- Risk: Performance
337
321
338
322
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.
591
575
The following packages (including current test coverage) will be modified to implement
592
576
this SDPY to WebSockets migration.
593
577
578
+ - ` k8s.io/kubernetes/staging/src/k8s.io/client-go/tools/portforward ` : ` 2024-05-27 ` - ` 86.3% `
594
579
- ` k8s.io/kubernetes/staging/src/k8s.io/client-go/tools/remotecommand ` : ` 2023-05-31 ` - ` 57.3% `
595
580
- ` k8s.io/kubernetes/staging/src/k8s.io/client-go/transport ` : ` 2023-05-31 ` - ` 57.7% `
596
581
- ` k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/httpstream ` : ` 2023-05-31 ` - ` 76.7% `
597
582
- ` 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% `
598
584
- ` k8s.io/kubernetes/staging/src/k8s.io/kubectl/pkg/cmd/attach ` : ` 2023-06-05 ` - ` 43.4% `
599
585
- ` k8s.io/kubernetes/staging/src/k8s.io/kubectl/pkg/cmd/cp ` : ` 2023-06-05 ` - ` 66.3% `
600
586
- ` 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% `
601
588
602
589
An important set of tests for this migration will be ** loopback** tests, which exercise the
603
590
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
633
620
634
621
-->
635
622
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 `
638
624
639
625
##### e2e tests
640
626
@@ -650,7 +636,7 @@ We expect no non-infra related flakes in the last month as a GA graduation crite
650
636
- `<test>: <link to test coverage>`
651
637
-->
652
638
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 ` ,
654
640
we will enhance these tests with the permutations of the feature flags for ` kubectl `
655
641
and the API Server. We will add e2e test coverage for flags and arguments that are
656
642
not already covered for these commands.
@@ -740,9 +726,9 @@ in back-to-back releases.
740
726
` kubectl port-forward ` behind the ` kubectl ` environment variable KUBECTL_PORT_FORWARD_WEBSOCKETS
741
727
which is ** OFF** by default.
742
728
- 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
744
730
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
746
732
behind the API Server feature flag ` PortForwardWebsockets ` which is ** OFF** by default.
747
733
748
734
#### Beta
@@ -755,6 +741,13 @@ in back-to-back releases.
755
741
756
742
##### v1.31 PortForward Subprotocol (port-forward)
757
743
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.
758
751
- Additional ` port-forward ` unit tests completed and enabled.
759
752
- Additional ` port-forward ` integration tests completed and enabled.
760
753
- Additional ` port-forward ` e2e tests completed and enabled.
@@ -825,7 +818,7 @@ just as it has for the last several years.
825
818
#### PortForward Subprotocol
826
819
827
820
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.
829
822
830
823
In this case, the initial upgrade request for ` PortForward ` WebSockets will
831
824
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
835
828
functionality in this case will work exactly as it has for the last several years.
836
829
837
830
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.
839
832
840
833
The ` kubectl port-forward ` will successfully request an upgrade for legacy
841
834
` SPDY/PortForward - V1 ` , just as it has for the last several years.
842
835
843
836
#### Version Skew within the Control Plane and Nodes
844
837
845
838
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
848
841
streaming between the client and the API Server, but it is designed to provide legacy
849
842
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
851
844
the possibility of intra-cluster version skew.
852
845
853
846
## Production Readiness Review Questionnaire
@@ -917,10 +910,6 @@ KUBECTL_PORT_FORWARD_WEBSOCKETS environment variable must be set to **ON** for
917
910
user unless the ` kubectl ` /API Server communication is communicating through an
918
911
intermediary such as a proxy (which is the whole reason for the feature).
919
912
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
-
924
913
###### Can the feature be disabled once it has been enabled (i.e. can we roll back the enablement)?
925
914
926
915
<!--
@@ -959,9 +948,13 @@ https://github.com/kubernetes/kubernetes/pull/97058/files#diff-7826f7adbc1996a05
959
948
-->
960
949
961
950
- 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.
962
952
- There will be unit tests in the API Server which exercise the feature gate within
963
953
the ` UpgradeAwareProxy ` , which conditionally delegates to the ` StreamTranslator `
964
954
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.
965
958
966
959
### Rollout, Upgrade and Rollback Planning
967
960
@@ -1459,6 +1452,7 @@ Major milestones might include:
1459
1452
- RemoteCommand over WebSockets shipped as beta: v1.30
1460
1453
- First Kubernetes release where PortForward over WebSockets described in KEP: v1.30
1461
1454
- PortForward over WebSockets shipped as alpha: v1.30
1455
+ - PortForward over WebSockets shipped as beta: v1.31
1462
1456
1463
1457
## Drawbacks
1464
1458
0 commit comments