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 ¶
- Variables
- func GetPodFullName(pod *Pod) string
- func ListenAndServeKubeletServer(host HostInterface, updates chan<- interface{}, address string, port uint)
- func ValidatePod(pod *Pod) (errors []error)
- type CadvisorInterface
- type ContainerCommandRunner
- type DockerContainerData
- type DockerContainers
- type DockerID
- type DockerInterface
- type DockerPuller
- type FakeDockerClient
- func (f *FakeDockerClient) CreateContainer(c docker.CreateContainerOptions) (*docker.Container, error)
- func (f *FakeDockerClient) InspectContainer(id string) (*docker.Container, error)
- func (f *FakeDockerClient) ListContainers(options docker.ListContainersOptions) ([]docker.APIContainers, error)
- func (f *FakeDockerClient) PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration) error
- func (f *FakeDockerClient) StartContainer(id string, hostConfig *docker.HostConfig) error
- func (f *FakeDockerClient) StopContainer(id string, timeout uint) error
- type FakeDockerPuller
- type HostInterface
- type Kubelet
- func (kl *Kubelet) GetContainerInfo(podFullName, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
- func (kl *Kubelet) GetMachineInfo() (*info.MachineInfo, error)
- func (kl *Kubelet) GetPodInfo(podFullName string) (api.PodInfo, error)
- func (kl *Kubelet) GetRootInfo(req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
- func (kl *Kubelet) LogEvent(event *api.Event) error
- func (kl *Kubelet) Run(updates <-chan PodUpdate)
- func (kl *Kubelet) RunInContainer(podFullName, container string, cmd []string) ([]byte, error)
- func (kl *Kubelet) ServeLogs(w http.ResponseWriter, req *http.Request)
- func (kl *Kubelet) SyncPods(pods []Pod) error
- type Pod
- type PodOperation
- type PodUpdate
- type Server
- type SyncHandler
Constants ¶
This section is empty.
Variables ¶
var ErrNoContainersInPod = errors.New("no containers exist for this pod")
ErrNoContainersInPod is returned when there are no running containers for a given pod
Functions ¶
func GetPodFullName ¶
GetPodFullName returns a name that full identifies a pod across all config sources.
func ListenAndServeKubeletServer ¶
func ListenAndServeKubeletServer(host HostInterface, updates chan<- interface{}, address string, port uint)
ListenAndServeKubeletServer initializes a server to respond to HTTP network requests on the Kubelet
func ValidatePod ¶
Types ¶
type CadvisorInterface ¶
type CadvisorInterface interface { ContainerInfo(name string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) MachineInfo() (*info.MachineInfo, error) }
CadvisorInterface is an abstract interface for testability. It abstracts the interface of "github.com/google/cadvisor/client".Client.
type ContainerCommandRunner ¶
type ContainerCommandRunner interface {
RunInContainer(containerID string, cmd []string) ([]byte, error)
}
func NewDockerContainerCommandRunner ¶
func NewDockerContainerCommandRunner() ContainerCommandRunner
NewDockerContainerCommandRunner creates a ContainerCommandRunner which uses nsinit to run a command inside a container.
type DockerContainerData ¶
type DockerContainerData struct {
// contains filtered or unexported fields
}
DockerContainerData is the structured representation of the JSON object returned by Docker inspect
type DockerContainers ¶
type DockerContainers map[DockerID]*docker.APIContainers
DockerContainers is a map of containers
func (DockerContainers) FindContainersByPodFullName ¶
func (c DockerContainers) FindContainersByPodFullName(podFullName string) map[string]*docker.APIContainers
func (DockerContainers) FindPodContainer ¶
func (c DockerContainers) FindPodContainer(podFullName, containerName string) (*docker.APIContainers, bool, uint64)
type DockerID ¶
type DockerID string
DockerID is an ID of docker container. It is a type to make it clear when we're working with docker container Ids
type DockerInterface ¶
type DockerInterface interface { ListContainers(options docker.ListContainersOptions) ([]docker.APIContainers, error) InspectContainer(id string) (*docker.Container, error) CreateContainer(docker.CreateContainerOptions) (*docker.Container, error) StartContainer(id string, hostConfig *docker.HostConfig) error StopContainer(id string, timeout uint) error PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration) error }
DockerInterface is an abstract interface for testability. It abstracts the interface of docker.Client.
type DockerPuller ¶
DockerPuller is an abstract interface for testability. It abstracts image pull operations.
func NewDockerPuller ¶
func NewDockerPuller(client DockerInterface) DockerPuller
NewDockerPuller creates a new instance of the default implementation of DockerPuller.
type FakeDockerClient ¶
type FakeDockerClient struct { Created []string // contains filtered or unexported fields }
FakeDockerClient is a simple fake docker client, so that kubelet can be run for testing without requiring a real docker setup.
func (*FakeDockerClient) CreateContainer ¶
func (f *FakeDockerClient) CreateContainer(c docker.CreateContainerOptions) (*docker.Container, error)
CreateContainer is a test-spy implementation of DockerInterface.CreateContainer. It adds an entry "create" to the internal method call record.
func (*FakeDockerClient) InspectContainer ¶
func (f *FakeDockerClient) InspectContainer(id string) (*docker.Container, error)
InspectContainer is a test-spy implementation of DockerInterface.InspectContainer. It adds an entry "inspect" to the internal method call record.
func (*FakeDockerClient) ListContainers ¶
func (f *FakeDockerClient) ListContainers(options docker.ListContainersOptions) ([]docker.APIContainers, error)
ListContainers is a test-spy implementation of DockerInterface.ListContainers. It adds an entry "list" to the internal method call record.
func (*FakeDockerClient) PullImage ¶
func (f *FakeDockerClient) PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration) error
PullImage is a test-spy implementation of DockerInterface.StopContainer. It adds an entry "pull" to the internal method call record.
func (*FakeDockerClient) StartContainer ¶
func (f *FakeDockerClient) StartContainer(id string, hostConfig *docker.HostConfig) error
StartContainer is a test-spy implementation of DockerInterface.StartContainer. It adds an entry "start" to the internal method call record.
func (*FakeDockerClient) StopContainer ¶
func (f *FakeDockerClient) StopContainer(id string, timeout uint) error
StopContainer is a test-spy implementation of DockerInterface.StopContainer. It adds an entry "stop" to the internal method call record.
type FakeDockerPuller ¶
type FakeDockerPuller struct { ImagesPulled []string // Every pull will return the first error here, and then reslice // to remove it. Will give nil errors if this slice is empty. ErrorsToInject []error // contains filtered or unexported fields }
FakeDockerPuller is a stub implementation of DockerPuller.
func (*FakeDockerPuller) Pull ¶
func (f *FakeDockerPuller) Pull(image string) (err error)
Pull records the image pull attempt, and optionally injects an error.
type HostInterface ¶
type HostInterface interface { GetContainerInfo(podFullName, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) GetRootInfo(req *info.ContainerInfoRequest) (*info.ContainerInfo, error) GetMachineInfo() (*info.MachineInfo, error) GetPodInfo(name string) (api.PodInfo, error) RunInContainer(name, container string, cmd []string) ([]byte, 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 NewIntegrationTestKubelet ¶
func NewIntegrationTestKubelet(hn string, dc DockerInterface) *Kubelet
NewIntegrationTestKubelet creates a new Kubelet for use in integration tests. TODO: add more integration tests, and expand parameter list as needed.
func NewMainKubelet ¶
func NewMainKubelet( hn string, dc DockerInterface, cc CadvisorInterface, ec tools.EtcdClient, rd string, ri time.Duration) *Kubelet
New creates a new Kubelet for use in main
func (*Kubelet) GetContainerInfo ¶
func (kl *Kubelet) GetContainerInfo(podFullName, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
GetContainerInfo returns stats (from Cadvisor) for a container.
func (*Kubelet) GetMachineInfo ¶
func (kl *Kubelet) GetMachineInfo() (*info.MachineInfo, error)
func (*Kubelet) GetPodInfo ¶
GetPodInfo returns information from Docker about the containers in a pod
func (*Kubelet) GetRootInfo ¶
func (kl *Kubelet) GetRootInfo(req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
GetRootInfo returns stats (from Cadvisor) of current machine (root container).
func (*Kubelet) RunInContainer ¶
Run a command in a container, returns the combined stdout, stderr as an array of bytes
type Pod ¶
type Pod struct { Namespace string Name string Manifest api.ContainerManifest }
Pod represents the structure of a pod on the Kubelet, distinct from the apiserver representation of a Pod.
type PodOperation ¶
type PodOperation int
PodOperation defines what changes will be made on a pod configuration.
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 )
type PodUpdate ¶
type PodUpdate struct { Pods []Pod Op PodOperation }
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 array and Op to SET.
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, updates chan<- interface{}) Server
NewServer initializes and configures a kubelet.Server object to handle HTTP requests
func (*Server) InstallDefaultHandlers ¶
func (s *Server) InstallDefaultHandlers()
InstallDefaultHandlers registers the set of supported HTTP request patterns with the mux
type SyncHandler ¶
SyncHandler is an interface implemented by Kubelet, for testability