Skip to content

Commit 0ae67b0

Browse files
committed
Adding cgroups path to the Spec.
Signed-off-by: Vishnu Kannan <vishnuk@google.com>
1 parent 138deee commit 0ae67b0

2 files changed

Lines changed: 56 additions & 1 deletion

File tree

runtime-config-linux.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,57 @@ Next parameters can be specified:
130130
Also known as cgroups, they are used to restrict resource usage for a container and handle
131131
device access. cgroups provide controls to restrict cpu, memory, IO, and network for
132132
the container. For more information, see the [kernel cgroups documentation](https://www.kernel.org/doc/Documentation/cgroups/cgroups.txt).
133+
The path to the cgroups can to be specified in the Spec via `cgroupsPath`.
134+
`cgroupsPath` is expected to be relative to the cgroups mount point.
135+
If not specified, cgroups will be created under '/' with the base name of the bundle.
136+
The Spec does not support [split hierarchy](https://www.kernel.org/doc/Documentation/cgroups/unified-hierarchy.txt).
137+
The cgroups will be created if they don't exist.
138+
139+
```json
140+
"cgroupsPath": "/myRuntime/myContainer"
141+
```
142+
143+
`cgroupsPath` can be used to either control the cgroups hierarchy for containers or to run a new process in an existing container.
144+
145+
Optionally, cgroups limits can be specified via `resources`.
146+
147+
```json
148+
"resources": {
149+
"disableOOMKiller": false,
150+
"memory": {
151+
"limit": 0,
152+
"reservation": 0,
153+
"swap": 0,
154+
"kernel": 0,
155+
"swappiness": -1
156+
},
157+
"cpu": {
158+
"shares": 0,
159+
"quota": 0,
160+
"period": 0,
161+
"realtimeRuntime": 0,
162+
"realtimePeriod": 0,
163+
"cpus": "",
164+
"mems": ""
165+
},
166+
"blockIO": {
167+
"blkioWeight": 0,
168+
"blkioWeightDevice": "",
169+
"blkioThrottleReadBpsDevice": "",
170+
"blkioThrottleWriteBpsDevice": "",
171+
"blkioThrottleReadIopsDevice": "",
172+
"blkioThrottleWriteIopsDevice": ""
173+
},
174+
"hugepageLimits": null,
175+
"network": {
176+
"classId": "",
177+
"priorities": null
178+
}
179+
}
180+
```
181+
182+
Do not specify `resources` unless limits have to be updated.
183+
For example, to run a new process in an existing container without updating limits, `resources` need not be specified.
133184

134185
## Sysctl
135186

runtime_config_linux.go

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

0 commit comments

Comments
 (0)