containers

package
v0.0.0-...-dca2ff9 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuntimeNameDocker     string = "docker"
	RuntimeNameContainerd string = "containerd"
	RuntimeNameCRIO       string = "cri-o"
)

Known container runtimes

View Source
const (
	ContainerUnknownState    string = "unknown"
	ContainerCreatedState           = "created"
	ContainerRunningState           = "running"
	ContainerRestartingState        = "restarting"
	ContainerPausedState            = "paused"
	ContainerExitedState            = "exited"
	ContainerDeadState              = "dead"
)

Supported container states

View Source
const (
	ContainerUnknownHealth  string = "unknown"
	ContainerStartingHealth        = "starting"
	ContainerHealthy               = "healthy"
	ContainerUnhealthy             = "unhealthy"
)

Supported container health

View Source
const (
	DefaultNetworkMode string = "default" // bridge
	HostNetworkMode           = "host"
	BridgeNetworkMode         = "bridge"
	NoneNetworkMode           = "none"
	AwsvpcNetworkMode         = "awsvpc"
	UnknownNetworkMode        = "unknown"
)

Container network modes

View Source
const (
	DefaultUTSMode UTSMode = ""
	HostUTSMode            = "host"
	UnknownUTSMode         = "unknown"
)

UTSMode is container UTS modes

View Source
const ContainerEntityName = "container_id"

ContainerEntityName is the entity name applied to all containers

View Source
const ContainerEntityPrefix = ContainerEntityName + EntitySeparator

ContainerEntityPrefix is the prefix that any entity corresponding to a container must have It replaces any prior prefix like <runtime>:// in a pod container status.

View Source
const EntitySeparator = "://"

EntitySeparator is used to separate the entity name from its ID

Variables

This section is empty.

Functions

func BuildEntityName

func BuildEntityName(runtime, id string) string

BuildEntityName builds a valid entity name for a given container runtime and cid.

func BuildTaggerEntityName

func BuildTaggerEntityName(id string) string

BuildTaggerEntityName builds a valid tagger entity name for a given cid.

func ContainerIDForEntity

func ContainerIDForEntity(name string) string

ContainerIDForEntity extracts the container ID portion of a container entity name

func DefaultGateway

func DefaultGateway() (net.IP, error)

DefaultGateway returns the default Docker gateway.

func DefaultHostIPs

func DefaultHostIPs() ([]string, error)

DefaultHostIPs returns the IP addresses bound to the default network interface. The default network interface is the one connected to the network gateway, and it is determined by parsing the routing table file in the proc file system.

func IsEntityName

func IsEntityName(name string) bool

IsEntityName tests whether a given entity name is valid

func ResetSharedFilter

func ResetSharedFilter()

ResetSharedFilter is only to be used in unit tests: it resets the global filter instance to force re-parsing of the configuration.

func SplitEntityName

func SplitEntityName(name string) (string, string)

SplitEntityName returns the prefix and container cid parts of a valid entity name

func SplitImageName

func SplitImageName(image string) (string, string, string, error)

SplitImageName splits a valid image name (from ResolveImageName) and returns:

  • the "long image name" with registry and prefix, without tag
  • the "short image name", without registry, prefix nor tag
  • the image tag if present
  • an error if parsing failed

Types

type Container

type Container struct {
	Type     string
	ID       string
	EntityID string
	Name     string
	Image    string
	ImageID  string
	Created  int64
	State    string
	Health   string
	Pids     []int32
	Excluded bool

	CPULimit       float64
	SoftMemLimit   uint64
	KernMemUsage   uint64
	MemLimit       uint64
	MemFailCnt     uint64
	CPUNrThrottled uint64
	CPU            *metrics.CgroupTimesStat
	Memory         *metrics.CgroupMemStat
	IO             *metrics.CgroupIOStat
	Network        metrics.ContainerNetStats
	AddressList    []NetworkAddress
	StartedAt      int64
	ThreadCount    uint64
	ThreadLimit    uint64
	// contains filtered or unexported fields
}

Container represents a single container on a machine and includes Cgroup-level statistics about the container.

func (*Container) FillCgroupLimits

func (c *Container) FillCgroupLimits() error

FillCgroupLimits fills the resource limits for a Container, based on the associated cgroups. This can be called once if the limits are assumed constant.

func (*Container) FillCgroupMetrics

func (c *Container) FillCgroupMetrics() error

FillCgroupMetrics fills the performance metrics for a Container, based on the associated cgroups. Network metrics are handled by FillNetworkMetrics

func (*Container) FillNetworkMetrics

func (c *Container) FillNetworkMetrics(networks map[string]string) error

FillNetworkMetrics fills the network metrics for a Container, based on the associated cgroups.

func (*Container) SetCgroups

func (c *Container) SetCgroups(cgroup *metrics.ContainerCgroup) error

SetCgroups has to be called when creating the Container, in order to be able to enable FillCgroupMetrics and FillNetworkMetrics to works

type Filter

type Filter struct {
	Enabled        bool
	ImageWhitelist []*regexp.Regexp
	NameWhitelist  []*regexp.Regexp
	ImageBlacklist []*regexp.Regexp
	NameBlacklist  []*regexp.Regexp
}

Filter holds the state for the container filtering logic

func GetSharedFilter

func GetSharedFilter() (*Filter, error)

GetSharedFilter allows to share the result of NewFilterFromConfig for several user classes

func NewFilter

func NewFilter(whitelist, blacklist []string) (*Filter, error)

NewFilter creates a new container filter from a two slices of regexp patterns for a whitelist and blacklist. Each pattern should have the following format: "field:pattern" where field can be: [image, name]. An error is returned if any of the expression don't compile.

func NewFilterFromConfig

func NewFilterFromConfig() (*Filter, error)

NewFilterFromConfig creates a new container filter, sourcing patterns from the pkg/config options

func NewFilterFromConfigIncludePause

func NewFilterFromConfigIncludePause() (*Filter, error)

NewFilterFromConfigIncludePause creates a new container filter, sourcing patterns from the pkg/config options, but ignoring the exclude_pause_container option, for use in autodiscovery

func (Filter) IsExcluded

func (cf Filter) IsExcluded(containerName, containerImage string) bool

IsExcluded returns a bool indicating if the container should be excluded based on the filters in the containerFilter instance.

type NetworkAddress

type NetworkAddress struct {
	IP       net.IP
	Port     int
	Protocol string
}

NetworkAddress represents a tuple IP/Port/Protocol

type UTSMode

type UTSMode string

UTSMode is container UTS modes

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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