kubelet

package
v0.0.0-...-cb9e437 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package kubelet is ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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
}

Interface for testability

type Kubelet

type Kubelet struct {
	Client             registry.EtcdClient
	DockerClient       DockerInterface
	FileCheckFrequency time.Duration
	SyncFrequency      time.Duration
	HTTPCheckFrequency time.Duration

	Hostname string
	// contains filtered or unexported fields
}

The main kubelet implementation

func (*Kubelet) ContainerExists

func (sl *Kubelet) ContainerExists(manifest *api.ContainerManifest, container *api.Container) (exists bool, foundName string, err error)

Does this container exist on this host? Returns true if so, and the name under which the container is running. Returns an error if one occurs.

func (*Kubelet) ExtractYAMLData

func (sl *Kubelet) ExtractYAMLData(buf []byte, output interface{}) error

Extract data from YAML file into a list of containers.

func (*Kubelet) GetContainerByName

func (sl *Kubelet) GetContainerByName(name string) (*docker.Container, error)

Get a container by name. returns the container data from Docker, or an error if one exists.

func (*Kubelet) GetContainerID

func (sl *Kubelet) GetContainerID(name string) (string, error)

func (*Kubelet) GetContainerInfo

func (sl *Kubelet) GetContainerInfo(name string) (string, error)

func (*Kubelet) KillContainer

func (sl *Kubelet) KillContainer(name string) error

func (*Kubelet) ListContainers

func (sl *Kubelet) ListContainers() ([]string, error)

func (*Kubelet) LogEvent

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

Log an event to the etcd backend.

func (*Kubelet) ResponseToManifests

func (sl *Kubelet) ResponseToManifests(response *etcd.Response) ([]api.ContainerManifest, error)

Take an etcd Response object, and turn it into a structured list of containers Return a list of containers, or an error if one occurs.

func (*Kubelet) RunContainer

func (sl *Kubelet) RunContainer(manifest *api.ContainerManifest, container *api.Container) (name string, err error)

func (*Kubelet) RunKubelet

func (sl *Kubelet) RunKubelet(file, manifest_url, etcd_servers, address string, port uint)

Starts background goroutines. If file, manifest_url, or address are empty, they are not watched. Never returns.

func (*Kubelet) RunSyncLoop

func (sl *Kubelet) RunSyncLoop(etcdChannel <-chan []api.ContainerManifest, handler SyncHandler)

runSyncLoop is the main loop for processing changes. It watches for changes from four channels (file, etcd, server, and http) and creates a union of the two. For any new change seen, will run a sync against desired state and running state. If no changes are seen to the configuration, will synchronize the last known desired state every sync_frequency seconds. Never returns.

func (*Kubelet) SyncAndSetupEtcdWatch

func (sl *Kubelet) SyncAndSetupEtcdWatch(changeChannel chan<- []api.ContainerManifest)

Sync with etcd, and set up an etcd watch for new configurations The channel to send new configurations across This function loops forever and is intended to be run in a go routine.

func (*Kubelet) SyncManifests

func (sl *Kubelet) SyncManifests(config []api.ContainerManifest) error

Sync the configured list of containers (desired state) with the host current state

func (*Kubelet) TimeoutWatch

func (sl *Kubelet) TimeoutWatch(done chan bool)

Timeout the watch after 30 seconds

func (*Kubelet) WatchEtcd

func (sl *Kubelet) WatchEtcd(watchChannel <-chan *etcd.Response, changeChannel chan<- []api.ContainerManifest)

Watch etcd for changes, receives config objects from the etcd client watch. This function loops forever and is intended to be run as a goroutine.

type State

type State struct {
	Running bool
}

State, sub object of the Docker JSON data

type SyncHandler

type SyncHandler interface {
	SyncManifests([]api.ContainerManifest) error
}

Interface implemented by Kubelet, for testability

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL