|
| 1 | +// +build linux |
| 2 | + |
| 3 | +package specs |
| 4 | + |
| 5 | +// LinuxSpec is the full specification for linux containers. |
| 6 | +type LinuxSpec struct { |
| 7 | + Spec |
| 8 | + // Linux is platform specific configuration for linux based containers. |
| 9 | + Linux Linux `json:"linux"` |
| 10 | +} |
| 11 | + |
| 12 | +// Linux contains platform specific configuration for linux based containers. |
| 13 | +type Linux struct { |
| 14 | + // UidMapping specifies user mappings for supporting user namespaces on linux. |
| 15 | + UidMappings []IDMapping `json:"uidMappings"` |
| 16 | + // UidMapping specifies group mappings for supporting user namespaces on linux. |
| 17 | + GidMappings []IDMapping `json:"gidMappings"` |
| 18 | + // Rlimits specifies rlimit options to apply to the container's process. |
| 19 | + Rlimits []Rlimit `json:"rlimits"` |
| 20 | + // SystemProperties are a set of key value pairs that are set for the container on start. |
| 21 | + SystemProperties map[string]string `json:"systemProperties"` |
| 22 | + // Resources contain cgroup information for handling resource constraints |
| 23 | + // for the container. |
| 24 | + Resources Resources `json:"resources"` |
| 25 | + // Namespaces contains the namespaces that are created and/or joined by the container. |
| 26 | + Namespaces []Namespace `json:"namespaces"` |
| 27 | + // Capabilities are linux capabilities that are kept for the container. |
| 28 | + Capabilities []string `json:"capabilities"` |
| 29 | + // Devices are a list of device nodes that are created and enabled for the container. |
| 30 | + Devices []string `json:"devices"` |
| 31 | +} |
| 32 | + |
| 33 | +// User specifies linux specific user and group information for the container's |
| 34 | +// main process. |
| 35 | +type User struct { |
| 36 | + // Uid is the user id. |
| 37 | + Uid int32 `json:"uid"` |
| 38 | + // Gid is the group id. |
| 39 | + Gid int32 `json:"gid"` |
| 40 | + // AdditionalGids are additional group ids set the the container's process. |
| 41 | + AdditionalGids []int32 `json:"additionalGids"` |
| 42 | +} |
| 43 | + |
| 44 | +// Namespace is the configuration for a linux namespace. |
| 45 | +type Namespace struct { |
| 46 | + // Type is the type of linux namespace. |
| 47 | + Type string `json:"type"` |
| 48 | + // Path is a path to an existing namespace persisted on disk that can be joined |
| 49 | + // and is of the same type. |
| 50 | + Path string `json:"path"` |
| 51 | +} |
| 52 | + |
| 53 | +// IDMapping specifies uid/gid mappings. |
| 54 | +type IDMapping struct { |
| 55 | + // From is the uid/gid of the host user or group. |
| 56 | + From int32 `json:"from"` |
| 57 | + // To is the uid/gid of the container's user or group. |
| 58 | + To int32 `json:"to"` |
| 59 | + // Count is how many uid/gids to map after To. |
| 60 | + Count int32 `json:"count"` |
| 61 | +} |
| 62 | + |
| 63 | +// Rlimit type and restrictions. |
| 64 | +type Rlimit struct { |
| 65 | + // Type of the rlimit to set. |
| 66 | + Type int `json:"type"` |
| 67 | + // Hard is the hard limit for the specified type. |
| 68 | + Hard uint64 `json:"hard"` |
| 69 | + // Soft is the soft limit for the specified type. |
| 70 | + Soft uint64 `json:"soft"` |
| 71 | +} |
| 72 | + |
| 73 | +type HugepageLimit struct { |
| 74 | + Pagesize string `json:"pageSize"` |
| 75 | + Limit int `json:"limit"` |
| 76 | +} |
| 77 | + |
| 78 | +type InterfacePriority struct { |
| 79 | + // Name is the name of the network interface. |
| 80 | + Name string `json:"name"` |
| 81 | + // Priority for the interface. |
| 82 | + Priority int64 `json:"priority"` |
| 83 | +} |
| 84 | + |
| 85 | +type BlockIO struct { |
| 86 | + // Specifies per cgroup weight, range is from 10 to 1000. |
| 87 | + Weight int64 `json:"blkioWeight"` |
| 88 | + // Weight per cgroup per device, can override BlkioWeight. |
| 89 | + WeightDevice string `json:"blkioWeightDevice"` |
| 90 | + // IO read rate limit per cgroup per device, bytes per second. |
| 91 | + ThrottleReadBpsDevice string `json:"blkioThrottleReadBpsDevice"` |
| 92 | + // IO write rate limit per cgroup per divice, bytes per second. |
| 93 | + ThrottleWriteBpsDevice string `json:"blkioThrottleWriteBpsDevice"` |
| 94 | + // IO read rate limit per cgroup per device, IO per second. |
| 95 | + ThrottleReadIOpsDevice string `json:"blkioThrottleReadIopsDevice"` |
| 96 | + // IO write rate limit per cgroup per device, IO per second. |
| 97 | + ThrottleWriteIOpsDevice string `json:"blkioThrottleWriteIopsDevice"` |
| 98 | +} |
| 99 | + |
| 100 | +type Memory struct { |
| 101 | + // Memory limit (in bytes) |
| 102 | + Limit int64 `json:"limit"` |
| 103 | + // Memory reservation or soft_limit (in bytes) |
| 104 | + Reservation int64 `json:"reservation"` |
| 105 | + // Total memory usage (memory + swap); set `-1' to disable swap |
| 106 | + Swap int64 `json:"swap"` |
| 107 | + // Kernel memory limit (in bytes) |
| 108 | + Kernel int64 `json:"kernel"` |
| 109 | +} |
| 110 | + |
| 111 | +type CPU struct { |
| 112 | + // CPU shares (relative weight vs. other cgroups with cpu shares). |
| 113 | + Shares int64 `json:"shares"` |
| 114 | + // CPU hardcap limit (in usecs). Allowed cpu time in a given period. |
| 115 | + Quota int64 `json:"quota"` |
| 116 | + // CPU period to be used for hardcapping (in usecs). 0 to use system default. |
| 117 | + Period int64 `json:"period"` |
| 118 | + // How many time CPU will use in realtime scheduling (in usecs). |
| 119 | + RealtimeRuntime int64 `json:"realtimeRuntime"` |
| 120 | + // CPU period to be used for realtime scheduling (in usecs). |
| 121 | + RealtimePeriod int64 `json:"realtimePeriod"` |
| 122 | + // CPU to use within the cpuset. |
| 123 | + Cpus string `json:"cpus"` |
| 124 | + // MEM to use within the cpuset. |
| 125 | + Mems string `json:"mems"` |
| 126 | +} |
| 127 | + |
| 128 | +type Network struct { |
| 129 | + // Set class identifier for container's network packets. |
| 130 | + ClassID string `json:"classId"` |
| 131 | + // Set priority of network traffic for container. |
| 132 | + Priorities []InterfacePriority `json:"priorities"` |
| 133 | +} |
| 134 | + |
| 135 | +type Resources struct { |
| 136 | + // DisableOOMKiller disables the OOM killer for out of memory conditions. |
| 137 | + DisableOOMKiller bool `json:"disableOOMKiller"` |
| 138 | + // Memory restriction configuration. |
| 139 | + Memory Memory `json:"memory"` |
| 140 | + // CPU resource restriction configuration. |
| 141 | + CPU CPU `json:"cpu"` |
| 142 | + // BlockIO restriction configuration. |
| 143 | + BlockIO BlockIO `json:"blockIO"` |
| 144 | + // Hugetlb limit (in bytes) |
| 145 | + HugepageLimits []HugepageLimit `json:"hugepageLimits"` |
| 146 | + // Network restriction configuration. |
| 147 | + Network Network `json:"network"` |
| 148 | +} |
0 commit comments