Skip to content

Commit c498abd

Browse files
committed
docs: add changlog doc of cri api
Signed-off-by: Starnop <[email protected]>
1 parent f29da94 commit c498abd

File tree

1 file changed

+307
-0
lines changed

1 file changed

+307
-0
lines changed
Lines changed: 307 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
# CRI API CHANGELOG
2+
3+
* [Overview](#overview "Overview")
4+
* [Requirements](#requirements "Requirements")
5+
* [The Changes Of CRI API](#the-changes-of-cri-api "The changes of CRI API")
6+
* [UpdateContainerResources](#updatecontainerresources "UpdateContainerResources()")
7+
* [ContainerStatus](#containerstatus "ContainerStatus()")
8+
* [ImageStatus](#imagestatus "ImageStatus()")
9+
* [CreateContainer](#createcontainer "CreateContainer()")
10+
* [RemoveVolume](#removevolume "RemoveVolume()")
11+
* [Pull Request](#pull-request)
12+
13+
## Overview
14+
15+
Because the CRI interface of Kubernetes cannot meet the customized development of Kubelet at present, it is necessary to provide the required functions of Kubelet by extending the API of CRI. On top of CRI's existing functionality, use the field extension or add method to make CRI meet the requirements.
16+
17+
Kubernetes Version: V1.10.0+
18+
19+
## Requirements
20+
21+
1. Support the ability to update the container diskquota.
22+
- Scenario:
23+
- Limits the directory size within the container.
24+
2. Support the ability to acquire the volumes of the Image.
25+
- Scenario:
26+
- In the Upgrade process, the volumes and mountpoints of the old container need to be read. At the same time, the volumes in the new image also need to be read. If the mount point is the same, the volumes in the new image cover the volumes in the old container.
27+
3. Support to the ability to acquire the volumes of the Container.
28+
- Scenario:
29+
- In the Upgrade process, the volumes of the new container needs to remain consistent with that of the old container, so the volumes of the old container needs to be read.
30+
31+
# The Changes Of CRI API
32+
33+
## UpdateContainerResources
34+
35+
### What To Solve?
36+
37+
1. Support the ability to update the container quotadir.
38+
39+
### Modification
40+
41+
+ Add the DiskQuota field in LinuxContainerResources, referring to the definition of Resources in mobyfor better compatibility. The new fields are as follows:
42+
43+
```
44+
type LinuxContainerResources struct {
45+
......
46+
//***New Fields***//
47+
// DiskQuota constrains the disk. Default: none (not specified)
48+
DiskQuota map[string]string `protobuf:"bytes,100,req,name=disk_quota,json=diskQuota,proto3" json:"disk_quota,omitempty"`
49+
// Block IO weight (relative weight vs. other containers)
50+
BlkioWeight uint16 `protobuf:"bytes,101,opt,name=blkio_weight,json=blkioWeight,proto3" json:"blkio_weight,omitempty"`
51+
BlkioWeightDevice []*WeightDevice `protobuf:"bytes,102,req,name=blkio_weight_device,json=blkioWeightDevice,proto3" json:"blkio_weight_device,omitempty"`
52+
BlkioDeviceReadBps []*ThrottleDevice `protobuf:"bytes,103,req,name=blkio_device_read_bps,json=blkioDeviceReadBps,proto3" json:"blkio_device_read_bps,omitempty"`
53+
BlkioDeviceWriteBps []*ThrottleDevice `protobuf:"bytes,104,req,name=blkio_device_write_bps,json=blkioDeviceWriteBps,proto3" json:"blkio_device_write_bps,omitempty"`
54+
BlkioDeviceReadIOps []*ThrottleDevice `protobuf:"bytes,105,req,name=blkio_device_read_IOps,json=blkioDeviceReadIOps,proto3" json:"blkio_device_read_IOps,omitempty"`
55+
BlkioDeviceWriteIOps []*ThrottleDevice `protobuf:"bytes,106,req,name=blkio_device_write_IOps,json=blkioDeviceWriteIOps,proto3" json:"blkio_device_write_IOps,omitempty"`
56+
// Kernel memory limit (in bytes)
57+
KernelMemory int64 `protobuf:"bytes,107,opt,name=kernel_memory,json=kernelMemory,proto3" json:"kernel_memory,omitempty"`
58+
// Memory soft limit (in bytes)
59+
MemoryReservation int64 `protobuf:"bytes,108,opt,name=memory_reservation,json=memoryReservation,proto3" json:"memory_reservation,omitempty"`
60+
// Tuning container memory swappiness behaviour
61+
MemorySwappiness int64 `protobuf:"bytes,109,opt,name=memory_swappiness,json=memorySwappiness,proto3" json:"memory_swappiness,omitempty"`
62+
// List of ulimits to be set in the container
63+
Ulimits []*Ulimit `protobuf:"bytes,110,opt,name=ulimits,json=ulimits,proto3" json:"ulimits,omitempty"`
64+
65+
}
66+
67+
// WeightDevice is a structure that holds device:weight pair
68+
type WeightDevice struct {
69+
// Path of weightdevice.
70+
Path string `protobuf:"bytes,1,opt,name=path,json=path,proto3" json:"path,omitempty"`
71+
// Weight of weightdevice.
72+
Weight uint16 `protobuf:"bytes,2,opt,name=weight,json=weight,proto3" json:"weight,omitempty"`
73+
}
74+
75+
// ThrottleDevice is a structure that holds device:rate_per_second pair
76+
type ThrottleDevice struct {
77+
// Path of throttledevice.
78+
Path string `protobuf:"bytes,1,opt,name=path,json=path,proto3" json:"path,omitempty"`
79+
// Rate of throttledevice.
80+
Rate uint64 `protobuf:"bytes,1,opt,name=rate,json=rate,proto3" json:"rate,omitempty"`
81+
}
82+
83+
// Ulimit is a human friendly version of Rlimit.
84+
type Ulimit struct {
85+
// Name of ulimit.
86+
Name string `protobuf:"bytes,1,opt,name=name,json=name,proto3" json:"name,omitempty"`
87+
// Hard of ulimit.
88+
Hard int64 `protobuf:"bytes,2,opt,name=hard,json=hard,proto3" json:"hard,omitempty"`
89+
// Soft of Ulimit.
90+
Soft int64 `protobuf:"bytes,3,opt,name=soft,json=soft,proto3" json:"soft,omitempty"`
91+
}
92+
```
93+
94+
The changes need to be made in the proto file are as follows:
95+
96+
```
97+
message LinuxContainerResources {
98+
......
99+
//***New Fields***//
100+
// DiskQuota constrains the disk
101+
map<string,string> disk_quota = 100;
102+
// Block IO weight (relative weight vs. other containers)
103+
uint32 blkio_weight = 101;
104+
repeated WeightDevice blkio_weight_device = 102;
105+
repeated ThrottleDevice blkio_device_read_bps = 103;
106+
repeated ThrottleDevice blkio_device_write_bps = 104;
107+
repeated ThrottleDevice blkio_device_read_IOps = 105;
108+
repeated ThrottleDevice blkio_device_write_IOps = 106;
109+
// Kernel memory limit (in bytes)
110+
int64 kernel_memory = 107;
111+
// Memory soft limit (in bytes)
112+
int64 memory_reservation = 108;
113+
// Tuning container memory swappiness behaviour
114+
Int64Value memory_swappiness = 109;
115+
// List of ulimits to be set in the container
116+
repeated Ulimit ulimits = 110;
117+
}
118+
119+
// WeightDevice is a structure that holds device:weight pair
120+
message WeightDevice {
121+
// Path of weightdevice.
122+
string path = 1;
123+
// Weight of weightdevice.
124+
uint32 Weight = 2;
125+
}
126+
127+
// ThrottleDevice is a structure that holds device:rate_per_second pair
128+
message ThrottleDevice {
129+
// Path of throttledevice.
130+
string path = 1;
131+
// Rate of throttledevice.
132+
uint64 rate = 2;
133+
}
134+
135+
// Ulimit is a human friendly version of Rlimit.
136+
message Ulimit {
137+
// Name of ulimit.
138+
string name = 1;
139+
// Hard limit of ulimit.
140+
int64 hard = 2;
141+
// Soft limit of Ulimit.
142+
int64 soft = 3;
143+
}
144+
```
145+
146+
## ContainerStatus
147+
148+
### What To Solve?
149+
150+
+ Support to the ability to acquire the volumes of the Container.
151+
+ Support to the ability to acquire the Resource of the Container.
152+
+ Pass the quotaID generated when the container is created for disk reuse.
153+
154+
### Modification
155+
156+
+ The ContainerStatus struct is used only in ContainerStatusResponse in CRI, so the volumes of the container can be obtained by directly adding volume field to the ContainerStatus struct.
157+
+ Add Resources field to support the retrieval of container's resource.
158+
+ When get ContainerStatus, the return object of ContainerStatusResponse will contain the field of QuotaId .
159+
160+
```
161+
// ContainerStatus represents the status of a container.
162+
type ContainerStatus struct {
163+
......
164+
//***New Fields***//
165+
// Volumes of container
166+
Volumes map[string]struct{} `protobuf:"bytes,100,opt,name=volumes,json=volumes" json:"volumes,omitempty"`
167+
// Resources specification for the container
168+
Resources *LinuxContainerResources `protobuf:"bytes,101,opt,name=resources" json:"resources,omitempty"`
169+
// QuotaId of the container
170+
QuotaId string `protobuf:"bytes,102,opt,name=quota_id,json=quotaId,proto3" json:"quota_id,omitempty"`
171+
}
172+
```
173+
174+
The changes need to be made in the proto file are as follows:
175+
176+
```
177+
// ContainerStatus represents the status of a container.
178+
message ContainerStatus {
179+
......
180+
//***New Fields***//
181+
// Volumes of container
182+
map<string, Volume> volumes= 100;
183+
// Resources specification for the container
184+
LinuxContainerResources resources = 101;
185+
// QuotaId of the container
186+
string quota_id = 102;
187+
}
188+
189+
message Volume {
190+
}
191+
```
192+
193+
## ImageStatus
194+
195+
### What To Solve?
196+
197+
+ Support the ability to acquire the volumes of the Image.
198+
199+
### Modification
200+
201+
+ Add volumes field in the Image struct.
202+
203+
```
204+
// Basic information about a container image.
205+
type Image struct {
206+
......
207+
//***New Fields***//
208+
// Volumes of image
209+
Volumes map[string]struct{} `protobuf:"bytes,7,opt,name=volumes,json=volumes" json:"volumes,omitempty"`
210+
}
211+
```
212+
213+
The changes need to be made in the proto file are as follows:
214+
215+
```
216+
// Basic information about a container image.
217+
message Image {
218+
......
219+
//***New Fields***//
220+
// Volumes of image
221+
map<string, Volume> volumes= 100;
222+
}
223+
```
224+
225+
## CreateContainer
226+
227+
###What To Solve?
228+
229+
+ Support the ability to set DiskQuota.
230+
+ Add missing fields.
231+
232+
### Modification
233+
234+
+ LinuxContainerConfig contains LinuxContainerResources, which have changed in UpdateContainerResources().So after changing LinuxContainerResources, the Create process already supports the setting of DiskQuota.
235+
+ For missing fields are as follows (not all):
236+
+ NetPriority : Set network priorities
237+
+ QuotaId : When creating container, pass parameters of the DiskQuota and QuotaId. (When QuotaId is -1, QuotaId will be automatically generated)
238+
239+
```
240+
type ContainerConfig struct {
241+
......
242+
//***New Fields***//
243+
// NetPriority of the container
244+
NetPriority int64 `protobuf:"bytes,100,opt,name=net_priority" json:"net_priority,omitempty"`
245+
// QuotaId of the container
246+
QuotaId string `protobuf:"bytes,101,opt,name=quota_id,json=quotaId,proto3" json:"quota_id,omitempty"`
247+
}
248+
```
249+
250+
The changes need to be made in the proto file are as follows:
251+
252+
```
253+
message ContainerConfig {
254+
......
255+
//***New Fields***//
256+
// NetPriority of the containeri
257+
int64 net_priority = 100;
258+
// QuotaId of the container
259+
string quota_id = 101;
260+
}
261+
```
262+
263+
## RemoveVolume
264+
265+
### What To Solve?
266+
267+
+ After kubelet performs in-situ upgrade, the container after upgrade cannot delete the anonymous volume inherited.
268+
269+
### Modification
270+
271+
+ Provides an interface for removing volume.
272+
+ The containerstatus interface supports querying volume by name.
273+
+ The changes need to be made in the proto file are as follows:
274+
275+
```
276+
service VolumeService {
277+
​ // RemoveVolume volume an volume
278+
rpc RemoveVolume(RemoveVolumeRequest) returns (RemoveVolumeResponse) {}
279+
}​
280+
281+
message RemoveVolumeRequest {
282+
// name of the volume to remove
283+
string volume_name = 1;
284+
}
285+
message RemoveVolumeResponse {}
286+
```
287+
288+
Add name field in the Mount struct:
289+
290+
```
291+
// Mount specifies a host volume to mount into a container.
292+
message Mount {
293+
......
294+
//***New Fields***//
295+
// Name of volume
296+
string name = 100;
297+
}
298+
299+
```
300+
301+
## Pull Request
302+
303+
+ feature: make runtime choosing supported in CRI managers for Kubernetes [#1593](https://github.com/alibaba/pouch/pull/1593)
304+
+ feature: extend cri apis for special needs [#1617](https://github.com/alibaba/pouch/pull/1617)
305+
+ feature: extend cri apis for remove volume [#2124](https://github.com/alibaba/pouch/pull/2124)
306+
+ feature: extend cri apis for support quotaID [#2138](https://github.com/alibaba/pouch/pull/2138)
307+

0 commit comments

Comments
 (0)