kubernetes: github.com/erikstmartin/kubernetes/pkg/kubelet Index | Files | Directories

package kubelet

import "github.com/erikstmartin/kubernetes/pkg/kubelet"

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.


Package Files

cadvisor.go doc.go handlers.go kubelet.go runonce.go server.go types.go


const (
    RunOnceManifestDelay     = 1 * time.Second
    RunOnceMaxRetries        = 10
    RunOnceRetryDelay        = 1 * time.Second
    RunOnceRetryDelayBackoff = 2
const ConfigSourceAnnotationKey = "kubernetes/config.source"
const (
    NetworkContainerImage = "kubernetes/pause:latest"

func GetPodFullName Uses

func GetPodFullName(pod *api.BoundPod) string

GetPodFullName returns a name that uniquely identifies a pod across all config sources.

func ListenAndServeKubeletServer Uses

func ListenAndServeKubeletServer(host HostInterface, updates chan<- interface{}, address net.IP, port uint, enableDebuggingHandlers bool)

ListenAndServeKubeletServer initializes a server to respond to HTTP network requests on the Kubelet.

func ResolvePort Uses

func ResolvePort(portReference util.IntOrString, container *api.Container) (int, error)

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.

type ByCreated Uses

type ByCreated []*docker.Container

func (ByCreated) Len Uses

func (a ByCreated) Len() int

func (ByCreated) Less Uses

func (a ByCreated) Less(i, j int) bool

func (ByCreated) Swap Uses

func (a ByCreated) Swap(i, j int)

type FlushWriter Uses

type FlushWriter struct {
    // contains filtered or unexported fields

FlushWriter provides wrapper for responseWriter with HTTP streaming capabilities

func (*FlushWriter) Write Uses

func (fw *FlushWriter) Write(p []byte) (n int, err error)

Write is a FlushWriter implementation of the io.Writer that sends any buffered data to the client.

type HostInterface Uses

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)
    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 Uses

type Kubelet struct {
    // contains filtered or unexported fields

Kubelet is the main kubelet implementation.

func NewIntegrationTestKubelet Uses

func NewIntegrationTestKubelet(hn string, rd string, dc dockertools.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 Uses

func NewMainKubelet(
    hn string,
    dc dockertools.DockerInterface,
    ec tools.EtcdClient,
    rd string,
    ni string,
    ri time.Duration,
    pullQPS float32,
    pullBurst int,
    minimumGCAge time.Duration,
    maxContainerCount int) *Kubelet

New creates a new Kubelet for use in main

func (*Kubelet) GarbageCollectContainers Uses

func (kl *Kubelet) GarbageCollectContainers() error

TODO: Also enforce a maximum total number of containers.

func (*Kubelet) GetBoundPods Uses

func (kl *Kubelet) GetBoundPods() ([]api.BoundPod, error)

GetBoundPods returns all pods bound to the kubelet and their spec

func (*Kubelet) GetCadvisorClient Uses

func (kl *Kubelet) GetCadvisorClient() cadvisorInterface

GetCadvisorClient gets the cadvisor client.

func (*Kubelet) GetContainerInfo Uses

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 Uses

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

func (*Kubelet) GetMachineInfo Uses

func (kl *Kubelet) GetMachineInfo() (*cadvisor.MachineInfo, error)

func (*Kubelet) GetPodInfo Uses

func (kl *Kubelet) GetPodInfo(podFullName, uuid string) (api.PodInfo, error)

GetPodInfo returns information from Docker about the containers in a pod

func (*Kubelet) GetRootInfo Uses

func (kl *Kubelet) GetRootInfo(req *cadvisor.ContainerInfoRequest) (*cadvisor.ContainerInfo, error)

GetRootInfo returns stats (from Cadvisor) of current machine (root container).

func (*Kubelet) LogEvent Uses

func (kl *Kubelet) LogEvent(event *api.Event) error

LogEvent reports an event.

func (*Kubelet) Run Uses

func (kl *Kubelet) Run(updates <-chan PodUpdate)

Run starts the kubelet reacting to config updates

func (*Kubelet) RunInContainer Uses

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 Uses

func (kl *Kubelet) RunOnce(updates <-chan PodUpdate) ([]RunPodResult, error)

RunOnce polls from one configuration update and run the associated pods.

func (*Kubelet) ServeLogs Uses

func (kl *Kubelet) ServeLogs(w http.ResponseWriter, req *http.Request)

Returns logs of current machine.

func (*Kubelet) SetCadvisorClient Uses

func (kl *Kubelet) SetCadvisorClient(c cadvisorInterface)

SetCadvisorClient sets the cadvisor client in a thread-safe way.

func (*Kubelet) SyncPods Uses

func (kl *Kubelet) SyncPods(pods []api.BoundPod) error

SyncPods synchronizes the configured list of pods (desired state) with the host current state.

type PodOperation Uses

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
    // Pods with the given ids have been removed from this source
    // Pods with the given ids have been updated in this source

type PodUpdate Uses

type PodUpdate struct {
    Pods []api.BoundPod
    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 object and Op to SET.

type RunPodResult Uses

type RunPodResult struct {
    Pod *api.BoundPod
    Err error

type Server Uses

type Server struct {
    // contains filtered or unexported fields

Server is a http.Handler which exposes kubelet functionality over HTTP.

func NewServer Uses

func NewServer(host HostInterface, updates chan<- interface{}, enableDebuggingHandlers bool) Server

NewServer initializes and configures a kubelet.Server object to handle HTTP requests.

func (*Server) InstallDebuggingHandlers Uses

func (s *Server) InstallDebuggingHandlers()

InstallDeguggingHandlers registers the HTTP request patterns that serve logs or run commands/containers

func (*Server) InstallDefaultHandlers Uses

func (s *Server) InstallDefaultHandlers()

InstallDefaultHandlers registers the default set of supported HTTP request patterns with the mux.

func (*Server) ServeHTTP Uses

func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP responds to HTTP requests on the Kubelet.

type SyncHandler Uses

type SyncHandler interface {
    SyncPods([]api.BoundPod) error

SyncHandler is an interface implemented by Kubelet, for testability


configPackage config implements the pod configuration readers.

Package kubelet imports 29 packages (graph). Updated 2018-04-10. Refresh now. Tools for package owners.