Documentation ¶
Overview ¶
Package kubelet is the package that contains the libraries that drive the Kubelet binary. The kubelet is responsible for node level pod management. It runs on each worker in the cluster.
Index ¶
- Constants
- Variables
- func GetPhase(spec *api.PodSpec, info []api.ContainerStatus) api.PodPhase
- func ListenAndServeKubeletReadOnlyServer(host HostInterface, address net.IP, port uint)
- func ListenAndServeKubeletServer(host HostInterface, address net.IP, port uint, tlsOptions *TLSOptions, ...)
- func ServePortForward(w http.ResponseWriter, req *http.Request, portForwarder PortForwarder, ...)
- type AuthInterface
- type Closer
- type DiskSpacePolicy
- type FlannelHelper
- type HostInterface
- type ImageGCPolicy
- type Kubelet
- func (kl *Kubelet) AttachContainer(podFullName string, podUID types.UID, containerName string, stdin io.Reader, ...) error
- func (kl *Kubelet) BirthCry()
- func (kl *Kubelet) ExecInContainer(podFullName string, podUID types.UID, containerName string, cmd []string, ...) error
- func (kl *Kubelet) GenerateRunContainerOptions(pod *api.Pod, container *api.Container) (*kubecontainer.RunContainerOptions, error)
- func (kl *Kubelet) GetCachedMachineInfo() (*cadvisorapi.MachineInfo, error)
- func (kl *Kubelet) GetContainerInfo(podFullName string, podUID types.UID, containerName string, ...) (*cadvisorapi.ContainerInfo, error)
- func (kl *Kubelet) GetContainerRuntimeVersion() (kubecontainer.Version, error)
- func (kl *Kubelet) GetHostIP() (net.IP, error)
- func (kl *Kubelet) GetHostname() string
- func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName string, logOptions *api.PodLogOptions, ...) error
- func (kl *Kubelet) GetNode() (*api.Node, error)
- func (kl *Kubelet) GetPodByFullName(podFullName string) (*api.Pod, bool)
- func (kl *Kubelet) GetPodByName(namespace, name string) (*api.Pod, bool)
- func (kl *Kubelet) GetPods() []*api.Pod
- func (kl *Kubelet) GetRawContainerInfo(containerName string, req *cadvisorapi.ContainerInfoRequest, ...) (map[string]*cadvisorapi.ContainerInfo, error)
- func (kl *Kubelet) GetRunningPods() ([]*api.Pod, error)
- func (kl *Kubelet) GetRuntime() kubecontainer.Runtime
- func (kl *Kubelet) HandlePodAdditions(pods []*api.Pod)
- func (kl *Kubelet) HandlePodCleanups() error
- func (kl *Kubelet) HandlePodDeletions(pods []*api.Pod)
- func (kl *Kubelet) HandlePodSyncs(pods []*api.Pod)
- func (kl *Kubelet) HandlePodUpdates(pods []*api.Pod)
- func (kl *Kubelet) LatestLoopEntryTime() time.Time
- func (kl *Kubelet) ListenAndServe(address net.IP, port uint, tlsOptions *TLSOptions, auth AuthInterface, ...)
- func (kl *Kubelet) ListenAndServeReadOnly(address net.IP, port uint)
- func (kl *Kubelet) PortForward(podFullName string, podUID types.UID, port uint16, stream io.ReadWriteCloser) error
- func (kl *Kubelet) ResyncInterval() time.Duration
- func (kl *Kubelet) Run(updates <-chan kubetypes.PodUpdate)
- func (kl *Kubelet) RunInContainer(podFullName string, podUID types.UID, containerName string, cmd []string) ([]byte, error)
- func (kl *Kubelet) RunOnce(updates <-chan kubetypes.PodUpdate) ([]RunPodResult, error)
- func (kl *Kubelet) ServeLogs(w http.ResponseWriter, req *http.Request)
- func (kl *Kubelet) StartGarbageCollection()
- func (kl *Kubelet) StreamingConnectionIdleTimeout() time.Duration
- type KubeletAuth
- type OOMWatcher
- type PodWorkers
- type PortForwarder
- type RunPodResult
- type Server
- type SourcesReadyFn
- type StatsRequest
- type SyncHandler
- type TLSOptions
- type TestingInterface
Constants ¶
const ( // max backoff period, exported for the e2e test MaxContainerBackOff = 300 * time.Second // system default DNS resolver configuration ResolvConfDefault = "/etc/resolv.conf" )
Variables ¶
var ( // ErrContainerNotFound returned when a container in the given pod with the // given container name was not found, amongst those managed by the kubelet. ErrContainerNotFound = errors.New("no matching container") )
Functions ¶
func GetPhase ¶ added in v0.20.0
GetPhase returns the phase of a pod given its container info. This func is exported to simplify integration with 3rd party kubelet integrations like kubernetes-mesos.
func ListenAndServeKubeletReadOnlyServer ¶ added in v0.15.0
func ListenAndServeKubeletReadOnlyServer(host HostInterface, address net.IP, port uint)
ListenAndServeKubeletReadOnlyServer initializes a server to respond to HTTP network requests on the Kubelet.
func ListenAndServeKubeletServer ¶
func ListenAndServeKubeletServer(host HostInterface, address net.IP, port uint, tlsOptions *TLSOptions, auth AuthInterface, enableDebuggingHandlers bool)
ListenAndServeKubeletServer initializes a server to respond to HTTP network requests on the Kubelet.
func ServePortForward ¶ added in v1.1.1
func ServePortForward(w http.ResponseWriter, req *http.Request, portForwarder PortForwarder, podName string, uid types.UID, idleTimeout time.Duration, streamCreationTimeout time.Duration)
ServePortForward handles a port forwarding request. A single request is kept alive as long as the client is still alive and the connection has not been timed out due to idleness. This function handles multiple forwarded connections; i.e., multiple `curl http://localhost:8888/` requests will be handled by a single invocation of ServePortForward.
Types ¶
type AuthInterface ¶
type AuthInterface interface { authenticator.Request authorizer.RequestAttributesGetter authorizer.Authorizer }
AuthInterface contains all methods required by the auth filters
func NewKubeletAuth ¶
func NewKubeletAuth(authenticator authenticator.Request, authorizerAttributeGetter authorizer.RequestAttributesGetter, authorizer authorizer.Authorizer) AuthInterface
NewKubeletAuth returns a kubelet.AuthInterface composed of the given authenticator, attribute getter, and authorizer
type DiskSpacePolicy ¶ added in v0.18.0
type FlannelHelper ¶
type FlannelHelper struct {
// contains filtered or unexported fields
}
A Kubelet to flannel bridging helper.
func NewFlannelHelper ¶
func NewFlannelHelper() *FlannelHelper
NewFlannelHelper creates a new flannel helper.
func (*FlannelHelper) Handshake ¶
func (f *FlannelHelper) Handshake() (podCIDR string, err error)
Handshake waits for the flannel subnet file and installs a few IPTables rules, returning the pod CIDR allocated for this node.
type HostInterface ¶
type HostInterface interface { GetContainerInfo(podFullName string, uid types.UID, containerName string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) GetRawContainerInfo(containerName string, req *cadvisorapi.ContainerInfoRequest, subcontainers bool) (map[string]*cadvisorapi.ContainerInfo, error) GetCachedMachineInfo() (*cadvisorapi.MachineInfo, error) GetPods() []*api.Pod GetRunningPods() ([]*api.Pod, error) GetPodByName(namespace, name string) (*api.Pod, bool) RunInContainer(name string, uid types.UID, container string, cmd []string) ([]byte, error) ExecInContainer(name string, uid types.UID, container string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool) error AttachContainer(name string, uid types.UID, container string, in io.Reader, out, err io.WriteCloser, tty bool) error GetKubeletContainerLogs(podFullName, containerName string, logOptions *api.PodLogOptions, stdout, stderr io.Writer) error ServeLogs(w http.ResponseWriter, req *http.Request) PortForward(name string, uid types.UID, port uint16, stream io.ReadWriteCloser) error StreamingConnectionIdleTimeout() time.Duration ResyncInterval() time.Duration GetHostname() string LatestLoopEntryTime() time.Time }
HostInterface contains all the kubelet methods required by the server. For testablitiy.
type ImageGCPolicy ¶ added in v0.14.0
type ImageGCPolicy struct { // Any usage above this threshold will always trigger garbage collection. // This is the highest usage we will allow. HighThresholdPercent int // Any usage below this threshold will never trigger garbage collection. // This is the lowest threshold we will try to garbage collect to. LowThresholdPercent int }
A policy for garbage collecting images. Policy defines an allowed band in which garbage collection will be run.
type Kubelet ¶
type Kubelet struct {
// contains filtered or unexported fields
}
Kubelet is the main kubelet implementation.
func NewMainKubelet ¶
func NewMainKubelet( hostname string, nodeName string, dockerClient dockertools.DockerInterface, kubeClient client.Interface, rootDirectory string, podInfraContainerImage string, resyncInterval time.Duration, pullQPS float32, pullBurst int, eventQPS float32, eventBurst int, containerGCPolicy kubecontainer.ContainerGCPolicy, sourcesReady SourcesReadyFn, registerNode bool, registerSchedulable bool, standaloneMode bool, clusterDomain string, clusterDNS net.IP, masterServiceNamespace string, volumePlugins []volume.VolumePlugin, networkPlugins []network.NetworkPlugin, networkPluginName string, streamingConnectionIdleTimeout time.Duration, recorder record.EventRecorder, cadvisorInterface cadvisor.Interface, imageGCPolicy ImageGCPolicy, diskSpacePolicy DiskSpacePolicy, cloud cloudprovider.Interface, nodeLabels []string, nodeLabelsFile string, nodeStatusUpdateFrequency time.Duration, resourceContainer string, osInterface kubecontainer.OSInterface, cgroupRoot string, containerRuntime string, rktPath string, rktStage1Image string, mounter mount.Interface, writer kubeio.Writer, chownRunner chown.Interface, chmodRunner chmod.Interface, dockerDaemonContainer string, systemContainer string, configureCBR0 bool, podCIDR string, reconcileCIDR bool, maxPods int, dockerExecHandler dockertools.ExecHandler, resolverConfig string, cpuCFSQuota bool, daemonEndpoints *api.NodeDaemonEndpoints, oomAdjuster *oom.OOMAdjuster, serializeImagePulls bool, containerManager cm.ContainerManager, flannelExperimentalOverlay bool, ) (*Kubelet, error)
New instantiates a new Kubelet object along with all the required internal modules. No initialization of Kubelet and its modules should happen here.
func (*Kubelet) AttachContainer ¶ added in v1.1.0
func (*Kubelet) BirthCry ¶ added in v0.5.1
func (kl *Kubelet) BirthCry()
BirthCry sends an event that the kubelet has started up.
func (*Kubelet) ExecInContainer ¶ added in v0.12.0
func (kl *Kubelet) ExecInContainer(podFullName string, podUID types.UID, containerName string, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool) error
ExecInContainer executes a command in a container, connecting the supplied stdin/stdout/stderr to the command's IO streams.
func (*Kubelet) GenerateRunContainerOptions ¶ added in v0.16.0
func (kl *Kubelet) GenerateRunContainerOptions(pod *api.Pod, container *api.Container) (*kubecontainer.RunContainerOptions, error)
GenerateRunContainerOptions generates the RunContainerOptions, which can be used by the container runtime to set parameters for launching a container.
func (*Kubelet) GetCachedMachineInfo ¶ added in v0.14.0
func (kl *Kubelet) GetCachedMachineInfo() (*cadvisorapi.MachineInfo, error)
GetCachedMachineInfo assumes that the machine info can't change without a reboot
func (*Kubelet) GetContainerInfo ¶
func (kl *Kubelet) GetContainerInfo(podFullName string, podUID types.UID, containerName string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error)
GetContainerInfo returns stats (from Cadvisor) for a container.
func (*Kubelet) GetContainerRuntimeVersion ¶ added in v0.16.0
func (kl *Kubelet) GetContainerRuntimeVersion() (kubecontainer.Version, error)
Returns the container runtime version for this Kubelet.
func (*Kubelet) GetHostname ¶ added in v0.12.0
GetHostname Returns the hostname as the kubelet sees it.
func (*Kubelet) GetKubeletContainerLogs ¶
func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName string, logOptions *api.PodLogOptions, stdout, stderr io.Writer) error
GetKubeletContainerLogs returns logs from the container TODO: this method is returning logs of random container attempts, when it should be returning the most recent attempt or all of them.
func (*Kubelet) GetPodByFullName ¶ added in v0.12.0
func (*Kubelet) GetPodByName ¶ added in v0.9.0
GetPodByName provides the first pod that matches namespace and name, as well as whether the pod was found.
func (*Kubelet) GetPods ¶ added in v0.13.1
GetPods returns all pods bound to the kubelet and their spec, and the mirror pods.
func (*Kubelet) GetRawContainerInfo ¶ added in v0.16.0
func (kl *Kubelet) GetRawContainerInfo(containerName string, req *cadvisorapi.ContainerInfoRequest, subcontainers bool) (map[string]*cadvisorapi.ContainerInfo, error)
Returns stats (from Cadvisor) for a non-Kubernetes container.
func (*Kubelet) GetRunningPods ¶ added in v0.21.0
GetRunningPods returns all pods running on kubelet from looking at the container runtime cache. This function converts kubecontainer.Pod to api.Pod, so only the fields that exist in both kubecontainer.Pod and api.Pod are considered meaningful.
func (*Kubelet) GetRuntime ¶ added in v0.19.0
func (kl *Kubelet) GetRuntime() kubecontainer.Runtime
GetRuntime returns the current Runtime implementation in use by the kubelet. This func is exported to simplify integration with third party kubelet extensions (e.g. kubernetes-mesos).
func (*Kubelet) HandlePodAdditions ¶ added in v1.1.0
func (*Kubelet) HandlePodCleanups ¶ added in v1.1.0
HandlePodCleanups performs a series of cleanup work, including terminating pod workers, killing unwanted pods, and removing orphaned volumes/pod directories. TODO(yujuhong): This function is executed by the main sync loop, so it should not contain any blocking calls. Re-examine the function and decide whether or not we should move it into a separte goroutine.
func (*Kubelet) HandlePodDeletions ¶ added in v1.1.0
func (*Kubelet) HandlePodSyncs ¶ added in v1.1.0
func (*Kubelet) HandlePodUpdates ¶ added in v1.1.0
func (*Kubelet) LatestLoopEntryTime ¶ added in v0.20.0
func (*Kubelet) ListenAndServe ¶ added in v0.15.0
func (kl *Kubelet) ListenAndServe(address net.IP, port uint, tlsOptions *TLSOptions, auth AuthInterface, enableDebuggingHandlers bool)
func (*Kubelet) ListenAndServeReadOnly ¶ added in v0.15.0
func (*Kubelet) PortForward ¶ added in v0.12.0
func (kl *Kubelet) PortForward(podFullName string, podUID types.UID, port uint16, stream io.ReadWriteCloser) error
PortForward connects to the pod's port and copies data between the port and the stream.
func (*Kubelet) ResyncInterval ¶ added in v0.20.0
func (*Kubelet) RunInContainer ¶
func (kl *Kubelet) RunInContainer(podFullName string, podUID types.UID, containerName string, cmd []string) ([]byte, error)
Run a command in a container, returns the combined stdout, stderr as an array of bytes
func (*Kubelet) RunOnce ¶
func (kl *Kubelet) RunOnce(updates <-chan kubetypes.PodUpdate) ([]RunPodResult, error)
RunOnce polls from one configuration update and run the associated pods.
func (*Kubelet) ServeLogs ¶
func (kl *Kubelet) ServeLogs(w http.ResponseWriter, req *http.Request)
Returns logs of current machine.
func (*Kubelet) StartGarbageCollection ¶ added in v0.14.0
func (kl *Kubelet) StartGarbageCollection()
Starts garbage collection threads.
func (*Kubelet) StreamingConnectionIdleTimeout ¶ added in v0.12.0
type KubeletAuth ¶
type KubeletAuth struct { // authenticator identifies the user for requests to the Kubelet API authenticator.Request // authorizerAttributeGetter builds authorization.Attributes for a request to the Kubelet API authorizer.RequestAttributesGetter // authorizer determines whether a given authorization.Attributes is allowed authorizer.Authorizer }
KubeletAuth implements AuthInterface
type OOMWatcher ¶ added in v0.17.0
type OOMWatcher interface {
Start(ref *api.ObjectReference) error
}
func NewOOMWatcher ¶ added in v0.17.0
func NewOOMWatcher(cadvisor cadvisor.Interface, recorder record.EventRecorder) OOMWatcher
type PodWorkers ¶ added in v0.17.0
type PodWorkers interface { UpdatePod(pod *api.Pod, mirrorPod *api.Pod, updateType kubetypes.SyncPodType, updateComplete func()) ForgetNonExistingPodWorkers(desiredPods map[types.UID]empty) ForgetWorker(uid types.UID) }
PodWorkers is an abstract interface for testability.
type PortForwarder ¶ added in v1.1.1
type PortForwarder interface { // PortForwarder copies data between a data stream and a port in a pod. PortForward(name string, uid types.UID, port uint16, stream io.ReadWriteCloser) error }
PortForwarder knows how to forward content from a data stream to/from a port in a pod.
type RunPodResult ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a http.Handler which exposes kubelet functionality over HTTP.
func NewServer ¶
func NewServer(host HostInterface, auth AuthInterface, enableDebuggingHandlers bool) Server
NewServer initializes and configures a kubelet.Server object to handle HTTP requests.
func (*Server) InstallAuthFilter ¶
func (s *Server) InstallAuthFilter()
InstallAuthFilter installs authentication filters with the restful Container.
func (*Server) InstallDebuggingHandlers ¶
func (s *Server) InstallDebuggingHandlers()
InstallDeguggingHandlers registers the HTTP request patterns that serve logs or run commands/containers
func (*Server) InstallDefaultHandlers ¶
func (s *Server) InstallDefaultHandlers()
InstallDefaultHandlers registers the default set of supported HTTP request patterns with the restful Container.
type SourcesReadyFn ¶ added in v0.8.0
type StatsRequest ¶ added in v0.16.0
type StatsRequest struct { // The name of the container for which to request stats. // Default: / ContainerName string `json:"containerName,omitempty"` // Max number of stats to return. // If start and end time are specified this limit is ignored. // Default: 60 NumStats int `json:"num_stats,omitempty"` // Start time for which to query information. // If omitted, the beginning of time is assumed. Start time.Time `json:"start,omitempty"` // End time for which to query information. // If omitted, current time is assumed. End time.Time `json:"end,omitempty"` // Whether to also include information from subcontainers. // Default: false. Subcontainers bool `json:"subcontainers,omitempty"` }
type SyncHandler ¶
type SyncHandler interface { HandlePodAdditions(pods []*api.Pod) HandlePodUpdates(pods []*api.Pod) HandlePodDeletions(pods []*api.Pod) HandlePodSyncs(pods []*api.Pod) HandlePodCleanups() error }
SyncHandler is an interface implemented by Kubelet, for testability
type TLSOptions ¶ added in v0.13.0
type TestingInterface ¶ added in v0.20.0
type TestingInterface interface {
Errorf(format string, args ...interface{})
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Kubelet interactions with cAdvisor.
|
Kubelet interactions with cAdvisor. |
Reads the pod configuration from the Kubernetes apiserver.
|
Reads the pod configuration from the Kubernetes apiserver. |
Package envvars is the package that build the environment variables that kubernetes provides to the containers run by it.
|
Package envvars is the package that build the environment variables that kubernetes provides to the containers run by it. |
Package leaky holds bits of kubelet that should be internal but have leaked out through bad abstractions.
|
Package leaky holds bits of kubelet that should be internal but have leaked out through bad abstractions. |
Handlers for pod lifecycle events.
|
Handlers for pod lifecycle events. |
exec
Package exec scans and loads networking plugins that are installed under /usr/libexec/kubernetes/kubelet-plugins/net/exec/ The layout convention for a plugin is: plugin-name/ (plugins have to be directories first) plugin-name/plugin-name (executable that will be called out, see Vendoring Note for more nuances) plugin-name/<other-files> where, 'executable' has the following requirements: - should have exec permissions - should give non-zero exit code on failure, and zero on success - the arguments will be <action> <pod_namespace> <pod_name> <docker_id_of_infra_container> whereupon, <action> will be one of: - init, called when the kubelet loads the plugin - setup, called after the infra container of a pod is created, but before other containers of the pod are created - teardown, called before the pod infra container is killed - status, called at regular intervals and is supposed to return a json formatted output indicating the pod's IPAddress(v4/v6).
|
Package exec scans and loads networking plugins that are installed under /usr/libexec/kubernetes/kubelet-plugins/net/exec/ The layout convention for a plugin is: plugin-name/ (plugins have to be directories first) plugin-name/plugin-name (executable that will be called out, see Vendoring Note for more nuances) plugin-name/<other-files> where, 'executable' has the following requirements: - should have exec permissions - should give non-zero exit code on failure, and zero on success - the arguments will be <action> <pod_namespace> <pod_name> <docker_id_of_infra_container> whereupon, <action> will be one of: - init, called when the kubelet loads the plugin - setup, called after the infra container of a pod is created, but before other containers of the pod are created - teardown, called before the pod infra container is killed - status, called at regular intervals and is supposed to return a json formatted output indicating the pod's IPAddress(v4/v6). |
Package pleg contains types and a generic implementation of the pod lifecycle event generator.
|
Package pleg contains types and a generic implementation of the pod lifecycle event generator. |
package portforward contains server-side logic for handling port forwarding requests.
|
package portforward contains server-side logic for handling port forwarding requests. |
package qos contains helper functions for quality of service.
|
package qos contains helper functions for quality of service. |
Package rkt contains the Containerruntime interface implementation for rkt.
|
Package rkt contains the Containerruntime interface implementation for rkt. |
Common types in the Kubelet.
|
Common types in the Kubelet. |
Utility functions.
|
Utility functions. |