Documentation
¶
Index ¶
- Constants
- func IsNamespaceSupported(ns NamespaceType) bool
- func NsName(ns NamespaceType) string
- type BlockIODevice
- type Capabilities
- type Cgroup
- type Config
- type FreezerState
- type Hook
- type HookList
- type HookName
- type Hooks
- type HostConfig
- type HugepageLimit
- type IDMap
- type Mount
- type MountIDMapping
- type Namespace
- type NamespaceType
- type Namespaces
- type Network
- type Resources
- type Route
- type ThrottleDevice
- type WeightDevice
Constants ¶
View Source
const ( // EXT_COPYUP 是一个指令,用于在将 tmpfs 挂载到某个目录上时,复制该目录的内容。 EXT_COPYUP = 1 << iota )
Variables ¶
This section is empty.
Functions ¶
func IsNamespaceSupported ¶
func IsNamespaceSupported(ns NamespaceType) bool
func NsName ¶
func NsName(ns NamespaceType) string
Types ¶
type BlockIODevice ¶
type Capabilities ¶
type Capabilities struct {
// Bounding is the set of capabilities checked by the kernel.
Bounding []string
// Effective is the set of capabilities checked by the kernel.
Effective []string
// Inheritable is the capabilities preserved across execve.
Inheritable []string
// Permitted is the limiting superset for effective capabilities.
Permitted []string
// Ambient is the ambient set of capabilities that are kept.
Ambient []string
}
type FreezerState ¶
type FreezerState string
const ( Undefined FreezerState = "" Frozen FreezerState = "FROZEN" Thawed FreezerState = "THAWED" )
type HookName ¶
type HookName string
const ( // Prestart commands are executed after the container namespaces are created, // but before the user supplied command is executed from init. // Note: This hook is now deprecated // Prestart commands are called in the Runtime namespace. Prestart HookName = "prestart" // CreateRuntime commands 必须作为create操作的一部分在运行时环境被创建之后,容器进程被更改根文件系统之后调用 // CreateRuntime is called immediately after the deprecated Prestart hook. // CreateRuntime commands are called in the Runtime Namespace. CreateRuntime HookName = "createRuntime" // CreateContainer commands MUST be called as part of the create operation after // the runtime environment has been created but before the pivot_root has been executed. // CreateContainer commands are called in the Container namespace. CreateContainer HookName = "createContainer" // StartContainer commands MUST be called as part of the start operation and before // the container process is started. // StartContainer commands are called in the Container namespace. StartContainer HookName = "startContainer" // Poststart commands are executed after the container init process starts. // Poststart commands are called in the Runtime Namespace. Poststart HookName = "poststart" // Poststop commands are executed after the container init process exits. // Poststop commands are called in the Runtime Namespace. Poststop HookName = "poststop" )
type HostConfig ¶
type HostConfig struct {
*Resources
}
type HugepageLimit ¶
type IDMap ¶
type IDMap struct {
ContainerID int64 `json:"container_id"`
HostID int64 `json:"host_id"`
Size int64 `json:"size"`
}
IDMap represents UID/GID Mappings for User Namespaces.
type Mount ¶
type Mount struct {
Source string `json:"source"`
Destination string `json:"destination"`
Device string `json:"device"`
Fstype string `json:"fstype"`
Flags int `json:"flags"`
// Mount flags that were explicitly cleared in the configuration (meaning
// the user explicitly requested that these flags *not* be set).
ClearedFlags int `json:"cleared_flags"`
// Propagation Flags
PropagationFlags []int `json:"propagation_flags"`
Data string `json:"data"`
Relabel string `json:"relabel"`
// RecAttr represents mount properties to be applied recursively (AT_RECURSIVE), see mount_setattr(2).
RecAttr *unix.MountAttr `json:"rec_attr"`
// Extensions are additional flags that are specific to runc.
Extensions int `json:"extensions"`
IDMapping *MountIDMapping `json:"id_mapping,omitempty"`
}
func (*Mount) IsIDMapped ¶
type MountIDMapping ¶
type MountIDMapping struct {
// Recursive indicates if the mapping needs to be recursive.
Recursive bool `json:"recursive"`
// UserNSPath is a path to a user namespace that indicates the necessary
// id-mappings for MOUNT_ATTR_IDMAP. If set to non-"", UIDMappings and
// GIDMappings must be set to nil.
UserNSPath string `json:"userns_path,omitempty"`
// UIDMappings is the uid mapping set for this mount, to be used with
// MOUNT_ATTR_IDMAP.
UIDMappings []IDMap `json:"uid_mappings,omitempty"`
// GIDMappings is the gid mapping set for this mount, to be used with
// MOUNT_ATTR_IDMAP.
GIDMappings []IDMap `json:"gid_mappings,omitempty"`
}
type Namespace ¶
type Namespace struct {
Type NamespaceType `json:"type"`
Path string `json:"path"`
}
type NamespaceType ¶
type NamespaceType string
const ( NEWNET NamespaceType = "NEWNET" NEWPID NamespaceType = "NEWPID" NEWNS NamespaceType = "NEWNS" NEWUTS NamespaceType = "NEWUTS" NEWIPC NamespaceType = "NEWIPC" NEWUSER NamespaceType = "NEWUSER" NEWCGROUP NamespaceType = "NEWCGROUP" NEWTIME NamespaceType = "NEWTIME" )
func NamespaceTypes ¶
func NamespaceTypes() []NamespaceType
type Namespaces ¶
type Namespaces []Namespace
func (*Namespaces) Add ¶
func (n *Namespaces) Add(t NamespaceType, path string)
func (*Namespaces) Contains ¶
func (n *Namespaces) Contains(t NamespaceType) bool
func (*Namespaces) PathOf ¶
func (n *Namespaces) PathOf(t NamespaceType) string
func (*Namespaces) Remove ¶
func (n *Namespaces) Remove(t NamespaceType) bool
type Network ¶
type Network struct {
// Type sets the networks type, commonly veth and loopback
Type string `json:"type"`
// Name of the network interface
Name string `json:"name"`
// The bridge to use.
Bridge string `json:"bridge"`
// MacAddress contains the MAC address to set on the network interface
MacAddress string `json:"mac_address"`
// Address contains the IPv4 and mask to set on the network interface
Address string `json:"address"`
// Gateway sets the gateway address that is used as the default for the interface
Gateway string `json:"gateway"`
// IPv6Address contains the IPv6 and mask to set on the network interface
IPv6Address string `json:"ipv6_address"`
// IPv6Gateway sets the ipv6 gateway address that is used as the default for the interface
IPv6Gateway string `json:"ipv6_gateway"`
// Mtu sets the mtu value for the interface and will be mirrored on both the host and
// container's interfaces if a pair is created, specifically in the case of type veth
// Note: This does not apply to loopback interfaces.
Mtu int `json:"mtu"`
// TxQueueLen sets the tx_queuelen value for the interface and will be mirrored on both the host and
// container's interfaces if a pair is created, specifically in the case of type veth
// Note: This does not apply to loopback interfaces.
TxQueueLen int `json:"txqueuelen"`
// HostInterfaceName is a unique name of a veth pair that resides on in the host interface of the
// container.
HostInterfaceName string `json:"host_interface_name"`
// HairpinMode specifies if hairpin NAT should be enabled on the virtual interface
// bridge port in the case of type veth
// Note: This is unsupported on some systems.
// Note: This does not apply to loopback interfaces.
HairpinMode bool `json:"hairpin_mode"`
}
type Resources ¶
type Resources struct {
Unified map[string]string `json:"unified"`
CpuIdle *int64 `json:"cpu_idle,omitempty"`
CpuQuota int64 `json:"cpu_quota"`
CpuBurst *uint64 `json:"cpu_burst"`
CpuPeriod uint64 `json:"cpu_period"`
CpuRtRuntime int64 `json:"cpu_rt_quota"`
CpuRtPeriod uint64 `json:"cpu_rt_period"`
CpusetCpus string `json:"cpuset_cpus"`
CpusetMems string `json:"cpuset_mems"`
CpuWeight uint64 `json:"cpu_weight"`
Memory int64 `json:"memory"`
MemoryReservation int64 `json:"memory_reservation"`
MemorySwap int64 `json:"memory_swap"`
MemorySwappiness *int64 `json:"memory_swappiness"`
IoMax string `json:"IoMax"`
IoWeight string `json:"IoWeight"`
IoStat string `json:"IoStat"`
IoPressure string `json:"IoPressure"`
PidsLimit int64 `json:"pids_limit"`
BlkioWeight uint16 `json:"blkio_weight"`
BlkioLeafWeight uint16 `json:"blkio_leaf_weight"`
BlkioWeightDevice []*WeightDevice `json:"blkio_weight_device"`
BlkioThrottleReadBpsDevice []*ThrottleDevice `json:"blkio_throttle_read_bps_device"`
BlkioThrottleWriteBpsDevice []*ThrottleDevice `json:"blkio_throttle_write_bps_device"`
BlkioThrottleReadIOPSDevice []*ThrottleDevice `json:"blkio_throttle_read_iops_device"`
BlkioThrottleWriteIOPSDevice []*ThrottleDevice `json:"blkio_throttle_write_iops_device"`
MemoryCheckBeforeUpdate bool `json:"memory_check_before_update"`
SkipDevices bool `json:"-"`
HugetlbLimit []*HugepageLimit `json:"hugetlb_limit"`
}
type Route ¶
type Route struct {
// Destination specifies the destination IP address and mask in the CIDR form.
Destination string `json:"destination"`
// Source specifies the source IP address and mask in the CIDR form.
Source string `json:"source"`
// Gateway specifies the gateway IP address.
Gateway string `json:"gateway"`
// InterfaceName specifies the device to set this route up for, for example eth0.
InterfaceName string `json:"interface_name"`
}
Route defines a routing table entry.
Routes can be specified to create entries in the routing table as the container is started.
All of destination, source, and gateway should be either IPv4 or IPv6. One of the three options must be present, and omitted entries will use their IP family default for the route table. For IPv4 for example, setting the gateway to 1.2.3.4 and the interface to eth0 will set up a standard destination of 0.0.0.0(or *) when viewed in the route table.
type ThrottleDevice ¶
type ThrottleDevice struct {
BlockIODevice
Rate uint64 `json:"rate"`
}
限制速率的设备:`major:minor`
func NewThrottleDevice ¶
func NewThrottleDevice(major, minor int64, rate uint64) *ThrottleDevice
func (*ThrottleDevice) String ¶
func (td *ThrottleDevice) String() string
func (*ThrottleDevice) StringName ¶
func (td *ThrottleDevice) StringName(name string) string
type WeightDevice ¶
type WeightDevice struct {
BlockIODevice
// 设备的带宽,10-1000
Weight uint16 `json:"weight"`
// 用于决定给定 cgroup 中任务在与 cgroup 的子 cgroup 竞争时
// 具有多少权重的 weight 的等效项。
LeafWeight uint16 `json:"leafWeight"`
}
func NewWeightDevice ¶
func NewWeightDevice(major, minor int64, weight, leafWeight uint16) *WeightDevice
返回一个WeightDevice配置对象的指针
func (*WeightDevice) LeafWeightString ¶
func (wd *WeightDevice) LeafWeightString() string
格式化字符串为了写入cgroup文件
func (*WeightDevice) WeightString ¶
func (wd *WeightDevice) WeightString() string
格式化字符串为了写入cgroup文件
Click to show internal directories.
Click to hide internal directories.