Skip to main content

Crate kube_portforward

Crate kube_portforward 

Source
Expand description

Kubernetes port-forward over SPDY

Speaks SPDY/3.1+portforward.k8s.io (tunnelled inside WebSocket binary messages) by default, falling back to the legacy Upgrade: SPDY/3.1 path when the apiserver rejects the WebSocket subprotocol. Multiplexes many concurrent local TCP connections over a small pool of upgraded connections using the SPDY/3.1 frame format.

§Why not kube::Api::portforward?

kube::Api::portforward opens a new WebSocket upgrade for every stream pair, has no keepalive, and gives you opaque errors. This crate multiplexes many stream pairs per upgrade, runs a Ping/Pong watchdog, exposes structured thiserror errors, and gracefully falls back to the legacy SPDY/3.1 path when the apiserver is too old for KEP-4006.

§Quick Start

use kube_portforward::Client;
use tokio::io::AsyncWriteExt;

let client = Client::new(kube, url);
let session = client.session("default", "nginx", 80).open().await?;
let mut stream = session.connect().await?;
stream.write_all(b"GET / HTTP/1.0\r\n\r\n").await?;
session.close().await?;

Structs§

Client
entry point that bundles a kube::Client with its cluster URL.
ClientBuilder
DataStream
ErrorStream
Forwarder
Long-lived port-forward orchestrator. Construct via Forwarder::builder.
ForwarderBuilder
PodWatcher
Watches pods in a namespace and tracks the currently ready pod matching a PodSelector. Owns a background reflector task that’s aborted on PodWatcher::shutdown.
ReadyPod
Snapshot of the currently ready pod.
Session
One port forward session that multiplexes many concurrent local connections over a pool of upgraded connections to the apiserver.
SessionBuilder
Builder for opening a session
Stream
port forward stream backed by one stream pair on a multiplexed connection to the apiserver. Implements AsyncRead + AsyncWrite on the data half. Dropping the Stream (or calling poll_shutdown) sends a SPDY FIN frame so the apiserver tears down the backing pod connection right away.

Enums§

Error
PodChange
Pod lifecycle change sent to subscribers.
PodSelector
Pod selection strategy.
RecoverySignal
Subprotocol
Protocol negotiated for a port-forward session.

Type Aliases§

RecoveryCallback