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 EtcdClientOrDie(etcdServerList util.StringList, etcdConfigFile string) *etcd.Client
- func GetPodFullName(pod *api.BoundPod) string
- func InitHealthChecking(k *Kubelet)
- func ListenAndServeKubeletServer(host HostInterface, address net.IP, port uint, enableDebuggingHandlers bool)
- func MonitorCAdvisor(k *Kubelet, cp uint)
- func ParsePodFullName(podFullName string) (podName, podNamespace string, podAnnotations map[string]string)
- func ResolvePort(portReference util.IntOrString, container *api.Container) (int, error)
- func SetupCapabilities(allowPrivileged bool)
- func SetupEventSending(client *client.Client, hostname string)
- func SetupLogging()
- type ByCreated
- type FlushWriter
- type HostInterface
- type Kubelet
- func (kl *Kubelet) BirthCry()
- func (kl *Kubelet) GarbageCollectContainers() error
- func (kl *Kubelet) GarbageCollectImages() error
- func (kl *Kubelet) GarbageCollectLoop()
- func (kl *Kubelet) GetBoundPods() ([]api.BoundPod, error)
- func (kl *Kubelet) GetCadvisorClient() cadvisorInterface
- func (kl *Kubelet) GetContainerInfo(podFullName, uuid, containerName string, req *cadvisor.ContainerInfoRequest) (*cadvisor.ContainerInfo, error)
- func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error
- func (kl *Kubelet) GetMachineInfo() (*cadvisor.MachineInfo, error)
- func (kl *Kubelet) GetPodByName(namespace, name string) (*api.BoundPod, bool)
- func (kl *Kubelet) GetPodContainerDir(podUID, ctrName string) string
- func (kl *Kubelet) GetPodDir(podUID string) string
- func (kl *Kubelet) GetPodInfo(podFullName, uuid string) (api.PodInfo, error)
- func (kl *Kubelet) GetPodVolumesDir(podUID string) string
- func (kl *Kubelet) GetPodsDir() string
- func (kl *Kubelet) GetRootDir() string
- func (kl *Kubelet) GetRootInfo(req *cadvisor.ContainerInfoRequest) (*cadvisor.ContainerInfo, error)
- func (kl *Kubelet) Run(updates <-chan PodUpdate)
- func (kl *Kubelet) RunInContainer(podFullName, uuid, container 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) SetCadvisorClient(c cadvisorInterface)
- func (kl *Kubelet) SyncPods(pods []api.BoundPod) error
- type PodOperation
- type PodUpdate
- type RunPodResult
- type Server
- type SourceReadyFn
- type SyncHandler
Constants ¶
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 etcd EtcdSource = "etcd" // Updates from querying a web page HTTPSource = "http" // Updates received to the kubelet server ServerSource = "server" // Updates from Kubernetes API Server ApiserverSource = "api" // Updates from all sources AllSource = "*" )
const ConfigSourceAnnotationKey = "kubernetes.io/config.source"
const (
NetworkContainerImage = "kubernetes/pause:latest"
)
Variables ¶
This section is empty.
Functions ¶
func EtcdClientOrDie ¶ added in v0.2.1
func EtcdClientOrDie(etcdServerList util.StringList, etcdConfigFile string) *etcd.Client
TODO: move this into a pkg/tools/etcd_tools
func GetPodFullName ¶
GetPodFullName returns a name that uniquely identifies a pod across all config sources.
func InitHealthChecking ¶ added in v0.2.1
func InitHealthChecking(k *Kubelet)
TODO: move this into the kubelet itself
func ListenAndServeKubeletServer ¶
func ListenAndServeKubeletServer(host HostInterface, address net.IP, port uint, enableDebuggingHandlers bool)
ListenAndServeKubeletServer initializes a server to respond to HTTP network requests on the Kubelet.
func MonitorCAdvisor ¶ added in v0.2.1
TODO: move this into the kubelet itself
func ParsePodFullName ¶ added in v0.2.1
func ParsePodFullName(podFullName string) (podName, podNamespace string, podAnnotations map[string]string)
ParsePodFullName unpacks a pod full name and returns the pod name, namespace, and annotations. If the pod full name is invalid, empty strings are returend.
func ResolvePort ¶
ResolvePort attempts to turn a IntOrString port reference into a concrete port number. If portReference has an int value, it is treated as a literal, and simply returns that value. If portReference is a string, an attempt is first made to parse it as an integer. If that fails, an attempt is made to find a port with the same name in the container spec. If a port with the same name is found, it's ContainerPort value is returned. If no matching port is found, an error is returned.
func SetupCapabilities ¶ added in v0.2.1
func SetupCapabilities(allowPrivileged bool)
TODO: move this into pkg/capabilities
func SetupEventSending ¶ added in v0.2.1
Types ¶
type FlushWriter ¶
type FlushWriter struct {
// contains filtered or unexported fields
}
FlushWriter provides wrapper for responseWriter with HTTP streaming capabilities
type HostInterface ¶
type HostInterface interface { GetContainerInfo(podFullName, uuid, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) GetRootInfo(req *info.ContainerInfoRequest) (*info.ContainerInfo, error) GetMachineInfo() (*info.MachineInfo, error) GetBoundPods() ([]api.BoundPod, error) GetPodByName(namespace, name string) (*api.BoundPod, bool) GetPodInfo(name, uuid string) (api.PodInfo, error) RunInContainer(name, uuid, container string, cmd []string) ([]byte, error) GetKubeletContainerLogs(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error ServeLogs(w http.ResponseWriter, req *http.Request) }
HostInterface contains all the kubelet methods required by the server. For testablitiy.
type Kubelet ¶
type Kubelet struct {
// contains filtered or unexported fields
}
Kubelet is the main kubelet implementation.
func NewMainKubelet ¶
func NewMainKubelet( hostname string, dockerClient dockertools.DockerInterface, etcdClient tools.EtcdClient, kubeClient *client.Client, rootDirectory string, networkContainerImage string, resyncInterval time.Duration, pullQPS float32, pullBurst int, minimumGCAge time.Duration, maxContainerCount int, sourceReady SourceReadyFn, clusterDomain string, clusterDNS net.IP) (*Kubelet, error)
New creates a new Kubelet for use in main
func (*Kubelet) BirthCry ¶ added in v0.2.1
func (kl *Kubelet) BirthCry()
BirthCry sends an event that the kubelet has started up.
func (*Kubelet) GarbageCollectContainers ¶ added in v0.2.1
TODO: Also enforce a maximum total number of containers.
func (*Kubelet) GarbageCollectImages ¶ added in v0.2.1
func (*Kubelet) GarbageCollectLoop ¶ added in v0.2.1
func (kl *Kubelet) GarbageCollectLoop()
func (*Kubelet) GetBoundPods ¶ added in v0.2.1
GetBoundPods returns all pods bound to the kubelet and their spec
func (*Kubelet) GetCadvisorClient ¶
func (kl *Kubelet) GetCadvisorClient() cadvisorInterface
GetCadvisorClient gets the cadvisor client.
func (*Kubelet) GetContainerInfo ¶
func (kl *Kubelet) GetContainerInfo(podFullName, uuid, containerName string, req *cadvisor.ContainerInfoRequest) (*cadvisor.ContainerInfo, error)
GetContainerInfo returns stats (from Cadvisor) for a container.
func (*Kubelet) GetKubeletContainerLogs ¶
func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error
GetKubeletContainerLogs returns logs from the container The second parameter of GetPodInfo and FindPodContainer methods represents pod UUID, which is allowed to be blank 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) GetMachineInfo ¶
func (kl *Kubelet) GetMachineInfo() (*cadvisor.MachineInfo, error)
func (*Kubelet) GetPodByName ¶ added in v0.2.1
GetPodFullName provides the first pod that matches namespace and name, or false if no such pod can be found.
func (*Kubelet) GetPodContainerDir ¶ added in v0.2.1
GetPodContainerDir returns the full path to the per-pod data directory under which container data is held for the specified pod. This directory may not exist if the pod or container does not exist.
func (*Kubelet) GetPodDir ¶ added in v0.2.1
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) GetPodInfo ¶
GetPodInfo returns information from Docker about the containers in a pod
func (*Kubelet) GetPodVolumesDir ¶ added in v0.2.1
GetPodVolumesDir returns the full path to the per-pod data directory under which volumes are created for the specified pod. This directory may not exist if the pod does not exist.
func (*Kubelet) GetPodsDir ¶ added in v0.2.1
GetPodsDir returns the full path to the directory under which pod directories are created.
func (*Kubelet) GetRootDir ¶ added in v0.2.1
GetRootDir returns the full path to the directory under which kubelet can store data. These functions are useful to pass interfaces to other modules that may need to know where to write data without getting a whole kubelet instance.
func (*Kubelet) GetRootInfo ¶
func (kl *Kubelet) GetRootInfo(req *cadvisor.ContainerInfoRequest) (*cadvisor.ContainerInfo, error)
GetRootInfo returns stats (from Cadvisor) of current machine (root container).
func (*Kubelet) RunInContainer ¶
func (kl *Kubelet) RunInContainer(podFullName, uuid, container 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) SetCadvisorClient ¶
func (kl *Kubelet) SetCadvisorClient(c cadvisorInterface)
SetCadvisorClient sets the cadvisor client in a thread-safe way.
type PodOperation ¶
type PodOperation int
PodOperation defines what changes will be made on a pod configuration.
type PodUpdate ¶
type PodUpdate struct { Pods []api.BoundPod 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 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 SourceReadyFn ¶ added in v0.2.1
type SyncHandler ¶
SyncHandler is an interface implemented by Kubelet, for testability
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
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. |