Skip to content

Commit 1c7c27d

Browse files
authored
Merge pull request #573 from jhowardmsft/jjh/addwindows
Add support for Windows based containers
2 parents c356a80 + dc8f2c2 commit 1c7c27d

File tree

9 files changed

+271
-0
lines changed

9 files changed

+271
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Table of Contents
2020
- [General Configuration](config.md)
2121
- [Linux-specific Configuration](config-linux.md)
2222
- [Solaris-specific Configuration](config-solaris.md)
23+
- [Windows-specific Configuration](config-windows.md)
2324
- [Glossary](glossary.md)
2425

2526
In the specifications in the above table of contents, the keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" are to be interpreted as described in [RFC 2119](http://tools.ietf.org/html/rfc2119) (Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997).
@@ -32,6 +33,7 @@ An implementation is compliant for a given CPU architecture if it satisfies all
3233
Protocols defined by this specification are:
3334
* Linux containers: [runtime.md](runtime.md), [config.md](config.md), [config-linux.md](config-linux.md), and [runtime-linux.md](runtime-linux.md).
3435
* Solaris containers: [runtime.md](runtime.md), [config.md](config.md), and [config-solaris.md](config-solaris.md).
36+
* Windows containers: [runtime.md](runtime.md), [config.md](config.md), and [config-windows.md](config-windows.md).
3537

3638
# Use Cases
3739

config-windows.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Windows-specific Container Configuration
2+
3+
This document describes the schema for the [Windows-specific section](config.md#platform-specific-configuration) of the [container configuration](config.md).
4+
The Windows container specification uses APIs provided by the Windows Host Compute Service (HCS) to fulfill the spec.
5+
6+
## Resources
7+
8+
You can configure a container's resource limits via the OPTIONAL `resources` field of the Windows configuration.
9+
10+
### Memory
11+
12+
`memory` is an OPTIONAL configuration for the container's memory usage.
13+
14+
The following parameters can be specified:
15+
16+
* **`limit`** *(uint64, OPTIONAL)* - sets limit of memory usage in bytes.
17+
18+
* **`reservation`** *(uint64, OPTIONAL)* - sets the guaranteed minimum amount of memory for a container in bytes.
19+
20+
#### Example
21+
22+
```json
23+
"windows": {
24+
"resources": {
25+
"memory": {
26+
"limit": 2097152,
27+
"reservation": 524288
28+
}
29+
}
30+
}
31+
```
32+
33+
### CPU
34+
35+
`cpu` is an OPTIONAL configuration for the container's CPU usage.
36+
37+
The following parameters can be specified:
38+
39+
* **`count`** *(uint64, OPTIONAL)* - specifies the number of CPUs available to the container.
40+
41+
* **`shares`** *(uint16, OPTIONAL)* - specifies the relative weight to other containers with CPU shares. The range is from 1 to 10000.
42+
43+
* **`percent`** *(uint, OPTIONAL)* - specifies the percentage of available CPUs usable by the container.
44+
45+
#### Example
46+
47+
```json
48+
"windows": {
49+
"resources": {
50+
"cpu": {
51+
"percent": 50
52+
}
53+
}
54+
}
55+
```
56+
57+
### Storage
58+
59+
`storage` is an OPTIONAL configuration for the container's storage usage.
60+
61+
The following parameters can be specified:
62+
63+
* **`iops`** *(uint64, OPTIONAL)* - specifies the maximum IO operations per second for the system drive of the container.
64+
65+
* **`bps`** *(uint64, OPTIONAL)* - specifies the maximum bytes per second for the system drive of the container.
66+
67+
* **`sandboxSize`** *(uint64, OPTIONAL)* - specifies the minimum size of the system drive in bytes.
68+
69+
#### Example
70+
71+
```json
72+
"windows": {
73+
"resources": {
74+
"storage": {
75+
"iops": 50
76+
}
77+
}
78+
}
79+
```
80+
81+
### Network
82+
83+
`network` is an OPTIONAL configuration for the container's network usage.
84+
85+
The following parameters can be specified:
86+
87+
* **`egressBandwidth`** *(uint64, OPTIONAL)* - specified the maximum egress bandwidth in bytes per second for the container.
88+
89+
#### Example
90+
91+
```json
92+
"windows": {
93+
"resources": {
94+
"network": {
95+
"egressBandwidth": 1048577
96+
}
97+
}
98+
}
99+
```

config.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ For Windows based systems the user structure has the following fields:
267267
This SHOULD only be set if **`platform.os`** is `linux`.
268268
* **`solaris`** (object, OPTIONAL) [Solaris-specific configuration](config-solaris.md).
269269
This SHOULD only be set if **`platform.os`** is `solaris`.
270+
* **`windows`** (object, optional) [Windows-specific configuration](config-windows.md).
271+
This SHOULD only be set if **`platform.os`** is `windows`.
270272

271273
### Example (Linux)
272274

schema/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The layout of the files is as follows:
99
* [config-schema.json](config-schema.json) - the primary entrypoint for the [configuration](../config.md) schema
1010
* [config-linux.json](config-linux.json) - the [Linux-specific configuration sub-structure](../config-linux.md)
1111
* [config-solaris.json](config-solaris.json) - the [Solaris-specific configuration sub-structure](../config-solaris.md)
12+
* [config-windows.json](config-windows.json) - the [Windows-specific configuration sub-structure](../config-windows.md)
1213
* [state-schema.json](state-schema.json) - the primary entrypoint for the [state JSON](../runtime.md#state) schema
1314
* [defs.json](defs.json) - definitions for general types
1415
* [defs-linux.json](defs-linux.json) - definitions for Linux-specific types

schema/config-schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@
161161
},
162162
"solaris": {
163163
"$ref": "config-solaris.json#/solaris"
164+
},
165+
"windows": {
166+
"$ref": "config-windows.json#/windows"
164167
}
165168
},
166169
"required": [

schema/config-windows.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"windows": {
3+
"description": "Windows platform-specific configurations",
4+
"id": "https://opencontainers.org/schema/bundle/windows",
5+
"type": "object",
6+
"properties": {
7+
"resources": {
8+
"id": "https://opencontainers.org/schema/bundle/windows/resources",
9+
"type": "object",
10+
"properties": {
11+
"memory": {
12+
"id": "https://opencontainers.org/schema/bundle/windows/resources/memory",
13+
"type": "object",
14+
"properties": {
15+
"limit": {
16+
"id": "https://opencontainers.org/schema/bundle/windows/resources/memory/limit",
17+
"$ref": "defs.json#/definitions/uint64Pointer"
18+
},
19+
"reservation": {
20+
"id": "https://opencontainers.org/schema/bundle/windows/resources/memory/reservation",
21+
"$ref": "defs.json#/definitions/uint64Pointer"
22+
}
23+
}
24+
},
25+
"cpu": {
26+
"id": "https://opencontainers.org/schema/bundle/windows/resources/cpu",
27+
"type": "object",
28+
"properties": {
29+
"count": {
30+
"id": "https://opencontainers.org/schema/bundle/windows/resources/cpu/count",
31+
"$ref": "defs.json#/definitions/uint64Pointer"
32+
},
33+
"shares": {
34+
"id": "https://opencontainers.org/schema/bundle/windows/resources/cpu/shares",
35+
"$ref": "defs-windows.json#/definitions/cpuSharesPointer"
36+
},
37+
"percent": {
38+
"id": "https://opencontainers.org/schema/bundle/windows/resources/cpu/percent",
39+
"$ref": "defs.json#/definitions/percentPointer"
40+
}
41+
}
42+
},
43+
"storage": {
44+
"id": "https://opencontainers.org/schema/bundle/windows/resources/storage",
45+
"type": "object",
46+
"properties": {
47+
"iops": {
48+
"id": "https://opencontainers.org/schema/bundle/windows/resources/storage/iops",
49+
"$ref": "defs.json#/definitions/uint64Pointer"
50+
},
51+
"bps": {
52+
"id": "https://opencontainers.org/schema/bundle/windows/resources/storage/bps",
53+
"$ref": "defs.json#/definitions/uint64Pointer"
54+
},
55+
"sandboxSize": {
56+
"id": "https://opencontainers.org/schema/bundle/windows/resources/storage/sandboxSize",
57+
"$ref": "defs.json#/definitions/uint64Pointer"
58+
}
59+
}
60+
},
61+
"network": {
62+
"id": "https://opencontainers.org/schema/bundle/windows/resources/network",
63+
"type": "object",
64+
"properties": {
65+
"egressBandwidth": {
66+
"id": "https://opencontainers.org/schema/bundle/windows/resources/network/egressBandwidth",
67+
"$ref": "defs.json#/definitions/uint64Pointer"
68+
}
69+
}
70+
}
71+
}
72+
}
73+
}
74+
}
75+
}

schema/defs-windows.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"definitions": {
3+
"cpuShares": {
4+
"description": "Relative weight to other containers with CPU Shares defined",
5+
"type": "integer",
6+
"minimum": 1,
7+
"maximum": 10000
8+
},
9+
"cpuSharesPointer": {
10+
"oneOf": [
11+
{
12+
"$ref": "#/definitions/cpuShares"
13+
},
14+
{
15+
"type": "null"
16+
}
17+
]
18+
}
19+
}
20+
}

schema/defs.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
"minimum": 0,
4242
"maximum": 18446744073709552000
4343
},
44+
"percent": {
45+
"type": "integer",
46+
"minimum": 0,
47+
"maximum": 100
48+
},
4449
"intPointer": {
4550
"oneOf": [
4651
{
@@ -71,6 +76,16 @@
7176
}
7277
]
7378
},
79+
"percentPointer": {
80+
"oneOf": [
81+
{
82+
"$ref": "#/definitions/percent"
83+
},
84+
{
85+
"type": "null"
86+
}
87+
]
88+
},
7489
"stringPointer": {
7590
"oneOf": [
7691
{

specs-go/config.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ type Spec struct {
2525
Linux *Linux `json:"linux,omitempty" platform:"linux"`
2626
// Solaris is platform specific configuration for Solaris containers.
2727
Solaris *Solaris `json:"solaris,omitempty" platform:"solaris"`
28+
// Windows is platform specific configuration for Windows based containers, including Hyper-V containers.
29+
Windows *Windows `json:"windows,omitempty" platform:"windows"`
2830
}
2931

3032
// Process contains information to start a specific application inside the container.
@@ -415,6 +417,58 @@ type Anet struct {
415417
Macaddress string `json:"macAddress,omitempty"`
416418
}
417419

420+
// Windows defines the runtime configuration for Windows based containers, including Hyper-V containers.
421+
type Windows struct {
422+
// Resources contains information for handling resource constraints for the container.
423+
Resources *WindowsResources `json:"resources,omitempty"`
424+
}
425+
426+
// WindowsResources has container runtime resource constraints for containers running on Windows.
427+
type WindowsResources struct {
428+
// Memory restriction configuration.
429+
Memory *WindowsMemoryResources `json:"memory,omitempty"`
430+
// CPU resource restriction configuration.
431+
CPU *WindowsCPUResources `json:"cpu,omitempty"`
432+
// Storage restriction configuration.
433+
Storage *WindowsStorageResources `json:"storage,omitempty"`
434+
// Network restriction configuration.
435+
Network *WindowsNetworkResources `json:"network,omitempty"`
436+
}
437+
438+
// WindowsMemoryResources contains memory resource management settings.
439+
type WindowsMemoryResources struct {
440+
// Memory limit in bytes.
441+
Limit *uint64 `json:"limit,omitempty"`
442+
// Memory reservation in bytes.
443+
Reservation *uint64 `json:"reservation,omitempty"`
444+
}
445+
446+
// WindowsCPUResources contains CPU resource management settings.
447+
type WindowsCPUResources struct {
448+
// Number of CPUs available to the container.
449+
Count *uint64 `json:"count,omitempty"`
450+
// CPU shares (relative weight to other containers with cpu shares). Range is from 1 to 10000.
451+
Shares *uint16 `json:"shares,omitempty"`
452+
// Percent of available CPUs usable by the container.
453+
Percent *uint8 `json:"percent,omitempty"`
454+
}
455+
456+
// WindowsStorageResources contains storage resource management settings.
457+
type WindowsStorageResources struct {
458+
// Specifies maximum Iops for the system drive.
459+
Iops *uint64 `json:"iops,omitempty"`
460+
// Specifies maximum bytes per second for the system drive.
461+
Bps *uint64 `json:"bps,omitempty"`
462+
// Sandbox size specifies the minimum size of the system drive in bytes.
463+
SandboxSize *uint64 `json:"sandboxSize,omitempty"`
464+
}
465+
466+
// WindowsNetworkResources contains network resource management settings.
467+
type WindowsNetworkResources struct {
468+
// EgressBandwidth is the maximum egress bandwidth in bytes per second.
469+
EgressBandwidth *uint64 `json:"egressBandwidth,omitempty"`
470+
}
471+
418472
// Arch used for additional architectures
419473
type Arch string
420474

0 commit comments

Comments
 (0)