Skip to content

Commit 88b0fc5

Browse files
committed
Merge pull request #137 from vishh/cgroups-path
Adding cgroups path to the Spec.
2 parents a600f41 + 429f936 commit 88b0fc5

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

runtime-config-linux.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,60 @@ Also known as cgroups, they are used to restrict resource usage for a container
131131
cgroups provide controls to restrict cpu, memory, IO, pids and network for the container.
132132
For more information, see the [kernel cgroups documentation](https://www.kernel.org/doc/Documentation/cgroups/cgroups.txt).
133133

134+
The path to the cgroups can to be specified in the Spec via `cgroupsPath`.
135+
`cgroupsPath` is expected to be relative to the cgroups mount point.
136+
If not specified, cgroups will be created under '/'.
137+
Implementations of the Spec can choose to name cgroups in any manner.
138+
The Spec does not include naming schema for cgroups.
139+
The Spec does not support [split hierarchy](https://www.kernel.org/doc/Documentation/cgroups/unified-hierarchy.txt).
140+
The cgroups will be created if they don't exist.
141+
142+
```json
143+
"cgroupsPath": "/myRuntime/myContainer"
144+
```
145+
146+
`cgroupsPath` can be used to either control the cgroups hierarchy for containers or to run a new process in an existing container.
147+
148+
Optionally, cgroups limits can be specified via `resources`.
149+
150+
```json
151+
"resources": {
152+
"disableOOMKiller": false,
153+
"memory": {
154+
"limit": 0,
155+
"reservation": 0,
156+
"swap": 0,
157+
"kernel": 0,
158+
"swappiness": -1
159+
},
160+
"cpu": {
161+
"shares": 0,
162+
"quota": 0,
163+
"period": 0,
164+
"realtimeRuntime": 0,
165+
"realtimePeriod": 0,
166+
"cpus": "",
167+
"mems": ""
168+
},
169+
"blockIO": {
170+
"blkioWeight": 0,
171+
"blkioWeightDevice": "",
172+
"blkioThrottleReadBpsDevice": "",
173+
"blkioThrottleWriteBpsDevice": "",
174+
"blkioThrottleReadIopsDevice": "",
175+
"blkioThrottleWriteIopsDevice": ""
176+
},
177+
"hugepageLimits": null,
178+
"network": {
179+
"classId": "",
180+
"priorities": null
181+
}
182+
}
183+
```
184+
185+
Do not specify `resources` unless limits have to be updated.
186+
For example, to run a new process in an existing container without updating limits, `resources` need not be specified.
187+
134188
## Sysctl
135189

136190
sysctl allows kernel parameters to be modified at runtime for the container.

runtime_config_linux.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ type LinuxRuntime struct {
2424
Sysctl map[string]string `json:"sysctl"`
2525
// Resources contain cgroup information for handling resource constraints
2626
// for the container
27-
Resources Resources `json:"resources"`
27+
Resources *Resources `json:"resources"`
28+
// CgroupsPath specifies the path to cgroups that are created and/or joined by the container.
29+
// The path is expected to be relative to the cgroups mountpoint.
30+
// If resources are specified, the cgroups at CgroupsPath will be updated based on resources.
31+
CgroupsPath string `json:"cgroupsPath"`
2832
// Namespaces contains the namespaces that are created and/or joined by the container
2933
Namespaces []Namespace `json:"namespaces"`
3034
// Devices are a list of device nodes that are created and enabled for the container

0 commit comments

Comments
 (0)