kubelet

package
v0.0.0-...-9017c7e Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package kubelet is ...

Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DockerContainerData

type DockerContainerData struct {
	// contains filtered or unexported fields
}

The structured representation of the JSON object returned by Docker inspect

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
	// 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, manifestUrl, etcdServers, 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,
	fileChannel, serverChannel, httpChannel <-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) SyncHTTP

func (sl *Kubelet) SyncHTTP(client *http.Client, url string, config *api.ContainerManifest) ([]byte, error)

SyncHTTP reads from url a yaml manifest and populates config. Returns the raw bytes, if something was read. Returns an error if something goes wrong. 'client' is used to execute the request, to allow caching of clients.

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.

func (*Kubelet) WatchFile

func (sl *Kubelet) WatchFile(file string, changeChannel chan<- api.ContainerManifest)

Watch a file for changes to the set of tasks that should run on this Kubelet This function loops forever and is intended to be run as a goroutine

func (*Kubelet) WatchHTTP

func (sl *Kubelet) WatchHTTP(url string, changeChannel chan<- api.ContainerManifest)

Watch an HTTP endpoint for changes to the set of tasks that should run on this Kubelet This function runs forever and is intended to be run as a goroutine

type KubeletServer

type KubeletServer struct {
	Kubelet       *Kubelet
	UpdateChannel chan api.ContainerManifest
}

func (*KubeletServer) ServeHTTP

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

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