containerd

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PluginName is the name of the plugin
	// this is used for logging and (along with the version) for uniquely
	// identifying plugin binaries fingerprinted by the client
	PluginName = "containerd-driver"

	// PluginVersion allows the client to identify and use newer versions of
	// an installed plugin
	PluginVersion = "v0.9.3"
)

Variables

This section is empty.

Functions

func NewPlugin

func NewPlugin(logger log.Logger) drivers.DriverPlugin

NewPlugin returns a new containerd driver plugin

func WithMemoryLimits

func WithMemoryLimits(soft, hard int64) oci.SpecOpts

WithMemoryLimits accepts soft (`memory`) and hard (`memory_max`) limits as parameters and set the desired limits. With `Nomad<1.1.0` releases, soft (`memory`) will act as a hard limit, and if the container process exceeds that limit, it will be OOM'ed. With `Nomad>=1.1.0` releases, users can over-provision using `soft` and `hard` limits. The container process will only get OOM'ed if the hard limit is exceeded.

func WithSysctls

func WithSysctls(sysctls map[string]string) oci.SpecOpts

WithSysctls sets the provided sysctls onto the spec Original code referenced from: https://github.com/containerd/containerd/blob/master/pkg/cri/opts/spec_linux.go#L546-L560

Types

type Config

type Config struct {
	Enabled           bool         `codec:"enabled"`
	ContainerdRuntime string       `codec:"containerd_runtime"`
	StatsInterval     string       `codec:"stats_interval"`
	AllowPrivileged   bool         `codec:"allow_privileged"`
	Auth              RegistryAuth `codec:"auth"`
}

Config contains configuration information for the plugin

type ContainerConfig

type ContainerConfig struct {
	Image                 containerd.Image
	ContainerName         string
	ContainerSnapshotName string
	NetworkNamespacePath  string
	SecretsDirSrc         string
	TaskDirSrc            string
	AllocDirSrc           string
	SecretsDirDest        string
	TaskDirDest           string
	AllocDirDest          string
	Env                   []string
	MemoryLimit           int64
	MemoryHardLimit       int64
	CPUShares             int64
	User                  string
}

type CredentialsOpt

type CredentialsOpt func(string) (string, string, error)

type Driver

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

func (*Driver) Capabilities

func (d *Driver) Capabilities() (*drivers.Capabilities, error)

Capabilities returns the features supported by the driver.

func (*Driver) ConfigSchema

func (d *Driver) ConfigSchema() (*hclspec.Spec, error)

ConfigSchema returns the plugin configuration schema.

func (*Driver) DestroyTask

func (d *Driver) DestroyTask(taskID string, force bool) error

DestroyTask cleans up and removes a task that has terminated.

func (*Driver) ExecTask

func (d *Driver) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error)

ExecTask returns the result of executing the given command inside a task. This is an optional capability.

func (*Driver) ExecTaskStreaming

func (d *Driver) ExecTaskStreaming(ctx context.Context, taskID string, opts *drivers.ExecOptions) (*drivers.ExitResult, error)

ExecTaskStreaming returns the result of executing the given command inside a task.

func (*Driver) Fingerprint

func (d *Driver) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint, error)

Fingerprint returns a channel that will be used to send health information and other driver specific node attributes.

func (*Driver) InspectTask

func (d *Driver) InspectTask(taskID string) (*drivers.TaskStatus, error)

InspectTask returns detailed status information for the referenced taskID.

func (*Driver) PluginInfo

func (d *Driver) PluginInfo() (*base.PluginInfoResponse, error)

PluginInfo returns information describing the plugin.

func (*Driver) RecoverTask

func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error

RecoverTask recreates the in-memory state of a task from a TaskHandle.

func (*Driver) SetConfig

func (d *Driver) SetConfig(cfg *base.Config) error

SetConfig is called by the client to pass the configuration for the plugin.

func (*Driver) SignalTask

func (d *Driver) SignalTask(taskID string, signal string) error

SignalTask forwards a signal to a task. This is an optional capability.

func (*Driver) StartTask

StartTask returns a task handle and a driver network if necessary.

func (*Driver) StopTask

func (d *Driver) StopTask(taskID string, timeout time.Duration, signal string) error

StopTask stops a running task with the given signal and within the timeout window.

func (*Driver) TaskConfigSchema

func (d *Driver) TaskConfigSchema() (*hclspec.Spec, error)

TaskConfigSchema returns the HCL schema for the configuration of a task.

func (*Driver) TaskEvents

func (d *Driver) TaskEvents(ctx context.Context) (<-chan *drivers.TaskEvent, error)

TaskEvents returns a channel that the plugin can use to emit task related events.

func (*Driver) TaskStats

func (d *Driver) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error)

TaskStats returns a channel which the driver should send stats to at the given interval.

func (*Driver) WaitTask

func (d *Driver) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error)

WaitTask returns a channel used to notify Nomad when a task exits.

type Mount

type Mount struct {
	Type    string   `codec:"type"`
	Target  string   `codec:"target"`
	Source  string   `codec:"source"`
	Options []string `codec:"options"`
}

Volume, bind, and tmpfs type mounts are supported. Mount contains configuration information about a mountpoint.

type RegistryAuth

type RegistryAuth struct {
	Username string `codec:"username"`
	Password string `codec:"password"`
}

Auth info to pull image from registry.

type TaskConfig

type TaskConfig struct {
	Image            string             `codec:"image"`
	Command          string             `codec:"command"`
	Args             []string           `codec:"args"`
	CapAdd           []string           `codec:"cap_add"`
	CapDrop          []string           `codec:"cap_drop"`
	Cwd              string             `codec:"cwd"`
	Devices          []string           `codec:"devices"`
	Seccomp          bool               `codec:"seccomp"`
	SeccompProfile   string             `codec:"seccomp_profile"`
	ShmSize          string             `codec:"shm_size"`
	Sysctl           hclutils.MapStrStr `codec:"sysctl"`
	Privileged       bool               `codec:"privileged"`
	PidsLimit        int64              `codec:"pids_limit"`
	PidMode          string             `codec:"pid_mode"`
	Hostname         string             `codec:"hostname"`
	HostDNS          bool               `codec:"host_dns"`
	ImagePullTimeout string             `codec:"image_pull_timeout"`
	ExtraHosts       []string           `codec:"extra_hosts"`
	Entrypoint       []string           `codec:"entrypoint"`
	ReadOnlyRootfs   bool               `codec:"readonly_rootfs"`
	HostNetwork      bool               `codec:"host_network"`
	Auth             RegistryAuth       `codec:"auth"`
	Mounts           []Mount            `codec:"mounts"`
}

TaskConfig contains configuration information for a task that runs with this plugin

type TaskState

type TaskState struct {
	StartedAt     time.Time
	ContainerName string
	StdoutPath    string
	StderrPath    string
}

TaskState is the runtime state which is encoded in the handle returned to Nomad client. This information is needed to rebuild the task state and handler during recovery.

Jump to

Keyboard shortcuts

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