Documentation ¶
Index ¶
- Constants
- Variables
- type Container
- func (c *Container) AttachSocket() string
- func (c *Container) CloseStdin() error
- func (c *Container) ControlSocket() string
- func (c *Container) Create(baseDir string) error
- func (c *Container) CreatedAt() int64
- func (c *Container) Exec(cmd []string, stdin io.Reader, stdout, stderr io.Writer) error
- func (c *Container) ExecSync(timeout time.Duration, cmd []string) (*k8s.ExecSyncResponse, error)
- func (c *Container) ExitCode() int32
- func (c *Container) ExitDescription() string
- func (c *Container) FinishedAt() int64
- func (c *Container) ID() string
- func (c *Container) ImageID() string
- func (c *Container) LogPath() string
- func (c *Container) MatchesFilter(filter *k8s.ContainerFilter) bool
- func (c *Container) Pid() int
- func (c *Container) PodID() string
- func (c *Container) PrepareExec(cmd []string) *exec.Cmd
- func (c *Container) Remove() error
- func (c *Container) ReopenLogFile() error
- func (c *Container) Start() error
- func (c *Container) StartedAt() int64
- func (c *Container) Stat() (*ContainerStat, error)
- func (c *Container) State() k8s.ContainerState
- func (c *Container) StateReason() string
- func (c *Container) Stdin() io.Writer
- func (c *Container) StdinClosed() bool
- func (c *Container) Stop(timeout int64) error
- func (c *Container) UpdateResources(upd *k8s.LinuxContainerResources) error
- func (c *Container) UpdateState() error
- type ContainerStat
- type Pod
- func (p *Pod) Containers() []string
- func (p *Pod) CreatedAt() int64
- func (p *Pod) ID() string
- func (p *Pod) MatchesFilter(filter *k8s.PodSandboxFilter) bool
- func (p *Pod) NetworkStatus() *k8s.PodSandboxNetworkStatus
- func (p *Pod) Pid() int
- func (p *Pod) Remove() error
- func (p *Pod) Run(baseDir string) error
- func (p *Pod) SetUpNetwork(manager *network.Manager) error
- func (p *Pod) State() k8s.PodSandboxState
- func (p *Pod) Stop() error
- func (p *Pod) TearDownNetwork(manager *network.Manager) error
- func (p *Pod) UpdateState() error
Constants ¶
const (
// ContainerIDLen reflects number of symbols in container unique ID.
ContainerIDLen = 64
)
const (
// PodIDLen reflects number of symbols in pod unique ID.
PodIDLen = 64
)
Variables ¶
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 ¶
AttachSocket returns attach socket on which runtime will serve attach request.
func (*Container) CloseStdin ¶
CloseStdin closes write end of container's stdin.
func (*Container) ControlSocket ¶
ControlSocket returns control socket on which runtime will wait for control signals, e.g. resize event.
func (*Container) Create ¶
Create creates container inside a pod from the image. All files created (bundle, sync socket, etc) are located in baseDir.
func (*Container) Exec ¶
Exec executes a command inside a container with attaching passed io streams to it.
func (*Container) ExitDescription ¶
ExitDescription returns human readable message of why container has exited.
func (*Container) FinishedAt ¶
FinishedAt returns container finish time in unix nano.
func (*Container) LogPath ¶
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) PrepareExec ¶
PrepareExec creates an instance of exec.Cmd that may be used later to run a command inside an allocated tty.
func (*Container) Remove ¶
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 ¶
ReopenLogFile reopens container log file. This method is usually called when logs are rotated.
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 ¶
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 ¶
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 ¶
StdinClosed returns true when allocated stdin (if any) has been already closed (possibly due to stdinOnce flag).
func (*Container) Stop ¶
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 ¶
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 ¶
Containers return list or container IDs that are in this pod.
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) Remove ¶
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 ¶
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 ¶
SetUpNetwork brings up network interface and configure it inside pod's network namespace.
func (*Pod) TearDownNetwork ¶
TearDownNetwork tears down network interface previously set inside pod's network namespace.
func (*Pod) UpdateState ¶
UpdateState updates container state according to information received from the runtime.