Documentation
¶
Overview ¶
Package exec provides WebSocket-based remote command execution in workspace pods. It bridges WebSocket connections from clients to Kubernetes exec streams, enabling interactive terminal sessions within running workspace containers.
Package exec provides a WebSocket-to-Kubernetes-exec bridge for terminal sessions.
Index ¶
- func Handler(opts *Options) http.HandlerFunc
- func SSHConsoleInUse(namespace, name string) bool
- func SSHHandler(opts *SSHOptions) http.HandlerFunc
- func SerialConsoleInUse(namespace, name string) bool
- func TakeOverSSHConsole(namespace, name string) bool
- func TakeOverSerialConsole(namespace, name string) bool
- func VMConsoleHandler(opts *Options) http.HandlerFunc
- func VMVNCHandler(opts *Options) http.HandlerFunc
- type Options
- type SSHOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
func Handler(opts *Options) http.HandlerFunc
Handler creates an HTTP handler that upgrades to WebSocket and bridges to pod exec. The handler expects path parameters: namespace, name (workspace name). Query parameters: shell (optional, auto-detected if not provided), cols, rows.
func SSHConsoleInUse ¶ added in v0.4.0
SSHConsoleInUse reports whether an SSH bridge is currently active for the workspace.
func SSHHandler ¶ added in v0.4.0
func SSHHandler(opts *SSHOptions) http.HandlerFunc
SSHHandler creates an HTTP handler that upgrades to WebSocket and bridges to the guest's sshd over the workspace's masqueraded port. The client authentic with the private key matching one of the public keys the controller seeded into the guest's cloud-init (SshKey CRs).
The target is the workspace Service's endpoints address:port — the virt-launcher pod IP where KubeVirt's masquerade DNATs to the guest — which bypasses the Service ClusterIP (VM Services do not DNAT correctly under the launcher's iptables; the pod IP path works cross-node). Guest sshd host keys are self-generated and rotate per image rebuild, so no host key verification is possible; the session is carried over the authenticated WS + TLS to the API instead.
func SerialConsoleInUse ¶ added in v0.4.0
SerialConsoleInUse reports whether a serial console bridge is currently active for the workspace.
func TakeOverSSHConsole ¶ added in v0.4.0
TakeOverSSHConsole force-ends the active SSH bridge for the workspace, if any.
func TakeOverSerialConsole ¶ added in v0.4.0
TakeOverSerialConsole force-ends the active serial console bridge for the workspace, if any, so the caller can open a fresh session. It returns whether a session was active.
func VMConsoleHandler ¶ added in v0.4.0
func VMConsoleHandler(opts *Options) http.HandlerFunc
VMConsoleHandler creates an HTTP handler that upgrades the client connection to a WebSocket and bridges it to the KubeVirt VMI serial console subresource. The VMI name equals the workspace name. The console is a raw serial stream: no shell is spawned — the guest image must run a getty on the console for a login prompt to appear.
func VMVNCHandler ¶ added in v0.4.0
func VMVNCHandler(opts *Options) http.HandlerFunc
VMVNCHandler returns an HTTP handler that upgrades the client connection to a WebSocket and bridges it to the KubeVirt VMI VNC subresource. The VMI name equals the workspace name. The socket carries the raw RFB (VNC) byte stream; the client side is expected to run a noVNC RFB client on top. KubeVirt's VNC console is single-session: while another session is active the dial fails with "Active VNC connection. Request denied."
Types ¶
type Options ¶
type Options struct {
// RESTConfig is the Kubernetes REST config for SPDY exec connections.
RESTConfig *rest.Config
// Clientset is the Kubernetes clientset for pod exec requests.
Clientset kubernetes.Interface
}
Options configures the exec handler.
type SSHOptions ¶ added in v0.4.0
type SSHOptions struct {
// Clientset is used to resolve the workspace Service endpoints (the
// launcher pod IP:port that masquerade forwards to the guest sshd).
Clientset kubernetes.Interface
}
SSHOptions configures the SSH bridge handler.