Documentation
¶
Index ¶
- Constants
- type CPUStats
- type Container
- type ContainerConfiguration
- type DecryptConfig
- type DeviceMapping
- type EndpointSettings
- type Event
- type EventAction
- type EventType
- type Hook
- type HookType
- type HostConfig
- type IOConfig
- type IOStats
- type Image
- type LogConfiguration
- type LogDriver
- type LogDriverConfiguration
- type LogMode
- type LogModeConfiguration
- type MemoryStats
- type Metrics
- type MountPoint
- type NetworkMode
- type NetworkSettings
- type PolicyType
- type PortMapping
- type Resources
- type RestartPolicy
- type Runtime
- type State
- type Status
- type StopOpts
- type UpdateOpts
Constants ¶
const ( // NetworkModeBridge means that the container is connected to the default bridge network interface of the engine and is assigned an IP NetworkModeBridge NetworkMode = "bridge" // NetworkModeHost means that the container shares the network stack of the host NetworkModeHost NetworkMode = "host" // RuntimeTypeV1 is the runtime type name for containerd shim interface v1 version. RuntimeTypeV1 Runtime = "io.containerd.runtime.v1.linux" // RuntimeTypeV2runscV1 is the runtime type name for gVisor containerd shim implement the shim v2 api. RuntimeTypeV2runscV1 Runtime = "io.containerd.runsc.v1" // RuntimeTypeV2kataV2 is the runtime type name for kata-runtime containerd shim implement the shim v2 api. RuntimeTypeV2kataV2 Runtime = "io.containerd.kata.v2" // RuntimeTypeV2runcV1 is the runtime type name for runc containerd shim implement the shim v2 api. RuntimeTypeV2runcV1 Runtime = "io.containerd.runc.v1" // RuntimeTypeV2runcV2 is the version 2 runtime type name for runc containerd shim implement the shim v2 api. RuntimeTypeV2runcV2 Runtime = "io.containerd.runc.v2" )
const ( // RPrivatePropagationMode represents mount propagation rprivate. RPrivatePropagationMode = "rprivate" // PrivatePropagationMode represents mount propagation private. PrivatePropagationMode = "private" RSharedPropagationMode = "rshared" SharedPropagationMode = "shared" // RSlavePropagationMode represents mount propagation rslave. RSlavePropagationMode = "rslave" // SlavePropagationMode represents mount propagation slave. SlavePropagationMode = "slave" )
const MemoryUnlimited = "-1"
MemoryUnlimited - no memory constraint
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CPUStats ¶
type CPUStats struct {
// Total represents the total system CPU time in nanoseconds.
Total uint64 `json:"total,omitempty"`
// Used represents the container's processes CPU time in nanoseconds.
Used uint64 `json:"used"`
}
CPUStats represents the CPU measurements of a container.
type Container ¶
type Container struct {
sync.Mutex
// ID the ID is system-internally generated
ID string `json:"container_id"`
// Name is a user-defined name of the container - the ID is set if none is provided
Name string `json:"container_name"`
// Image is the image information for the container
Image Image `json:"image"`
// DomainName is the domain name set inside the container
DomainName string `json:"domain_name"`
// HostName is the hostname for the container
HostName string `json:"host_name"`
// ResolvConfPath is the path to the container's resolv.conf file
ResolvConfPath string `json:"resolv_conf_path,omitempty"`
// HostsPath is the path to the container's hosts file
HostsPath string `json:"hosts_path,omitempty"`
// HostnamePath is the path to the container's hostname file
HostnamePath string `json:"hostname_path,omitempty"`
// Mounts is the mounts for the container
Mounts []MountPoint `json:"mount_points"`
// Hooks is to perform on container start/stop, etc.
Hooks []Hook `json:"hooks"`
// Config is the configuration of the container's root process
Config *ContainerConfiguration `json:"config"`
// HostConfig is the host configuration for the container
HostConfig *HostConfig `json:"host_config"`
// IOConfig is the IO configuration for the container
IOConfig *IOConfig `json:"io_config"`
// NetworkSettings is the network settings for the container
NetworkSettings *NetworkSettings `json:"network_settings"`
// State is the container's state
State *State `json:"state"`
// Created is the time of the container's creation
Created string `json:"created,omitempty"`
// RestartCount is the metric for the container showing how many restart retries have been performed on it
RestartCount int `json:"restart_count"`
// ManuallyStopped is the flag indicating whether the container has been manually stopped or internally by the system
ManuallyStopped bool `json:"manually_stopped"`
// StartedSuccessfullyBefore is the flag indicating if the container has ever been started successfully before
StartedSuccessfullyBefore bool `json:"started_successfully_before"`
}
Container represents the container instance
type ContainerConfiguration ¶
type ContainerConfiguration struct {
Env []string `json:"env,omitempty"`
Cmd []string `json:"cmd,omitempty"`
}
ContainerConfiguration holds environment variables for the containers
type DecryptConfig ¶
type DecryptConfig struct {
Keys []string `json:"keys,omitempty"`
Recipients []string `json:"recipients,omitempty"`
}
DecryptConfig holds the data needed for image decryption
type DeviceMapping ¶
type DeviceMapping struct {
PathOnHost string `json:"path_on_host"`
PathInContainer string `json:"path_in_container"`
CgroupPermissions string `json:"cgroup_permissions"` //rwm
}
DeviceMapping represents a device mapping between the host and the container
type EndpointSettings ¶
type EndpointSettings struct {
ID string `json:"id,omitempty"`
Gateway string `json:"gateway"`
IPAddress string `json:"ip_address"`
MacAddress string `json:"mac_address"`
NetworkID string `json:"network_id,omitempty"`
}
EndpointSettings represents an endpoint settings for connecting to a specific network
type Event ¶
type Event struct {
// the EventType
Type EventType `json:"type"`
// the EventAction
Action EventAction `json:"action"`
// the container instance that changed
Source Container `json:"source,omitempty"`
// time
Time int64 `json:"time,omitempty"`
}
Event represents an emitted event
type EventAction ¶
type EventAction string
EventAction represents the event's action
const ( // EventActionContainersCreated is used when a container is created EventActionContainersCreated EventAction = "created" // EventActionContainersRunning is used when a container is running EventActionContainersRunning EventAction = "running" // EventActionContainersPaused is used when a container is paused EventActionContainersPaused EventAction = "paused" // EventActionContainersResumed is used when a container is resumed EventActionContainersResumed EventAction = "resumed" // EventActionContainersStopped is used when a container is stopped EventActionContainersStopped EventAction = "stopped" // EventActionContainersExited is used when a container is exited EventActionContainersExited EventAction = "exited" // EventActionContainersRemoved is used when a container is removed EventActionContainersRemoved EventAction = "removed" // EventActionContainersRenamed is used when a container is renamed EventActionContainersRenamed EventAction = "renamed" // EventActionContainersUpdated is used when a container is updated EventActionContainersUpdated EventAction = "updated" // EventActionContainersUnknown is used when an unknown action has been performed EventActionContainersUnknown EventAction = "unknown" )
type EventType ¶
type EventType string
EventType represents the event's type
const ( // EventTypeContainers is an event type for the containers EventTypeContainers EventType = "containers" )
type Hook ¶
type Hook struct {
// Path to the executable logic relevant for this hook's execution
Path string `json:"path"`
// Args is the hook arguments
Args []string `json:"args"`
// Env is the environmental variables needed for the hook's execution
Env []string `json:"env"`
// Timeout is the timeout for the hook's execution
Timeout int `json:"timeout"`
// Type is the type of the hook
Type HookType `json:"type"` //prestart, poststart, poststop
}
Hook enables injection of actions to be performed throughout different stages of the container's OCI lifecycle
type HookType ¶
type HookType int
HookType represents a hook type
constants for the supported hook types
type HostConfig ¶
type HostConfig struct {
Devices []DeviceMapping `json:"devices"`
NetworkMode NetworkMode `json:"network_mode"`
Privileged bool `json:"privileged"`
RestartPolicy *RestartPolicy `json:"restart_policy"`
Runtime Runtime `json:"runtime"`
ExtraHosts []string `json:"extra_hosts"`
ExtraCapabilities []string `json:"extra_capabilities"`
PortMappings []PortMapping `json:"port_mappings"`
LogConfig *LogConfiguration `json:"log_config"`
Resources *Resources `json:"resources"`
}
HostConfig defines the resources, behavior, etc. that the host must manage on the container
type IOConfig ¶
type IOConfig struct {
// Whether to attach to `stderr`.
AttachStderr bool `json:"attach_stderr"`
// Whether to attach to `stdin`.
AttachStdin bool `json:"attach_stdin"`
// Whether to attach to `stdout`.
AttachStdout bool `json:"attach_stdout"`
// Open `stdin`
OpenStdin bool `json:"open_stdin"`
// Close `stdin` after one attached client disconnects
StdinOnce bool `json:"stdin_once"`
// Attach standard streams to a TTY, including `stdin` if it is not closed.
Tty bool `json:"tty"`
}
IOConfig represents a container's IO configuration
type IOStats ¶
type IOStats struct {
// Read represents the number of bytes that has been read.
Read uint64 `json:"read"`
// Write represents the number of bytes that has been written.
Write uint64 `json:"write"`
}
IOStats represents the IO measurements of a container.
type Image ¶
type Image struct {
Name string `json:"name"`
DecryptConfig *DecryptConfig `json:"decrypt_config,omitempty"`
}
Image represents an image information for the container
type LogConfiguration ¶
type LogConfiguration struct {
DriverConfig *LogDriverConfiguration `json:"driver_config,omitempty"`
ModeConfig *LogModeConfiguration `json:"mode_config,omitempty"`
}
LogConfiguration represents log configuration
type LogDriverConfiguration ¶
type LogDriverConfiguration struct {
Type LogDriver `json:"type,omitempty"`
// driver config - applicable for json-file only
MaxFiles int `json:"max_files,omitempty"`
MaxSize string `json:"max_size,omitempty"`
RootDir string `json:"root_dir,omitempty"`
}
LogDriverConfiguration represents a log driver configuration
type LogModeConfiguration ¶
type LogModeConfiguration struct {
Mode LogMode `json:"mode,omitempty"`
// applicable for non-blocking mode
MaxBufferSize string `json:"max_buffer_size,omitempty"`
}
LogModeConfiguration represents log mode configuration
type MemoryStats ¶
type MemoryStats struct {
// Total represents the container memory limit in bytes.
// If container does not have memory limit set, machine memory is used.
Total uint64 `json:"total"`
// Used represents the memory used by a container in bytes.
Used uint64 `json:"used"`
}
MemoryStats represents the memory measurements of a container.
type Metrics ¶
type Metrics struct {
CPU *CPUStats `json:"cpu,omitempty"`
Memory *MemoryStats `json:"memory,omitempty"`
IO *IOStats `json:"io,omitempty"`
Network *IOStats `json:"network,omitempty"`
Timestamp time.Time `json:"timestamp"`
PIDs uint64 `json:"pids,omitempty"`
}
Metrics represents all measurements of a container.
type MountPoint ¶
type MountPoint struct {
Destination string `json:"destination"` // path in container
Source string `json:"source"` // path in host
PropagationMode string `json:"propagation_mode"` // propagation mode to use in the spec
}
MountPoint specifies a mount point from the host to the container
type NetworkMode ¶
type NetworkMode string
NetworkMode represents the network mode for the container
type NetworkSettings ¶
type NetworkSettings struct {
// networks
Networks map[string]*EndpointSettings `json:"networks"`
// underlying sandbox id
SandboxID string `json:"sandbox_id,omitempty"`
// underlying sandbox key
SandboxKey string `json:"sandbox_key,omitempty"`
// the underlying network controller id
NetworkControllerID string `json:"network_controller_id,omitempty"`
}
NetworkSettings container network settings
type PolicyType ¶
type PolicyType string
PolicyType represents a container's policy type
const ( No PolicyType = "no" Always PolicyType = "always" UnlessStopped PolicyType = "unless-stopped" OnFailure PolicyType = "on-failure" )
constants for the supported policy types
type PortMapping ¶
type PortMapping struct {
// Protocol
Proto string `json:"proto"`
// Container port
ContainerPort uint16 `json:"container_port"`
// Host IP
HostIP string `json:"host_ip"`
// Host port
HostPort uint16 `json:"host_port"`
// Host port
HostPortEnd uint16 `json:"host_port_end"`
}
PortMapping mappings from the host to a container
type Resources ¶
type Resources struct {
// Hard memory usage limit
Memory string `json:"memory,omitempty"`
// Soft memory usage limit
MemoryReservation string `json:"memory_reservation,omitempty"`
// Swap + memory usage limit
MemorySwap string `json:"memory_swap,omitempty"`
}
Resources of the container
type RestartPolicy ¶
type RestartPolicy struct {
// maximum retry count
MaximumRetryCount int `json:"maximum_retry_count"`
// retry timeout in seconds
RetryTimeout time.Duration `json:"retry_timeout"`
// type
Type PolicyType `json:"type"`
}
RestartPolicy represents a container's restart policy
type State ¶
type State struct {
// Pid represents the container's process's PID
Pid int64 `json:"pid"`
// StartedAt defines the time when this container was last started
StartedAt string `json:"started_at"`
// Error indicates whether there was a problem that has occurred while changing the state of a container
Error string `json:"error"`
// ExitCode represents the last exit code of the container's internal root process
ExitCode int64 `json:"exit_code"`
// FinishedAt defines a timestamp of the last container's exit
FinishedAt string `json:"finished_at"`
// Exited defines whether the container has exited on its own for some reason - daemon reboot or internal error - distinguishes between manual stop and internal exit
Exited bool `json:"exited"`
// Dead identifies whether the container is dead
Dead bool `json:"dead"`
// Restarting identifies whether the container is currently restarting
Restarting bool `json:"restarting"`
// Paused indicates whether this container is paused
Paused bool `json:"paused"`
// Running indicates whether this container is running
// Note: Paused and running are not mutually exclusive as pausing actually requires the process to be running - it's only 'freezed' but still running
Running bool `json:"running"`
// OOMKilled indicates whether the container is killed due to out of memory
OOMKilled bool `json:"oomKilled"`
// Status represents the status of this container
Status Status `json:"status"`
}
State represents a container's state
type Status ¶
type Status int
Status represents a container's status
constants for the supported statuses
type StopOpts ¶
type StopOpts struct {
// Timeout period in seconds to gracefully stop the container.
Timeout int64 `json:"timeout,omitempty"`
// Force determines whether a SIGKILL signal will be send to the container's process if it does not finish within the timeout specified.
Force bool `json:"force,omitempty"`
// Signal to be send to the container's process. Signal could be specified by using their names or numbers, e.g. SIGINT or 2.
Signal string `json:"signal,omitempty"`
}
StopOpts represent options for stoping a container.
type UpdateOpts ¶
type UpdateOpts struct {
// RestartPolicy to be used for the container.
RestartPolicy *RestartPolicy `json:"restart_policy"`
// Resources of the container.
Resources *Resources `json:"resources"`
}
UpdateOpts represent options for updating a container.