api

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package api implements HTTP handlers for handling requests that the kubelet would normally implement, such as pod logs, exec, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachPodMetricsRoutes

func AttachPodMetricsRoutes(p PodMetricsConfig, mux ServeMux)

AttachPodMetricsRoutes adds the http routes for pod/node metrics to the passed in serve mux.

Callers should take care to namespace the serve mux as they see fit, however these routes get called by the Kubernetes API server.

func AttachPodRoutes

func AttachPodRoutes(p PodHandlerConfig, mux ServeMux, debug bool)

AttachPodRoutes adds the http routes for pod stuff to the passed in serve mux.

Callers should take care to namespace the serve mux as they see fit, however these routes get called by the Kubernetes API server.

func HandleContainerExec

func HandleContainerExec(h ContainerExecHandlerFunc) http.HandlerFunc

HandleContainerExec makes an http handler func from a Provider which execs a command in a pod's container Note that this handler currently depends on gorrilla/mux to get url parts as variables. TODO(@cpuguy83): don't force gorilla/mux on consumers of this function

func HandleContainerLogs

func HandleContainerLogs(h ContainerLogsHandlerFunc) http.HandlerFunc

HandleContainerLogs creates an http handler function from a provider to serve logs from a pod

func HandlePodStatsSummary

func HandlePodStatsSummary(h PodStatsSummaryHandlerFunc) http.HandlerFunc

HandlePodStatsSummary makes an HTTP handler for implementing the kubelet summary stats endpoint

func HandleRunningPods

func HandleRunningPods(getPods PodListerFunc) http.HandlerFunc

func InstrumentHandler

func InstrumentHandler(h http.Handler) http.Handler

InstrumentHandler wraps an http.Handler and injects instrumentation into the request context.

func NotFound

func NotFound(w http.ResponseWriter, r *http.Request)

NotFound provides a handler for cases where the requested endpoint doesn't exist

func NotImplemented

func NotImplemented(w http.ResponseWriter, r *http.Request)

NotImplemented provides a handler for cases where a provider does not implement a given API

func PodHandler

func PodHandler(p PodHandlerConfig, debug bool) http.Handler

PodHandler creates an http handler for interacting with pods/containers.

func PodStatsSummaryHandler

func PodStatsSummaryHandler(f PodStatsSummaryHandlerFunc) http.Handler

PodStatsSummaryHandler creates an http handler for serving pod metrics.

If the passed in handler func is nil this will create handlers which only

serves http.StatusNotImplemented

Types

type AttachIO

type AttachIO interface {
	Stdin() io.Reader
	Stdout() io.WriteCloser
	Stderr() io.WriteCloser
	TTY() bool
	Resize() <-chan TermSize
}

AttachIO is used to pass in streams to attach to a container process

type ContainerExecHandlerFunc

type ContainerExecHandlerFunc func(ctx context.Context, namespace, podName, containerName string, cmd []string, attach AttachIO) error

ContainerExecHandlerFunc defines the handler function used for "execing" into a container in a pod.

type ContainerLogOpts

type ContainerLogOpts struct {
	Tail       int
	Since      time.Duration
	LimitBytes int
	Timestamps bool
}

ContainerLogOpts are used to pass along options to be set on the container log stream.

type ContainerLogsHandlerFunc

type ContainerLogsHandlerFunc func(ctx context.Context, namespace, podName, containerName string, opts ContainerLogOpts) (io.ReadCloser, error)

ContainerLogsHandlerFunc is used in place of backend implementations for getting container logs

type PodHandlerConfig

type PodHandlerConfig struct {
	RunInContainer   ContainerExecHandlerFunc
	GetContainerLogs ContainerLogsHandlerFunc
	GetPods          PodListerFunc
}

type PodListerFunc

type PodListerFunc func(context.Context) ([]*v1.Pod, error)

type PodMetricsConfig

type PodMetricsConfig struct {
	GetStatsSummary PodStatsSummaryHandlerFunc
}

PodMetricsConfig stores the handlers for pod metrics routes It is used by AttachPodMetrics.

The main reason for this struct is in case of expansion we do not need to break the package level API.

type PodStatsSummaryHandlerFunc

type PodStatsSummaryHandlerFunc func(context.Context) (*stats.Summary, error)

PodStatsSummaryHandlerFunc defines the handler for getting pod stats summaries

type ServeMux

type ServeMux interface {
	Handle(path string, h http.Handler)
}

ServeMux defines an interface used to attach routes to an existing http serve mux. It is used to enable callers creating a new server to completely manage their own HTTP server while allowing us to attach the required routes to satisfy the Kubelet HTTP interfaces.

type TermSize

type TermSize struct {
	Width  uint16
	Height uint16
}

TermSize is used to set the terminal size from attached clients.

Jump to

Keyboard shortcuts

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