Documentation
¶
Index ¶
- Variables
- func BytesCounterReaderWrap(r io.Reader) io.ReadCloser
- func BytesCounterWriterWrap(w io.Writer) io.Writer
- func CounterReset(wrapped interface{})
- func CounterValue(wrapped interface{}) int
- func FromTargetAction(proxyMode ProxyMode) rewriter.Action
- func LoggerWithCommonAttrs(ctx context.Context, attrs ...any) *slog.Logger
- func RegisterMetrics()
- func ToTargetAction(proxyMode ProxyMode) rewriter.Action
- func WatchLabel(isWatch bool) string
- func WrapRESTConfig(cfg *rest.Config, wrapper http.RoundTripper)
- type Handler
- type MetricsProvider
- type ProxyMetrics
- func (p *ProxyMetrics) ClientRequestRewriteDuration(dur time.Duration)
- func (p *ProxyMetrics) ClientRequestRewriteError()
- func (p *ProxyMetrics) ClientRequestRewriteSuccess()
- func (p *ProxyMetrics) FromClientBytesAdd(decision string, count int)
- func (p *ProxyMetrics) FromTargetBytesAdd(count int)
- func (p *ProxyMetrics) GotClientRequest()
- func (p *ProxyMetrics) RequestDuration(dur time.Duration)
- func (p *ProxyMetrics) RequestHandleError()
- func (p *ProxyMetrics) RequestHandleSuccess()
- func (p *ProxyMetrics) TargetResponseError()
- func (p *ProxyMetrics) TargetResponseInvalidJSON(status int)
- func (p *ProxyMetrics) TargetResponseRewriteDuration(dur time.Duration)
- func (p *ProxyMetrics) TargetResponseRewriteError()
- func (p *ProxyMetrics) TargetResponseRewriteSuccess()
- func (p *ProxyMetrics) TargetResponseSuccess(decision string)
- func (p *ProxyMetrics) ToClientBytesAdd(count int)
- func (p *ProxyMetrics) ToTargetBytesAdd(decision string, count int)
- type ProxyMode
- type RoundTripper
- type StreamHandler
Constants ¶
This section is empty.
Variables ¶
var Subsystem = defaultSubsystem
Functions ¶
func BytesCounterReaderWrap ¶
func BytesCounterReaderWrap(r io.Reader) io.ReadCloser
func CounterReset ¶
func CounterReset(wrapped interface{})
func CounterValue ¶
func CounterValue(wrapped interface{}) int
func FromTargetAction ¶
func LoggerWithCommonAttrs ¶
func RegisterMetrics ¶
func RegisterMetrics()
func ToTargetAction ¶
func WatchLabel ¶
func WrapRESTConfig ¶ added in v0.2.0
func WrapRESTConfig(cfg *rest.Config, wrapper http.RoundTripper)
WrapRESTConfig attaches a transport wrapper to the provided rest.Config. For proxy.RoundTripper it also wires the previous transport into Base.
Types ¶
type Handler ¶
type Handler struct {
Name string
// ProxyPass is a target http client to send requests to.
// An allusion to nginx proxy_pass directive.
TargetClient *http.Client
TargetURL *url.URL
ProxyMode ProxyMode
Rewriter *rewriter.RuleBasedRewriter
MetricsProvider MetricsProvider
// contains filtered or unexported fields
}
type MetricsProvider ¶
type MetricsProvider interface {
NewClientRequestsTotal(name, resource, method, watch, decision string) prometheus.Counter
NewTargetResponsesTotal(name, resource, method, watch, decision, status, error string) prometheus.Counter
NewTargetResponseInvalidJSONTotal(name, resource, method, watch, status string) prometheus.Counter
NewRequestsHandledTotal(name, resource, method, watch, decision, status, error string) prometheus.Counter
NewRequestsHandlingSeconds(name, resource, method, watch, decision, status string) prometheus.Observer
NewRewritesTotal(name, resource, method, watch, side, operation, error string) prometheus.Counter
NewRewritesDurationSeconds(name, resource, method, watch, side, operation string) prometheus.Observer
NewFromClientBytesTotal(name, resource, method, watch, decision string) prometheus.Counter
NewToTargetBytesTotal(name, resource, method, watch, decision string) prometheus.Counter
NewFromTargetBytesTotal(name, resource, method, watch, decision string) prometheus.Counter
NewToClientBytesTotal(name, resource, method, watch, decision string) prometheus.Counter
}
func NewMetricsProvider ¶
func NewMetricsProvider() MetricsProvider
func NoopMetricsProvider ¶
func NoopMetricsProvider() MetricsProvider
type ProxyMetrics ¶
type ProxyMetrics struct {
// contains filtered or unexported fields
}
func NewProxyMetrics ¶
func NewProxyMetrics(ctx context.Context, provider MetricsProvider) *ProxyMetrics
func (*ProxyMetrics) ClientRequestRewriteDuration ¶
func (p *ProxyMetrics) ClientRequestRewriteDuration(dur time.Duration)
func (*ProxyMetrics) ClientRequestRewriteError ¶
func (p *ProxyMetrics) ClientRequestRewriteError()
func (*ProxyMetrics) ClientRequestRewriteSuccess ¶
func (p *ProxyMetrics) ClientRequestRewriteSuccess()
func (*ProxyMetrics) FromClientBytesAdd ¶
func (p *ProxyMetrics) FromClientBytesAdd(decision string, count int)
func (*ProxyMetrics) FromTargetBytesAdd ¶
func (p *ProxyMetrics) FromTargetBytesAdd(count int)
func (*ProxyMetrics) GotClientRequest ¶
func (p *ProxyMetrics) GotClientRequest()
func (*ProxyMetrics) RequestDuration ¶
func (p *ProxyMetrics) RequestDuration(dur time.Duration)
func (*ProxyMetrics) RequestHandleError ¶
func (p *ProxyMetrics) RequestHandleError()
func (*ProxyMetrics) RequestHandleSuccess ¶
func (p *ProxyMetrics) RequestHandleSuccess()
func (*ProxyMetrics) TargetResponseError ¶
func (p *ProxyMetrics) TargetResponseError()
func (*ProxyMetrics) TargetResponseInvalidJSON ¶
func (p *ProxyMetrics) TargetResponseInvalidJSON(status int)
func (*ProxyMetrics) TargetResponseRewriteDuration ¶
func (p *ProxyMetrics) TargetResponseRewriteDuration(dur time.Duration)
func (*ProxyMetrics) TargetResponseRewriteError ¶
func (p *ProxyMetrics) TargetResponseRewriteError()
func (*ProxyMetrics) TargetResponseRewriteSuccess ¶
func (p *ProxyMetrics) TargetResponseRewriteSuccess()
func (*ProxyMetrics) TargetResponseSuccess ¶
func (p *ProxyMetrics) TargetResponseSuccess(decision string)
func (*ProxyMetrics) ToClientBytesAdd ¶
func (p *ProxyMetrics) ToClientBytesAdd(count int)
func (*ProxyMetrics) ToTargetBytesAdd ¶
func (p *ProxyMetrics) ToTargetBytesAdd(decision string, count int)
type ProxyMode ¶
type ProxyMode string
const ( // ToOriginal mode indicates that resource should be restored when passed to target and renamed when passing back to client. ToOriginal ProxyMode = "original" // ToRenamed mode indicates that resource should be renamed when passed to target and restored when passing back to client. ToRenamed ProxyMode = "renamed" )
type RoundTripper ¶ added in v0.2.0
type RoundTripper struct {
Name string
Base http.RoundTripper
ProxyMode ProxyMode
Rewriter *rewriter.RuleBasedRewriter
MetricsProvider MetricsProvider
// contains filtered or unexported fields
}
RoundTripper rewrites Kubernetes API requests and responses without an HTTP sidecar proxy. It is intended to wrap kubeclient transport in-process.
func NewProxyRoundTripper ¶ added in v0.2.0
func NewProxyRoundTripper(name string, mode ProxyMode, rules *rewriter.RewriteRules) *RoundTripper
type StreamHandler ¶
type StreamHandler struct {
Rewriter *rewriter.RuleBasedRewriter
MetricsProvider MetricsProvider
}
StreamHandler reads a stream from the target, transforms events and sends them to the client.
func (*StreamHandler) Handle ¶
func (s *StreamHandler) Handle(ctx context.Context, w http.ResponseWriter, resp *http.Response, targetReq *rewriter.TargetRequest) error
Handle starts a go routine to pass rewritten Watch Events from server to client. Sources: k8s.io/apimachinery@v0.26.1/pkg/watch/streamwatcher.go:100 receive method k8s.io/kubernetes@v1.13.0/staging/src/k8s.io/client-go/rest/request.go:537 wrapperFn, create framer. k8s.io/kubernetes@v1.13.0/staging/src/k8s.io/client-go/rest/request.go:598 instantiate watch NewDecoder