kube

package
v1.0.0-beta.7 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2019 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContainerIDLen reflects number of symbols in container unique ID.
	ContainerIDLen = 64
)
View Source
const (
	// PodIDLen reflects number of symbols in pod unique ID.
	PodIDLen = 64
)

Variables

View Source
var (
	// ErrContainerNotCreated is used when attempting to perform operations on containers that
	// are not in CONTAINER_CREATED state, e.g. start already started container.
	ErrContainerNotCreated = fmt.Errorf("container is not in %s state", k8s.ContainerState_CONTAINER_CREATED.String())
)

Functions

This section is empty.

Types

type Container

type Container struct {
	*k8s.ContainerConfig
	// contains filtered or unexported fields
}

Container represents kubernetes container inside a pod. It encapsulates all container-specific logic and should be used by runtime for correct interaction.

func NewContainer

func NewContainer(config *k8s.ContainerConfig, pod *Pod, info *image.Info, trashDir string) *Container

NewContainer constructs Container instance. Container is thread safe to use.

func (*Container) AttachSocket

func (c *Container) AttachSocket() string

AttachSocket returns attach socket on which runtime will serve attach request.

func (*Container) CloseStdin

func (c *Container) CloseStdin() error

CloseStdin closes write end of container's stdin.

func (*Container) ControlSocket

func (c *Container) ControlSocket() string

ControlSocket returns control socket on which runtime will wait for control signals, e.g. resize event.

func (*Container) Create

func (c *Container) Create(baseDir string) error

Create creates container inside a pod from the image. All files created (bundle, sync socket, etc) are located in baseDir.

func (*Container) CreatedAt

func (c *Container) CreatedAt() int64

CreatedAt returns pod creation time in Unix nano.

func (*Container) Exec

func (c *Container) Exec(cmd []string, stdin io.Reader, stdout, stderr io.Writer) error

Exec executes a command inside a container with attaching passed io streams to it.

func (*Container) ExecSync

func (c *Container) ExecSync(timeout time.Duration, cmd []string) (*k8s.ExecSyncResponse, error)

ExecSync runs passed command inside a container and returns result.

func (*Container) ExitCode

func (c *Container) ExitCode() int32

ExitCode returns container exit code.

func (*Container) ExitDescription

func (c *Container) ExitDescription() string

ExitDescription returns human readable message of why container has exited.

func (*Container) FinishedAt

func (c *Container) FinishedAt() int64

FinishedAt returns container finish time in unix nano.

func (*Container) ID

func (c *Container) ID() string

ID returns unique container ID.

func (*Container) ImageID

func (c *Container) ImageID() string

ImageID returns id of the container base image.

func (*Container) LogPath

func (c *Container) LogPath() string

LogPath returns and absolute path to container logs on the host filesystem or empty string if logs are not collected.

func (*Container) MatchesFilter

func (c *Container) MatchesFilter(filter *k8s.ContainerFilter) bool

MatchesFilter tests Container against passed filter and returns true if it matches.

func (*Container) Pid

func (c *Container) Pid() int

Pid returns pid of the container process in the host's PID namespace.

func (*Container) PodID

func (c *Container) PodID() string

PodID returns ID of a pod container is executed in.

func (*Container) PrepareExec

func (c *Container) PrepareExec(cmd []string) *exec.Cmd

PrepareExec creates an instance of exec.Cmd that may be used later to run a command inside an allocated tty.

func (*Container) Remove

func (c *Container) Remove() error

Remove removes the container, making sure nothing of it left on the host filesystem. When no Stop is called before Remove forcibly kills container process.

func (*Container) ReopenLogFile

func (c *Container) ReopenLogFile() error

ReopenLogFile reopens container log file. This method is usually called when logs are rotated.

func (*Container) Start

func (c *Container) Start() error

Start starts created container.

func (*Container) StartedAt

func (c *Container) StartedAt() int64

StartedAt returns container start time in unix nano.

func (*Container) Stat

func (c *Container) Stat() (*ContainerStat, error)

Stat fetches information about container resources usage. This method implies that cpuacct and memory cgroups controllers are mounted on host at /sys/fs/cgroups/cpuacct and /sys/fs/cgroups/memory respectively.

func (*Container) State

func (c *Container) State() k8s.ContainerState

State returns current container state understood by k8s.

func (*Container) StateReason

func (c *Container) StateReason() string

StateReason returns brief string explaining why container is in its current state. K8s requires us to return CamelCase here, but we will fallback to full description in case of unknown container state.

func (*Container) Stdin

func (c *Container) Stdin() io.Writer

Stdin returns write end of container's stdin, if any. If container is created with StdinOnce set to true this call will return nil after first attach to container finishes.

func (*Container) StdinClosed

func (c *Container) StdinClosed() bool

StdinClosed returns true when allocated stdin (if any) has been already closed (possibly due to stdinOnce flag).

func (*Container) Stop

func (c *Container) Stop(timeout int64) error

Stop stops running container. The passed timeout is used to give container a chance to stop gracefully. If timeout is 0 or container is still running after grace period, it will be forcibly terminated.

func (*Container) UpdateResources

func (c *Container) UpdateResources(upd *k8s.LinuxContainerResources) error

UpdateResources updates container resources according to the passed request. This method implies that cpu, cpuset and memory cgroups controllers are mounted on host at /sys/fs/cgroups/cpu, /sys/fs/cgroups/cpuset and /sys/fs/cgroups/memory respectively.

func (*Container) UpdateState

func (c *Container) UpdateState() error

UpdateState updates container state according to information received from the runtime.

type ContainerStat

type ContainerStat struct {
	// Writable layer fs usage.
	Fs *fs.UsageInfo
	// Total memory used by container in bytes
	Memory uint64
	// Total CPU used in nanoseconds.
	CPU uint64
}

ContainerStat holds information about container resources usage.

type Pod

type Pod struct {
	*k8s.PodSandboxConfig
	// contains filtered or unexported fields
}

Pod represents kubernetes pod. It encapsulates all pod-specific logic and should be used by runtime for correct interaction.

func NewPod

func NewPod(config *k8s.PodSandboxConfig) *Pod

NewPod constructs Pod instance. Pod is thread safe to use.

func (*Pod) Containers

func (p *Pod) Containers() []string

Containers return list or container IDs that are in this pod.

func (*Pod) CreatedAt

func (p *Pod) CreatedAt() int64

CreatedAt returns pod creation time in Unix nano.

func (*Pod) ID

func (p *Pod) ID() string

ID returns unique pod ID.

func (*Pod) MatchesFilter

func (p *Pod) MatchesFilter(filter *k8s.PodSandboxFilter) bool

MatchesFilter tests Pod against passed filter and returns true if it matches.

func (*Pod) NetworkStatus

func (p *Pod) NetworkStatus() *k8s.PodSandboxNetworkStatus

NetworkStatus returns pod's IP address.

func (*Pod) Pid

func (p *Pod) Pid() int

Pid returns pid of the pod process in the host's PID namespace.

func (*Pod) Remove

func (p *Pod) Remove() error

Remove removes pod and all its containers, making sure nothing of it left on the host filesystem. When no Stop is called before Remove forcibly kills all containers and pod itself.

func (*Pod) Run

func (p *Pod) Run(baseDir string) error

Run prepares and runs pod based on initial config passed to NewPod. All files created (namespaces, sync socket, etc) are located in baseDir.

func (*Pod) SetUpNetwork

func (p *Pod) SetUpNetwork(manager *network.Manager) error

SetUpNetwork brings up network interface and configure it inside pod's network namespace.

func (*Pod) State

func (p *Pod) State() k8s.PodSandboxState

State returns current pod state.

func (*Pod) Stop

func (p *Pod) Stop() error

Stop stops pod and all its containers, reclaims any resources.

func (*Pod) TearDownNetwork

func (p *Pod) TearDownNetwork(manager *network.Manager) error

TearDownNetwork tears down network interface previously set inside pod's network namespace.

func (*Pod) UpdateState

func (p *Pod) UpdateState() error

UpdateState updates container state according to information received from the runtime.

Jump to

Keyboard shortcuts

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