Package io.kubernetes.client
Class PortForward
java.lang.Object
io.kubernetes.client.PortForward
Utility class for setting up port-forwarding connections. Uses the WebSockets API, not the SPDY
API (which the Go client uses)
The protocol is undocumented as far as I can tell, but the PR that added it is here: github.com/kubernetes/kubernetes/pull/33684
And the protocol is:
web sockets on server/api/v1/namespaces/<namespace>/pods/<pod>/portforward with args ports=80 and ports=8080
I/O for first port (80) is on Channel 0 Err for first port (80) is on Channel 1 I/O for second port (8080) is on Channel 2 Err for second port (8080) is on Channel 3 < and so on for remaining ports>
The first two bytes of each output stream is the port that is being forwarded in little-endian format.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
PortForwardResult contains the result of an Attach call, it includes streams for stdout stderr and stdin. -
Constructor Summary
ConstructorsConstructorDescriptionSimple PortForward API constructor, uses default configurationPortForward
(io.kubernetes.client.openapi.ApiClient apiClient) PortForward API Constructor -
Method Summary
Modifier and TypeMethodDescriptionPortForward to a containerPortForward to a container.io.kubernetes.client.openapi.ApiClient
Get the API client for these PortForward operations.void
setApiClient
(io.kubernetes.client.openapi.ApiClient apiClient) Set the API client for subsequent PortForward operations.
-
Constructor Details
-
PortForward
public PortForward()Simple PortForward API constructor, uses default configuration -
PortForward
public PortForward(io.kubernetes.client.openapi.ApiClient apiClient) PortForward API Constructor- Parameters:
apiClient
- The api client to use.
-
-
Method Details
-
getApiClient
public io.kubernetes.client.openapi.ApiClient getApiClient()Get the API client for these PortForward operations.- Returns:
- The API client that will be used.
-
setApiClient
public void setApiClient(io.kubernetes.client.openapi.ApiClient apiClient) Set the API client for subsequent PortForward operations.- Parameters:
apiClient
- The new API client to use.
-
forward
public PortForward.PortForwardResult forward(io.kubernetes.client.openapi.models.V1Pod pod, List<Integer> ports) throws io.kubernetes.client.openapi.ApiException, IOException PortForward to a container- Parameters:
pod
- The pod where the port forward is run.ports
- The ports to forward- Returns:
- The result of the Port Forward request.
- Throws:
io.kubernetes.client.openapi.ApiException
IOException
-
forward
public PortForward.PortForwardResult forward(String namespace, String name, List<Integer> ports) throws io.kubernetes.client.openapi.ApiException, IOException PortForward to a container.- Parameters:
namespace
- The namespace of the Podname
- The name of the Podports
- The ports to forward- Returns:
- The result of the Port Forward request.
- Throws:
io.kubernetes.client.openapi.ApiException
IOException
-