apiserverk8s.io/apiserver/pkg/util/proxy Index | Files | Directories

package proxy

import "k8s.io/apiserver/pkg/util/proxy"

Index

Functions

func NewRequestForProxy

func NewRequestForProxy(location *url.URL, req *http.Request) (*http.Request, context.CancelFunc)

NewRequestForProxy returns a shallow copy of the original request with a context that may include a timeout for discovery requests

func NewTranslatingHandler

func NewTranslatingHandler(delegate http.Handler, translator http.Handler, shouldTranslate func(*http.Request) bool) http.Handler

func ResolveCluster

func ResolveCluster(services listersv1.ServiceLister, namespace, id string, port int32) (*url.URL, error)

func ResolveEndpoint

func ResolveEndpoint(services listersv1.ServiceLister, endpoints listersv1.EndpointsLister, namespace, id string, port int32) (*url.URL, error)

ResolveEndpoint returns a URL to which one can send traffic for the specified service.

Types

type Options

type Options struct {
	Stdin  bool
	Stdout bool
	Stderr bool
	Tty    bool
}

Options contains details about which streams are required for remote command execution.

type StreamTranslatorHandler

type StreamTranslatorHandler struct {
	// Location is the location of the upstream proxy. It is used as the location to Dial on the upstream server
	// for upgrade requests.
	Location *url.URL
	// Transport provides an optional round tripper to use to proxy. If nil, the default proxy transport is used
	Transport http.RoundTripper
	// MaxBytesPerSec throttles stream Reader/Writer if necessary
	MaxBytesPerSec int64
	// Options define the requested streams (e.g. stdin, stdout).
	Options Options
}

StreamTranslatorHandler is a handler which translates WebSocket stream data to SPDY to proxy to kubelet (and ContainerRuntime).

func NewStreamTranslatorHandler

func NewStreamTranslatorHandler(location *url.URL, transport http.RoundTripper, maxBytesPerSec int64, opts Options) *StreamTranslatorHandler

NewStreamTranslatorHandler creates a new proxy handler. Responder is required for returning errors to the caller.

func (*StreamTranslatorHandler) ServeHTTP

func (h *StreamTranslatorHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type TunnelingHandler

type TunnelingHandler struct {
	// contains filtered or unexported fields
}

TunnelingHandler is a handler which tunnels SPDY through WebSockets.

func NewTunnelingHandler

func NewTunnelingHandler(upgradeHandler http.Handler) *TunnelingHandler

NewTunnelingHandler is used to create the tunnel between an upstream SPDY connection and a downstream tunneling connection through the stored UpgradeAwareProxy.

func (*TunnelingHandler) ServeHTTP

func (h *TunnelingHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP uses the upgradeHandler to tunnel between a downstream tunneling connection and an upstream SPDY connection. The tunneling connection is a wrapped WebSockets connection which communicates SPDY framed data. In the case the upstream upgrade fails, we delegate communication to the passed in "w" ResponseWriter.

Source Files

proxy.go streamtranslator.go streamtunnel.go translatinghandler.go websocket.go

Directories

PathSynopsis
pkg/util/proxy/metrics
Version
v0.30.9
Published
Jan 16, 2025
Platform
linux/amd64
Imports
36 packages
Last checked
1 minute ago

Tools for package owners.