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
- func GetPhase(spec *api.PodSpec, info []api.ContainerStatus) api.PodPhase
- type DiskSpacePolicy
- type FlannelHelper
- type ImageGCPolicy
- type KillPodOptions
- 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) GeneratePodHostNameAndDomain(pod *api.Pod) (string, string, error)
- func (kl *Kubelet) GenerateRunContainerOptions(pod *api.Pod, container *api.Container, podIP string) (*kubecontainer.RunContainerOptions, error)
- func (kl *Kubelet) GetCachedMachineInfo() (*cadvisorapi.MachineInfo, error)
- func (kl *Kubelet) GetClusterDNS(pod *api.Pod) ([]string, []string, error)
- func (kl *Kubelet) GetContainerInfo(podFullName string, podUID types.UID, containerName string, ...) (*cadvisorapi.ContainerInfo, error)
- func (kl *Kubelet) GetContainerInfoV2(name string, options cadvisorapiv2.RequestOptions) (map[string]cadvisorapiv2.ContainerInfo, 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) GetNodeConfig() cm.NodeConfig
- func (kl *Kubelet) GetPodByFullName(podFullName string) (*api.Pod, bool)
- func (kl *Kubelet) GetPodByName(namespace, name string) (*api.Pod, bool)
- func (kl *Kubelet) GetPodDir(podUID types.UID) string
- 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) HandlePodReconcile(pods []*api.Pod)
- func (kl *Kubelet) HandlePodSyncs(pods []*api.Pod)
- func (kl *Kubelet) HandlePodUpdates(pods []*api.Pod)
- func (kl *Kubelet) ImagesFsInfo() (cadvisorapiv2.FsInfo, error)
- func (kl *Kubelet) LatestLoopEntryTime() time.Time
- func (kl *Kubelet) ListVolumesForPod(podUID types.UID) (map[string]volume.Volume, bool)
- func (kl *Kubelet) ListenAndServe(address net.IP, port uint, tlsOptions *server.TLSOptions, ...)
- func (kl *Kubelet) ListenAndServeReadOnly(address net.IP, port uint)
- func (kl *Kubelet) PLEGHealthCheck() (bool, error)
- func (kl *Kubelet) PortForward(podFullName string, podUID types.UID, port uint16, stream io.ReadWriteCloser) error
- func (kl *Kubelet) ResyncInterval() time.Duration
- func (kl *Kubelet) RootFsInfo() (cadvisorapiv2.FsInfo, error)
- 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 OOMWatcher
- type OnCompleteFunc
- type Option
- type PodStatusFunc
- type PodWorkers
- type ReasonCache
- type RunPodResult
- type SyncHandler
- type UpdatePodOptions
Constants ¶
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DiskSpacePolicy ¶
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 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 // Minimum age at which a image can be garbage collected. MinAge time.Duration }
A policy for garbage collecting images. Policy defines an allowed band in which garbage collection will be run.
type KillPodOptions ¶ added in v1.1.0
type KillPodOptions struct { // PodStatusFunc is the function to invoke to set pod status in response to a kill request. PodStatusFunc PodStatusFunc // PodTerminationGracePeriodSecondsOverride is optional override to use if a pod is being killed as part of kill operation. PodTerminationGracePeriodSecondsOverride *int64 }
KillPodOptions are options when performing a pod update whose update type is kill.
type Kubelet ¶
type Kubelet struct { // TODO: think about moving this to be centralized in PodWorkers in follow-on. // the list of handlers to call during pod admission. lifecycle.PodAdmitHandlers // the list of handlers to call during pod sync loop. lifecycle.PodSyncLoopHandlers // the list of handlers to call during pod sync. lifecycle.PodSyncHandlers // contains filtered or unexported fields }
Kubelet is the main kubelet implementation.
func NewMainKubelet ¶
func NewMainKubelet( hostname string, nodeName string, dockerClient dockertools.DockerInterface, kubeClient clientset.Interface, rootDirectory string, seccompProfileRoot string, podInfraContainerImage string, resyncInterval time.Duration, pullQPS float32, pullBurst int, eventQPS float32, eventBurst int, containerGCPolicy kubecontainer.ContainerGCPolicy, sourcesReadyFn config.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 map[string]string, nodeStatusUpdateFrequency time.Duration, osInterface kubecontainer.OSInterface, cgroupRoot string, containerRuntime string, rktPath string, rktAPIEndpoint string, rktStage1Image string, mounter mount.Interface, writer kubeio.Writer, configureCBR0 bool, nonMasqueradeCIDR string, podCIDR string, reconcileCIDR bool, maxPods int, podsPerCore int, nvidiaGPUs int, dockerExecHandler dockertools.ExecHandler, resolverConfig string, cpuCFSQuota bool, daemonEndpoints *api.NodeDaemonEndpoints, oomAdjuster *oom.OOMAdjuster, serializeImagePulls bool, containerManager cm.ContainerManager, outOfDiskTransitionFrequency time.Duration, flannelExperimentalOverlay bool, nodeIP net.IP, reservation kubetypes.Reservation, enableCustomMetrics bool, volumeStatsAggPeriod time.Duration, containerRuntimeOptions []kubecontainer.Option, hairpinMode string, babysitDaemons bool, evictionConfig eviction.Config, kubeOptions []Option, ) (*Kubelet, error)
NewMainKubelet 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 ¶
func (kl *Kubelet) AttachContainer(podFullName string, podUID types.UID, containerName string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool) error
AttachContainer uses the container runtime to attach the given streams to the given container.
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) GeneratePodHostNameAndDomain ¶ added in v1.1.0
func (*Kubelet) GenerateRunContainerOptions ¶
func (kl *Kubelet) GenerateRunContainerOptions(pod *api.Pod, container *api.Container, podIP string) (*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) GetClusterDNS ¶ added in v1.1.0
GetClusterDNS returns a list of the DNS servers and a list of the DNS search domains of the cluster.
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) GetContainerInfoV2 ¶ added in v1.1.0
func (kl *Kubelet) GetContainerInfoV2(name string, options cadvisorapiv2.RequestOptions) (map[string]cadvisorapiv2.ContainerInfo, error)
GetContainerInfoV2 returns stats (from Cadvisor) for containers.
func (*Kubelet) GetHostname ¶
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) GetNode ¶
GetNode returns the node info for the configured node name of this Kubelet.
func (*Kubelet) GetNodeConfig ¶ added in v1.1.0
func (kl *Kubelet) GetNodeConfig() cm.NodeConfig
GetNodeConfig returns the container manager node config.
func (*Kubelet) GetPodByFullName ¶
GetPodByFullName gets the pod with the given 'full' name, which incorporates the namespace as well as whether the pod was found.
func (*Kubelet) GetPodByName ¶
GetPodByName provides the first pod that matches namespace and name, as well as whether the pod was found.
func (*Kubelet) GetPodDir ¶ added in v1.1.0
GetPodDir returns the full path to the per-pod data directory for the specified pod. This directory may not exist if the pod does not exist.
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) HandlePodAdditions ¶
HandlePodAdditions is the callback in SyncHandler for pods being added from a config source.
func (*Kubelet) HandlePodCleanups ¶
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 ¶
HandlePodDeletions is the callback in the SyncHandler interface for pods being deleted from a config source.
func (*Kubelet) HandlePodReconcile ¶ added in v1.1.0
HandlePodReconcile is the callback in the SyncHandler interface for pods that should be reconciled.
func (*Kubelet) HandlePodSyncs ¶
HandlePodSyncs is the callback in the syncHandler interface for pods that should be dispatched to pod workers for sync.
func (*Kubelet) HandlePodUpdates ¶
HandlePodUpdates is the callback in the SyncHandler interface for pods being updated from a config source.
func (*Kubelet) ImagesFsInfo ¶ added in v1.1.0
func (kl *Kubelet) ImagesFsInfo() (cadvisorapiv2.FsInfo, error)
ImagesFsInfo returns information about docker image fs usage from cadvisor.
func (*Kubelet) LatestLoopEntryTime ¶
LatestLoopEntryTime returns the last time in the sync loop monitor.
func (*Kubelet) ListVolumesForPod ¶ added in v1.1.0
ListVolumesForPod returns a map of the volumes associated with the given pod
func (*Kubelet) ListenAndServe ¶
func (kl *Kubelet) ListenAndServe(address net.IP, port uint, tlsOptions *server.TLSOptions, auth server.AuthInterface, enableDebuggingHandlers bool)
ListenAndServe runs the kubelet HTTP server.
func (*Kubelet) ListenAndServeReadOnly ¶
ListenAndServeReadOnly runs the kubelet HTTP server in read-only mode.
func (*Kubelet) PLEGHealthCheck ¶ added in v1.1.0
PLEGHealthCheck returns whether the PLEG is healty.
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 ¶
ResyncInterval returns the interval used for periodic syncs.
func (*Kubelet) RootFsInfo ¶ added in v1.1.0
func (kl *Kubelet) RootFsInfo() (cadvisorapiv2.FsInfo, error)
RootFsInfo returns info about the root fs from cadvisor.
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 ¶
func (kl *Kubelet) StartGarbageCollection()
Starts garbage collection threads.
func (*Kubelet) StreamingConnectionIdleTimeout ¶
StreamingConnectionIdleTimeout returns the timeout for streaming connections to the HTTP server.
type OOMWatcher ¶
type OOMWatcher interface {
Start(ref *api.ObjectReference) error
}
func NewOOMWatcher ¶
func NewOOMWatcher(cadvisor cadvisor.Interface, recorder record.EventRecorder) OOMWatcher
type OnCompleteFunc ¶ added in v1.1.0
type OnCompleteFunc func(err error)
OnCompleteFunc is a function that is invoked when an operation completes. If err is non-nil, the operation did not complete successfully.
type Option ¶ added in v1.1.0
type Option func(*Kubelet)
Option is a functional option type for Kubelet
type PodStatusFunc ¶ added in v1.1.0
PodStatusFunc is a function that is invoked to generate a pod status.
type PodWorkers ¶
type PodWorkers interface { UpdatePod(options *UpdatePodOptions) ForgetNonExistingPodWorkers(desiredPods map[types.UID]empty) ForgetWorker(uid types.UID) }
PodWorkers is an abstract interface for testability.
type ReasonCache ¶ added in v1.1.0
type ReasonCache struct {
// contains filtered or unexported fields
}
ReasonCache stores the failure reason of the latest container start in a string, keyed by <pod_UID>_<container_name>. The goal is to propagate this reason to the container status. This endeavor is "best-effort" for two reasons:
- The cache is not persisted.
- We use an LRU cache to avoid extra garbage collection work. This means that some entries may be recycled before a pod has been deleted.
TODO(random-liu): Use more reliable cache which could collect garbage of failed pod. TODO(random-liu): Move reason cache to somewhere better.
func NewReasonCache ¶ added in v1.1.0
func NewReasonCache() *ReasonCache
func (*ReasonCache) Get ¶ added in v1.1.0
Get gets error reason from the cache. The return values are error reason, error message and whether an error reason is found in the cache. If no error reason is found, empty string will be returned for error reason and error message.
func (*ReasonCache) Remove ¶ added in v1.1.0
func (c *ReasonCache) Remove(uid types.UID, name string)
Remove removes error reason from the cache
func (*ReasonCache) Update ¶ added in v1.1.0
func (c *ReasonCache) Update(uid types.UID, result kubecontainer.PodSyncResult)
Update updates the reason cache with the SyncPodResult. Only SyncResult with StartContainer action will change the cache.
type RunPodResult ¶
type SyncHandler ¶
type SyncHandler interface { HandlePodAdditions(pods []*api.Pod) HandlePodUpdates(pods []*api.Pod) HandlePodDeletions(pods []*api.Pod) HandlePodReconcile(pods []*api.Pod) HandlePodSyncs(pods []*api.Pod) HandlePodCleanups() error }
SyncHandler is an interface implemented by Kubelet, for testability
type UpdatePodOptions ¶ added in v1.1.0
type UpdatePodOptions struct { // pod to update Pod *api.Pod // the mirror pod for the pod to update, if it is a static pod MirrorPod *api.Pod // the type of update (create, update, sync, kill) UpdateType kubetypes.SyncPodType // optional callback function when operation completes // this callback is not guaranteed to be completed since a pod worker may // drop update requests if it was fulfilling a previous request. this is // only guaranteed to be invoked in response to a kill pod request which is // always delivered. OnCompleteFunc OnCompleteFunc // if update type is kill, use the specified options to kill the pod. KillPodOptions *KillPodOptions }
UpdatePodOptions is an options struct to pass to a UpdatePod operation.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
api
|
|
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 custommetrics contains support for instrumenting cAdvisor to gather custom metrics from pods.
|
Package custommetrics contains support for instrumenting cAdvisor to gather custom metrics from pods. |
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 eviction is responsible for enforcing eviction thresholds to maintain node stability.
|
Package eviction is responsible for enforcing eviction thresholds to maintain node stability. |
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 and interfaces to integrate with kubelet admission, synchronization, and eviction of pods.
|
Handlers for pod lifecycle events and interfaces to integrate with kubelet admission, synchronization, and eviction of pods. |
cni/testing
mock_cni is a mock of the `libcni.CNI` interface.
|
mock_cni is a mock of the `libcni.CNI` interface. |
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 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. |
Package server contains functions related to serving Kubelet's external interface.
|
Package server contains functions related to serving Kubelet's external interface. |
portforward
package portforward contains server-side logic for handling port forwarding requests.
|
package portforward contains server-side logic for handling port forwarding requests. |
remotecommand
package remotecommand contains functions related to executing commands in and attaching to pods.
|
package remotecommand contains functions related to executing commands in and attaching to pods. |
stats
Package stats handles exporting Kubelet and container stats.
|
Package stats handles exporting Kubelet and container stats. |
Common types in the Kubelet.
|
Common types in the Kubelet. |
Utility functions.
|
Utility functions. |