Documentation ¶
Index ¶
- Variables
- func NewErrorStreamingDisabled(method string) error
- func NewErrorTooManyInFlight() error
- func WriteError(err error, w http.ResponseWriter) error
- type Config
- type ExecHandler
- type Runtime
- type Server
- type StreamingRuntime
- func (r *StreamingRuntime) Attach(ctx context.Context, containerID string, in io.Reader, ...) error
- func (r *StreamingRuntime) Exec(ctx context.Context, containerID string, cmd []string, in io.Reader, ...) error
- func (r *StreamingRuntime) ExecWithContext(ctx context.Context, containerID string, cmd []string, in io.Reader, ...) error
- func (r *StreamingRuntime) PortForward(ctx context.Context, podSandboxID string, port int32, ...) error
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = Config{ StreamIdleTimeout: 4 * time.Hour, StreamCreationTimeout: remotecommandconsts.DefaultStreamCreationTimeout, SupportedRemoteCommandProtocols: remotecommandconsts.SupportedStreamingProtocols, SupportedPortForwardProtocols: portforward.SupportedProtocols, }
DefaultConfig provides default values for server Config. The DefaultConfig is partial, so some fields like Addr must still be provided.
Functions ¶
func NewErrorStreamingDisabled ¶
NewErrorStreamingDisabled creates an error for disabled streaming method.
func NewErrorTooManyInFlight ¶
func NewErrorTooManyInFlight() error
NewErrorTooManyInFlight creates an error for exceeding the maximum number of in-flight requests.
func WriteError ¶
func WriteError(err error, w http.ResponseWriter) error
WriteError translates a CRI streaming error into an appropriate HTTP response.
Types ¶
type Config ¶
type Config struct { // The host:port address the server will listen on. Addr string // The optional base URL for constructing streaming URLs. If empty, the baseURL will be // constructed from the serve address. // Note that for port "0", the URL port will be set to actual port in use. BaseURL *url.URL // How long to leave idle connections open for. StreamIdleTimeout time.Duration // How long to wait for clients to create streams. Only used for SPDY streaming. StreamCreationTimeout time.Duration // The streaming protocols the server supports (understands and permits). See // k8s.io/kubernetes/pkg/kubelet/server/remotecommand/constants.go for available protocols. // Only used for SPDY streaming. SupportedRemoteCommandProtocols []string // The streaming protocols the server supports (understands and permits). See // k8s.io/kubernetes/pkg/kubelet/server/portforward/constants.go for available protocols. // Only used for SPDY streaming. SupportedPortForwardProtocols []string // The config for serving over TLS. If nil, TLS will not be used. TLSConfig *tls.Config }
Config defines the options used for running the stream server.
type ExecHandler ¶
type ExecHandler interface { ExecInContainer( ctx context.Context, client libdocker.DockerClientInterface, container *dockertypes.ContainerJSON, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize, timeout time.Duration, ) error }
ExecHandler knows how to execute a command in a running Docker container.
type Runtime ¶
type Runtime interface { Exec(ctx context.Context, containerID string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize) error Attach(ctx context.Context, containerID string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize) error PortForward(ctx context.Context, podSandboxID string, port int32, stream io.ReadWriteCloser) error }
Runtime is the interface to execute the commands and provide the streams.
type Server ¶
type Server interface { http.Handler // Get the serving URL for the requests. // Requests must not be nil. Responses may be nil iff an error is returned. GetExec(*runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) GetAttach(req *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) GetPortForward(*runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) // Start the server. // addr is the address to serve on (address:port) stayUp indicates whether the server should // listen until Stop() is called, or automatically stop after all expected connections are // closed. Calling Get{Exec,Attach,PortForward} increments the expected connection count. // Function does not return until the server is stopped. Start(stayUp bool) error // Stop the server, and terminate any open connections. Stop() error }
Server is the library interface to serve the stream requests.
type StreamingRuntime ¶
type StreamingRuntime struct { Client libdocker.DockerClientInterface ExecHandler ExecHandler }
func (*StreamingRuntime) Attach ¶
func (r *StreamingRuntime) Attach( ctx context.Context, containerID string, in io.Reader, out, errw io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize, ) error
func (*StreamingRuntime) Exec ¶
func (r *StreamingRuntime) Exec( ctx context.Context, containerID string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize, ) error
func (*StreamingRuntime) ExecWithContext ¶
func (r *StreamingRuntime) ExecWithContext( ctx context.Context, containerID string, cmd []string, in io.Reader, out, errw io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize, timeout time.Duration, ) error
ExecWithContext adds a context.
func (*StreamingRuntime) PortForward ¶
func (r *StreamingRuntime) PortForward( ctx context.Context, podSandboxID string, port int32, stream io.ReadWriteCloser, ) error
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package portforward contains server-side logic for handling port forwarding requests.
|
Package portforward contains server-side logic for handling port forwarding requests. |
Package remotecommand contains functions related to executing commands in and attaching to pods.
|
Package remotecommand contains functions related to executing commands in and attaching to pods. |