Documentation ¶
Index ¶
Constants ¶
const ( // DefaultStreamIdleTimeout is the timeout for idle stream. DefaultStreamIdleTimeout = 4 * time.Hour // DefaultStreamCreationTimeout is the timeout for stream creation. DefaultStreamCreationTimeout = 30 * time.Second )
Keep these constants consistent with the peers in official package: k8s.io/kubernetes/pkg/kubelet/server.
Variables ¶
var ( // CacheTTL is timeout after which tokens become invalid. CacheTTL = 1 * time.Minute // MaxInFlight is the maximum number of in-flight requests to allow. MaxInFlight = 1000 // TokenLen is the length of the random base64 encoded token identifying the request. TokenLen = 8 )
var DefaultConfig = Config{ StreamIdleTimeout: 4 * time.Hour, StreamCreationTimeout: DefaultStreamCreationTimeout, SupportedRemoteCommandProtocols: SupportedStreamingProtocols, SupportedPortForwardProtocols: SupportedPortForwardProtocols, }
DefaultConfig provides default values for server Config.
var SupportedPortForwardProtocols = []string{constant.PortForwardProtocolV1Name}
SupportedPortForwardProtocols is the portforward protocols which server supports.
var SupportedStreamingProtocols = []string{constant.StreamProtocolV1Name, constant.StreamProtocolV2Name}
SupportedStreamingProtocols is the streaming protocols which server supports.
Functions ¶
func ErrorStreamingDisabled ¶
ErrorStreamingDisabled returns error when the streaming method is disabled.
func ErrorTooManyInFlight ¶
func ErrorTooManyInFlight() error
ErrorTooManyInFlight returns error when the maximum number of in-flight requests is exceeded.
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 { // Address is the addr:port address the server will listen on. Address string // BaseURL is the optional base URL for constructing streaming URLs. If empty, the baseURL will be constructed from the serve address. BaseURL *url.URL // StreamIdleTimeout is how long to leave idle connections open for. StreamIdleTimeout time.Duration // StreamCreationTimeout is how long to wait for clients to create streams. Only used for SPDY streaming. StreamCreationTimeout time.Duration // SupportedStreamingProtocols is the streaming protocols which server supports. SupportedRemoteCommandProtocols []string // SupportedPortForwardProtocol is the portforward protocols which server supports. SupportedPortForwardProtocols []string }
Config defines the options used for running the stream server.
type Runtime ¶
type Runtime interface { // Exec executes the command in pod. Exec(containerID string, cmd []string, streamOpts *remotecommand.Options, streams *remotecommand.Streams) (uint32, error) // Attach attaches to pod. Attach(containerID string, streamOpts *remotecommand.Options, streams *remotecommand.Streams) error // PortForward forward port to pod. PortForward(name string, port int32, stream io.ReadWriteCloser) error }
Runtime is the interface to execute the commands and provide the streams.
type Server ¶
type Server interface { // GetExec get the serving URL for Exec request. GetExec(*runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) // GetAttach get the serving URL for Attach request. GetAttach(*runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) // GetPortForward get the serving URL for PortForward request. GetPortForward(*runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) // Start starts the stream server. Start() error }
Server as an interface defines all operations against stream server.