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 CapacityFromMachineInfo(info *cadvisorApi.MachineInfo) api.ResourceList
- func GetPhase(spec *api.PodSpec, info []api.ContainerStatus) api.PodPhase
- func GetValidatedSources(sources []string) ([]string, error)
- func ListenAndServeKubeletReadOnlyServer(host HostInterface, address net.IP, port uint)
- func ListenAndServeKubeletServer(host HostInterface, address net.IP, port uint, tlsOptions *TLSOptions, ...)
- type ContainerGCPolicy
- type DiskSpacePolicy
- 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, tail string, follow, previous bool, ...) 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) LatestLoopEntryTime() time.Time
- func (kl *Kubelet) ListenAndServe(address net.IP, port uint, tlsOptions *TLSOptions, ...)
- 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 PodUpdate)
- func (kl *Kubelet) RunInContainer(podFullName string, podUID types.UID, containerName string, cmd []string) ([]byte, error)
- func (kl *Kubelet) RunOnce(updates <-chan PodUpdate) ([]RunPodResult, error)
- func (kl *Kubelet) ServeLogs(w http.ResponseWriter, req *http.Request)
- func (kl *Kubelet) StartGarbageCollection()
- func (kl *Kubelet) StreamingConnectionIdleTimeout() time.Duration
- func (kl *Kubelet) SyncPods(allPods []*api.Pod, podSyncTypes map[types.UID]SyncPodType, ...) error
- type OOMWatcher
- type PodOperation
- type PodUpdate
- type PodWorkers
- type RunPodResult
- type Server
- type SourcesReadyFn
- type StatsRequest
- type SyncHandler
- type SyncPodType
- type TLSOptions
- type TestingInterface
Constants ¶
const ( // The percent of the machine memory capacity. The value is used to calculate // docker memory resource container's hardlimit to workaround docker memory // leakage issue. Please see kubernetes/issues/9881 for more detail. DockerMemoryLimitThresholdPercent = 70 // The minimum memory limit allocated to docker container: 150Mi MinDockerMemoryLimit = 150 * 1024 * 1024 )
const ( RunOnceManifestDelay = 1 * time.Second RunOnceMaxRetries = 10 RunOnceRetryDelay = 1 * time.Second RunOnceRetryDelayBackoff = 2 )
const ( // This is the current pod configuration SET PodOperation = iota // Pods with the given ids are new to this source ADD // Pods with the given ids have been removed from this source REMOVE // Pods with the given ids have been updated in this source UPDATE // These constants identify the sources of pods // Updates from a file FileSource = "file" // Updates from querying a web page HTTPSource = "http" // Updates from Kubernetes API Server ApiserverSource = "api" // Updates from all sources AllSource = "*" // Used for ConfigMirrorAnnotationKey. MirrorType = "mirror" NamespaceDefault = api.NamespaceDefault )
const ConfigFirstSeenAnnotationKey = "kubernetes.io/config.seen"
const ConfigMirrorAnnotationKey = "kubernetes.io/config.mirror"
const ConfigSourceAnnotationKey = "kubernetes.io/config.source"
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 CapacityFromMachineInfo ¶
func CapacityFromMachineInfo(info *cadvisorApi.MachineInfo) api.ResourceList
func GetPhase ¶
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 GetValidatedSources ¶
Gets all validated sources from the specified sources.
func ListenAndServeKubeletReadOnlyServer ¶
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, enableDebuggingHandlers bool)
ListenAndServeKubeletServer initializes a server to respond to HTTP network requests on the Kubelet.
Types ¶
type ContainerGCPolicy ¶
type ContainerGCPolicy struct { // Minimum age at which a container can be garbage collected, zero for no limit. MinAge time.Duration // Max number of dead containers any single pod (UID, container name) pair is // allowed to have, less than zero for no limit. MaxPerPodContainer int // Max number of total dead containers, less than zero for no limit. MaxContainers int }
Specified a policy for garbage collecting containers.
type DiskSpacePolicy ¶
type HostInterface ¶
type HostInterface interface { GetContainerInfo(podFullName string, uid types.UID, containerName string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error) GetContainerRuntimeVersion() (kubecontainer.Version, 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, tail string, follow, previous bool, 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 ¶
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, containerGCPolicy ContainerGCPolicy, sourcesReady SourcesReadyFn, registerNode 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, nodeStatusUpdateFrequency time.Duration, resourceContainer string, osInterface kubecontainer.OSInterface, cgroupRoot string, containerRuntime string, mounter mount.Interface, dockerDaemonContainer string, systemContainer string, configureCBR0 bool, podCIDR string, pods int, dockerExecHandler dockertools.ExecHandler) (*Kubelet, error)
New creates a new Kubelet for use in main
func (*Kubelet) AttachContainer ¶
func (*Kubelet) BirthCry ¶
func (kl *Kubelet) BirthCry()
BirthCry sends an event that the kubelet has started up.
func (*Kubelet) ExecInContainer ¶
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 ¶
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 ¶
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 ¶
func (kl *Kubelet) GetContainerRuntimeVersion() (kubecontainer.Version, error)
Returns the container runtime version for this Kubelet.
func (*Kubelet) GetHostname ¶
GetHostname Returns the hostname as the kubelet sees it.
func (*Kubelet) GetKubeletContainerLogs ¶
func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail string, follow, previous bool, 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 ¶
func (*Kubelet) GetPodByName ¶
GetPodByName provides the first pod that matches namespace and name, as well as whether the pod was found.
func (*Kubelet) GetPods ¶
GetPods returns all pods bound to the kubelet and their spec, and the mirror pods.
func (*Kubelet) GetRawContainerInfo ¶
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 ¶
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 ¶
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) LatestLoopEntryTime ¶
func (*Kubelet) ListenAndServe ¶
func (*Kubelet) ListenAndServeReadOnly ¶
func (*Kubelet) PortForward ¶
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 ¶
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 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 ¶
func (kl *Kubelet) StartGarbageCollection()
Starts garbage collection threads.
func (*Kubelet) StreamingConnectionIdleTimeout ¶
type OOMWatcher ¶
type OOMWatcher interface {
Start(ref *api.ObjectReference) error
}
func NewOOMWatcher ¶
func NewOOMWatcher(cadvisor cadvisor.Interface, recorder record.EventRecorder) OOMWatcher
type PodOperation ¶
type PodOperation int
PodOperation defines what changes will be made on a pod configuration.
type PodUpdate ¶
type PodUpdate struct { Pods []*api.Pod Op PodOperation Source string }
PodUpdate defines an operation sent on the channel. You can add or remove single services by sending an array of size one and Op == ADD|REMOVE (with REMOVE, only the ID is required). For setting the state of the system to a given state for this source configuration, set Pods as desired and Op to SET, which will reset the system state to that specified in this operation for this source channel. To remove all pods, set Pods to empty object and Op to SET.
Additionally, Pods should never be nil - it should always point to an empty slice. While functionally similar, this helps our unit tests properly check that the correct PodUpdates are generated.
type PodWorkers ¶
type PodWorkers interface { UpdatePod(pod *api.Pod, mirrorPod *api.Pod, updateComplete func()) ForgetNonExistingPodWorkers(desiredPods map[types.UID]empty) }
PodWorkers is an abstract interface for testability.
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, enableDebuggingHandlers bool) Server
NewServer initializes and configures a kubelet.Server object to handle HTTP requests.
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 mux.
type SourcesReadyFn ¶
type SourcesReadyFn func() bool
type StatsRequest ¶
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 { // Syncs current state to match the specified pods. SyncPodType specified what // type of sync is occurring per pod. StartTime specifies the time at which // syncing began (for use in monitoring). SyncPods(pods []*api.Pod, podSyncTypes map[types.UID]SyncPodType, mirrorPods map[string]*api.Pod, startTime time.Time) error }
SyncHandler is an interface implemented by Kubelet, for testability
type SyncPodType ¶
type SyncPodType int
SyncPodType classifies pod updates, eg: create, update.
const ( SyncPodSync SyncPodType = iota SyncPodUpdate SyncPodCreate )
func (SyncPodType) String ¶
func (sp SyncPodType) String() string
type TestingInterface ¶
type TestingInterface interface {
Errorf(format string, args ...interface{})
}
Source Files ¶
- container_bridge.go
- container_gc.go
- container_manager.go
- container_manager_linux.go
- disk_manager.go
- doc.go
- fake_pod_workers.go
- image_manager.go
- kubelet.go
- mirror_client.go
- networks.go
- oom_watcher.go
- pod_manager.go
- pod_workers.go
- root_context_linux.go
- runonce.go
- runtime_hooks.go
- server.go
- status_manager.go
- types.go
- util.go
- volume_manager.go
- volumes.go
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:
|
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: |
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. |