Help us shape the future of Go! Take the 2026 Go Developer Survey

exec

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClaimTier1Session added in v0.5.0

func ClaimTier1Session(namespace, name string, cancel func()) (func(), bool)

ClaimTier1Session registers a new Tier 1 transport session for the workspace. It returns a release function and true on success, or nil and false if the slot is already taken.

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

func SSHConsoleInUse(namespace, name string) bool

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

func SerialConsoleInUse(namespace, name string) bool

SerialConsoleInUse reports whether a serial console bridge is currently active for the workspace.

func TakeOverSSHConsole added in v0.4.0

func TakeOverSSHConsole(namespace, name string) bool

TakeOverSSHConsole force-ends the active SSH bridge for the workspace, if any.

func TakeOverSerialConsole added in v0.4.0

func TakeOverSerialConsole(namespace, name string) bool

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 TakeOverTier1 added in v0.5.0

func TakeOverTier1(namespace, name string) bool

TakeOverTier1 force-ends the active Tier 1 transport session for the workspace, if any, so the caller can open a fresh session. It returns whether a session was active.

func TakeOverVNC added in v0.5.0

func TakeOverVNC(namespace, name string) bool

TakeOverVNC force-ends the active VNC bridge for the workspace, if any, so the caller can open a fresh session. It returns whether a session was active.

func Tier1InUse added in v0.5.0

func Tier1InUse(namespace, name string) bool

Tier1InUse reports whether either interactive display transport is in use.

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."

func VNCInUse added in v0.5.0

func VNCInUse(namespace, name string) bool

VNCInUse reports whether either interactive display transport is in use.

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
	Display   *display.Store
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL