Documentation
¶
Overview ¶
Package runtime provides an interface for container runtime environments as well as some builtin implementations such as containerd.
Index ¶
- Constants
- type ContainerIO
- type ContainerdRuntime
- func (c *ContainerdRuntime) Cleanup(ctx context.Context, id string) error
- func (c *ContainerdRuntime) Delete(ctx context.Context, ctr *containers.Container) error
- func (c *ContainerdRuntime) Get(ctx context.Context, id string) (*containers.Container, error)
- func (c *ContainerdRuntime) ID(ctx context.Context, id string) (string, error)
- func (c *ContainerdRuntime) IO(ctx context.Context, id string) (*ContainerIO, error)
- func (c *ContainerdRuntime) Kill(ctx context.Context, ctr *containers.Container) error
- func (c *ContainerdRuntime) Labels(ctx context.Context, id string) (labels.Label, error)
- func (c *ContainerdRuntime) List(ctx context.Context) ([]*containers.Container, error)
- func (c *ContainerdRuntime) Name(ctx context.Context, id string) (string, error)
- func (c *ContainerdRuntime) Namespace() string
- func (c *ContainerdRuntime) Pull(ctx context.Context, ctr *containers.Container) error
- func (c *ContainerdRuntime) Run(ctx context.Context, ctr *containers.Container) error
- func (c *ContainerdRuntime) Stop(ctx context.Context, ctr *containers.Container) error
- func (c *ContainerdRuntime) Version(ctx context.Context) (string, error)
- type ID
- type NewContainerdRuntimeOption
- type Runtime
Constants ¶
const ( DefaultNamespace = "voiyd" IDMaxLen = 64 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContainerIO ¶
type ContainerIO struct {
Stdout io.ReadCloser
Stderr io.ReadCloser
}
type ContainerdRuntime ¶
type ContainerdRuntime struct {
// contains filtered or unexported fields
}
func NewContainerdRuntimeClient ¶
func NewContainerdRuntimeClient(client *containerd.Client, cni networking.Manager, opts ...NewContainerdRuntimeOption) *ContainerdRuntime
func (*ContainerdRuntime) Cleanup ¶
func (c *ContainerdRuntime) Cleanup(ctx context.Context, id string) error
Cleanup performs any tasks necessary to clean up the environment from danglig configuration. Such as tearing down the network.
func (*ContainerdRuntime) Delete ¶
func (c *ContainerdRuntime) Delete(ctx context.Context, ctr *containers.Container) error
Delete deletes the container and any tasks associated with it. Tasks will be forcefully stopped if running.
func (*ContainerdRuntime) Get ¶
func (c *ContainerdRuntime) Get(ctx context.Context, id string) (*containers.Container, error)
Get returns the first container from the runtime that matches the provided id
func (*ContainerdRuntime) IO ¶
func (c *ContainerdRuntime) IO(ctx context.Context, id string) (*ContainerIO, error)
func (*ContainerdRuntime) Kill ¶
func (c *ContainerdRuntime) Kill(ctx context.Context, ctr *containers.Container) error
Kill forcefully stops the container and tasks within by sending SIGKILL to the process. Like Stop(), Kill() does not perform garbage collection. Use Gleanup() for this.
func (*ContainerdRuntime) List ¶
func (c *ContainerdRuntime) List(ctx context.Context) ([]*containers.Container, error)
func (*ContainerdRuntime) Namespace ¶
func (c *ContainerdRuntime) Namespace() string
Namespace returns the namespace used for runnning workload. If supported by the runtime
func (*ContainerdRuntime) Pull ¶
func (c *ContainerdRuntime) Pull(ctx context.Context, ctr *containers.Container) error
func (*ContainerdRuntime) Run ¶
func (c *ContainerdRuntime) Run(ctx context.Context, ctr *containers.Container) error
func (*ContainerdRuntime) Stop ¶
func (c *ContainerdRuntime) Stop(ctx context.Context, ctr *containers.Container) error
Stop stops containers associated with the name of provided container instance. Stop will attempt to gracefully stop tasks, but will eventually do it forcefully if timeout is reached. Stop does not perform any garbage colletion and it is up to the caller to call Cleanup() after calling Stop()
type NewContainerdRuntimeOption ¶
type NewContainerdRuntimeOption func(c *ContainerdRuntime)
func WithLogDirFmt ¶
func WithLogDirFmt(rootPath string) NewContainerdRuntimeOption
WithLogDirFmt allows for setting the root directory for container log files (stdout). For example /var/lib/voiyd/containers/%s/log which happens to be the default location.
func WithLogger ¶
func WithLogger(l logger.Logger) NewContainerdRuntimeOption
func WithNamespace ¶
func WithNamespace(ns string) NewContainerdRuntimeOption
type Runtime ¶
type Runtime interface {
List(context.Context) ([]*containers.Container, error)
Get(context.Context, string) (*containers.Container, error)
Delete(context.Context, *containers.Container) error
Kill(context.Context, *containers.Container) error
Stop(context.Context, *containers.Container) error
Run(context.Context, *containers.Container) error
Cleanup(context.Context, string) error
Pull(context.Context, *containers.Container) error
Labels(context.Context, string) (labels.Label, error)
IO(context.Context, string) (*ContainerIO, error)
Namespace() string
Version(context.Context) (string, error)
ID(context.Context, string) (string, error)
Name(context.Context, string) (string, error)
}