Skip to content

Commit 1b0dd3c

Browse files
committed
Update KEP-5695: Refine Test Plan
- Detail required unit tests and existing test infrastructure. - Update E2E test requirements. - Update Graduation Criteria to include enabling existing test stubs. - Update Implementation History with test infrastructure preparation. Signed-off-by: Willian Paixao <[email protected]>
1 parent ece5dd7 commit 1b0dd3c

File tree

1 file changed

+65
-38
lines changed
  • keps/sig-cli/5695-kubectl-reverse-port-forward

1 file changed

+65
-38
lines changed

keps/sig-cli/5695-kubectl-reverse-port-forward/README.md

Lines changed: 65 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
- [API Changes](#api-changes)
1818
- [Implementation Overview](#implementation-overview)
1919
- [Test Plan](#test-plan)
20-
- [Prerequisite testing updates](#prerequisite-testing-updates)
21-
- [Unit tests](#unit-tests)
22-
- [Integration tests](#integration-tests)
23-
- [e2e tests](#e2e-tests)
20+
- [Prerequisite Testing Updates](#prerequisite-testing-updates)
21+
- [Unit Tests](#unit-tests)
22+
- [Integration Tests](#integration-tests)
23+
- [E2E Tests](#e2e-tests)
2424
- [Graduation Criteria](#graduation-criteria)
2525
- [Alpha](#alpha)
2626
- [Beta](#beta)
@@ -42,6 +42,7 @@
4242
- [Alternative 3: Service Mesh Integration](#alternative-3-service-mesh-integration)
4343
- [Alternative 4: API Server Proxy](#alternative-4-api-server-proxy)
4444
- [Infrastructure Needed](#infrastructure-needed)
45+
- [References](#references)
4546
<!-- /toc -->
4647

4748
## Release Signoff Checklist
@@ -52,9 +53,9 @@ Items marked with (R) are required *prior to targeting to a milestone / release*
5253
- [ ] (R) KEP approvers have approved the KEP status as `implementable`
5354
- [ ] (R) Design details are appropriately documented
5455
- [ ] (R) Test plan is in place, giving consideration to SIG Architecture and SIG Testing input
55-
- [ ] e2e Tests for all Beta API Operations (endpoints)
56-
- [ ] (R) Ensure GA e2e tests meet requirements for [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md)
57-
- [ ] (R) Minimum Two Week Window for GA e2e tests to prove flake free
56+
- [ ] E2E Tests for all Beta API Operations (endpoints)
57+
- [ ] (R) Ensure GA E2E tests meet requirements for [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md)
58+
- [ ] (R) Minimum Two Week Window for GA E2E tests to prove flake free
5859
- [ ] (R) Graduation criteria is in place
5960
- [ ] (R) [all GA Endpoints](https://github.com/kubernetes/community/pull/1806) must be hit by [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md) within one minor version of promotion to GA
6061
- [ ] (R) Production readiness review completed
@@ -230,25 +231,33 @@ The implementation builds upon the existing port-forward infrastructure with the
230231

231232
**4. Flow Diagram:**
232233

233-
```
234-
Reverse Port-Forward Flow:
235-
236-
1. Setup Phase:
237-
kubectl --reverse → kubelet → creates listener in pod namespace
238-
239-
2. Connection Phase:
240-
pod process → connects to localhost:REMOTE_PORT
241-
242-
listener in pod namespace → forwards to kubelet
243-
244-
kubelet → streams connection to kubectl (via WebSocket/HTTP2)
245-
246-
kubectl → connects to localhost:LOCAL_PORT
247-
248-
local service receives connection
249-
250-
3. Data Transfer:
251-
Bidirectional streaming between local service ↔ kubectl ↔ kubelet ↔ pod
234+
```mermaid
235+
sequenceDiagram
236+
participant User
237+
participant kubectl
238+
participant APIServer as API Server
239+
participant kubelet
240+
participant Pod
241+
242+
Note over User,Pod: Setup Phase
243+
User->>kubectl: port-forward --reverse pod 8080:80
244+
kubectl->>APIServer: Establish streaming connection
245+
APIServer->>kubelet: Forward port-forward request
246+
kubelet->>Pod: Create listener on port 8080 in pod netns
247+
248+
Note over User,Pod: Connection Phase
249+
Pod->>Pod: Process connects to localhost:8080
250+
Pod->>kubelet: Connection received
251+
kubelet->>kubectl: Stream new connection
252+
kubectl->>User: Connect to localhost:80
253+
254+
Note over User,Pod: Data Transfer
255+
User->>kubectl: Send data
256+
kubectl->>kubelet: Forward data
257+
kubelet->>Pod: Deliver to pod
258+
Pod->>kubelet: Response data
259+
kubelet->>kubectl: Forward response
260+
kubectl->>User: Deliver response
252261
```
253262

254263
**5. Implementation Components:**
@@ -273,30 +282,46 @@ Reverse Port-Forward Flow:
273282
existing tests to make this code solid enough prior to committing the changes necessary
274283
to implement this enhancement.
275284

276-
##### Prerequisite testing updates
285+
#### Prerequisite Testing Updates
277286

278287
- Ensure existing port-forward tests are not affected by the changes
279288
- Add test coverage for the new protocol messages
280289
- Verify backward compatibility with clusters not supporting reverse port-forward
281290

282-
##### Unit tests
291+
#### Unit Tests
292+
293+
**Existing Test Infrastructure:**
294+
295+
Test stubs for reverse port-forward have been prepared in `k8s.io/kubectl/pkg/cmd/portforward/portforward_test.go`:
296+
- `TestReversePortForwardFlagParsing`: Tests `--reverse` flag parsing
297+
- `TestReversePortSpecificationSyntax`: Tests port specification format validation
298+
- `TestReversePortForwardValidation`: Tests validation logic for reverse mode
299+
- `TestReverseForwardModeConflict`: Tests that forward/reverse modes cannot be mixed
300+
- `TestPortRangeValidation`: Port range validation helper tests
301+
302+
These tests are currently skipped (waiting for implementation) and will be enabled during alpha implementation.
303+
304+
**Required Unit Test Coverage:**
283305

284-
- `k8s.io/kubectl/pkg/cmd/portforward`: 2025-01-18 - (baseline + new reverse mode tests)
285-
- Port spec parsing for reverse mode
306+
- `k8s.io/kubectl/pkg/cmd/portforward`:
307+
- Port spec parsing for reverse mode (REMOTE:LOCAL format)
286308
- Reverse connection handling logic
287309
- Error handling for reverse-specific failures
310+
- Flag validation (`--reverse` with various port specs)
311+
- Port range validation (1-65535 for remote, 0-65535 for local)
288312

289-
- `k8s.io/kubernetes/pkg/kubelet/cri/streaming/portforward`: 2025-01-18 - (baseline + new reverse protocol tests)
313+
- `k8s.io/kubernetes/pkg/kubelet/cri/streaming/portforward`:
290314
- Reverse mode protocol handshake
291315
- Connection multiplexing
292316
- Listener cleanup on disconnect
317+
- Error handling for port conflicts
293318

294-
- `k8s.io/kubernetes/pkg/kubelet`: 2025-01-18 - (baseline + new namespace listener tests)
319+
- `k8s.io/kubernetes/pkg/kubelet`:
295320
- Pod network namespace listener creation
296321
- Port conflict detection
297-
- Resource cleanup
322+
- Resource cleanup on connection termination
298323

299-
##### Integration tests
324+
#### Integration Tests
300325

301326
- Test reverse port-forward with real kubelet and pod
302327
- Test multiple concurrent reverse connections
@@ -307,7 +332,7 @@ to implement this enhancement.
307332

308333
Integration test location: `test/integration/kubectl/portforward_reverse_test.go`
309334

310-
##### e2e tests
335+
#### E2E Tests
311336

312337
- End-to-end reverse port-forward test with real cluster
313338
- Create pod with simple client application
@@ -327,7 +352,8 @@ E2E test location: `test/e2e/kubectl/portforward.go` (extend existing tests)
327352

328353
- Feature implemented behind `KubectlReversePortForward` feature gate
329354
- Basic functionality working (single port, single connection)
330-
- Unit tests for kubectl and kubelet components
355+
- Unit tests for kubectl and kubelet components (test infrastructure already prepared)
356+
- Enable and complete existing test stubs in `portforward_test.go`
331357
- Initial e2e tests completed
332358
- Documentation drafted
333359

@@ -386,7 +412,7 @@ The feature will handle version skew gracefully:
386412

387413
###### How can this feature be enabled / disabled in a live cluster?
388414

389-
- [X] Feature gate (also fill in values in `kep.yaml`)
415+
- [x] Feature gate (also fill in values in `kep.yaml`)
390416
- Feature gate name: `KubectlReversePortForward`
391417
- Components depending on the feature gate:
392418
- kubelet
@@ -574,6 +600,7 @@ No persistent state is stored in etcd for reverse port-forward sessions. The fea
574600
- 2016-01-27: Original feature request filed as [#20227](https://github.com/kubernetes/kubernetes/issues/20227)
575601
- 2017-12-18: Initial PoC implementation as [#57320](https://github.com/kubernetes/kubernetes/pull/57320)
576602
- 2025-11-18: KEP created
603+
- 2025-11-19: Test infrastructure prepared in `portforward_test.go` with comprehensive test stubs
577604
- TBD: Alpha implementation targeting v1.34
578605
- TBD: Beta implementation targeting v1.35
579606
- TBD: GA implementation targeting v1.36
@@ -624,4 +651,4 @@ No special infrastructure required. The feature builds on existing port-forward
624651
- Original PoC: https://github.com/kubernetes/kubernetes/pull/57320
625652
- SSH Reverse Port Forward Documentation: https://man.openbsd.org/ssh#R
626653
- Similar tools for comparison:
627-
- Telepresence: https://www.telepresence.io/
654+
- Telepresence: https://www.telepresence.io/

0 commit comments

Comments
 (0)