Skip to content

Commit

Permalink
Add support for Windows-based containers
Browse files Browse the repository at this point in the history
Signed-off-by: John Howard <jhoward@microsoft.com>
  • Loading branch information
John Howard committed Sep 19, 2016
1 parent f0ecb45 commit d57e63f
Show file tree
Hide file tree
Showing 9 changed files with 271 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Table of Contents
- [General Configuration](config.md)
- [Linux-specific Configuration](config-linux.md)
- [Solaris-specific Configuration](config-solaris.md)
- [Windows-specific Configuration](config-windows.md)
- [Glossary](glossary.md)

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).
Expand All @@ -30,6 +31,7 @@ An implementation is compliant for a given CPU architecture if it satisfies all
Protocols defined by this specification are:
* Linux containers: [runtime.md](runtime.md), [config.md](config.md), [config-linux.md](config-linux.md), and [runtime-linux.md](runtime-linux.md).
* Solaris containers: [runtime.md](runtime.md), [config.md](config.md), and [config-solaris.md](config-solaris.md).
* Windows containers: [runtime.md](runtime.md), [config.md](config.md), and [config-windows.md](config-windows.md).

# Use Cases

Expand Down
99 changes: 99 additions & 0 deletions config-windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Windows-specific Container Configuration

This document describes the schema for the [Windows-specific section](config.md#platform-specific-configuration) of the [container configuration](config.md).
The Windows container specification uses APIs provided by the Windows Host Compute Service (HCS) to fulfill the spec.

## Resources

You can configure a container's resource limits via the OPTIONAL `resources` field of the Windows configuration.

### Memory

`memory` is an OPTIONAL configuration for the container's memory usage.

The following parameters can be specified:

* **`limit`** *(uint64, optional)* - sets limit of memory usage in bytes.

* **`reservation`** *(uint64, optional)* - sets the guaranteed minimum amount of memory for a container in bytes.

#### Example

```json
"windows": {
"resources": {
"memory": {
"limit": 2097152,
"reservation": 524288
}
}
}
```

### CPU

`cpu` is an OPTIONAL configuration for the container's CPU usage.

The following parameters can be specified:

* **`count`** *(uint64, optional)* - specifies the number of CPUs available to the container.

* **`shares`** *(uint16, optional)* - specifies the relative weight to other containers with CPU shares. The range is from 1 to 10000.

* **`percent`** *(uint, optional)* - specifies the percentage of available CPUs usable by the container.

#### Example

```json
"windows": {
"resources": {
"cpu": {
"percent": 50
}
}
}
```

### Storage

`storage` is an OPTIONAL configuration for the container's storage usage.

The following parameters can be specified:

* **`iops`** *(uint64, optional)* - specifies the maximum Iops for the system drive of the container.

* **`bps`** *(uint64, optional)* - specifies the maximum bytes per second for the system drive of the container.

* **`sandboxSize`** *(uint64, optional)* - specifies the minimum size of the system drive in bytes.

#### Example

```json
"windows": {
"resources": {
"storage": {
"iops": 50
}
}
}
```

### Network

`network` is an OPTIONAL configuration for the container's network usage.

The following parameters can be specified:

* **`egressBandwidth`** *(uint64, optional)* - specified the maximum egress bandwidth in bytes per second for the container.

#### Example

```json
"windows": {
"resources": {
"network": {
"egressBandwidth": 1048577
}
}
}
```
2 changes: 2 additions & 0 deletions config.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ For Windows based systems the user structure has the following fields:
This SHOULD only be set if **`platform.os`** is `linux`.
* **`solaris`** (object, optional) [Solaris-specific configuration](config-solaris.md).
This SHOULD only be set if **`platform.os`** is `solaris`.
* **`windows`** (object, optional) [Windows-specific configuration](config-windows.md).
This SHOULD only be set if **`platform.os`** is `windows`.

### Example (Linux)

Expand Down
1 change: 1 addition & 0 deletions schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The layout of the files is as follows:
* [config-schema.json](config-schema.json) - the primary entrypoint for the [configuration](../config.md) schema
* [config-linux.json](config-linux.json) - the [Linux-specific configuration sub-structure](../config-linux.md)
* [config-solaris.json](config-solaris.json) - the [Solaris-specific configuration sub-structure](../config-solaris.md)
* [config-windows.json](config-windows.json) - the [Windows-specific configuration sub-structure](../config-windows.md)
* [state-schema.json](state-schema.json) - the primary entrypoint for the [state JSON](../runtime.md#state) schema
* [defs.json](defs.json) - definitions for general types
* [defs-linux.json](defs-linux.json) - definitions for Linux-specific types
Expand Down
3 changes: 3 additions & 0 deletions schema/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@
},
"solaris": {
"$ref": "config-solaris.json#/solaris"
},
"windows": {
"$ref": "config-windows.json#/windows"
}
},
"required": [
Expand Down
75 changes: 75 additions & 0 deletions schema/config-windows.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"windows": {
"description": "Windows platform-specific configurations",
"id": "https://opencontainers.org/schema/bundle/windows",
"type": "object",
"properties": {
"resources": {
"id": "https://opencontainers.org/schema/bundle/windows/resources",
"type": "object",
"properties": {
"memory": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/memory",
"type": "object",
"properties": {
"limit": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/memory/limit",
"$ref": "defs.json#/definitions/uint64Pointer"
},
"reservation": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/memory/reservation",
"$ref": "defs.json#/definitions/uint64Pointer"
}
}
},
"cpu": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/cpu",
"type": "object",
"properties": {
"count": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/cpu/count",
"$ref": "defs.json#/definitions/uint64Pointer"
},
"shares": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/cpu/shares",
"$ref": "defs-windows.json#/definitions/cpuSharesPointer"
},
"percent": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/cpu/percent",
"$ref": "defs.json#/definitions/percentPointer"
}
}
},
"storage": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/storage",
"type": "object",
"properties": {
"iops": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/storage/iops",
"$ref": "defs.json#/definitions/uint64Pointer"
},
"bps": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/storage/bps",
"$ref": "defs.json#/definitions/uint64Pointer"
},
"sandboxSize": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/storage/sandboxSize",
"$ref": "defs.json#/definitions/uint64Pointer"
}
}
},
"network": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/network",
"type": "object",
"properties": {
"egressBandwidth": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/network/egressBandwidth",
"$ref": "defs.json#/definitions/uint64Pointer"
}
}
}
}
}
}
}
}
20 changes: 20 additions & 0 deletions schema/defs-windows.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"definitions": {
"cpuShares": {
"description": "Relative weight to other containers with CPU Shares defined",
"type": "integer",
"minimum": 1,
"maximum": 10000
},
"cpuSharesPointer": {
"oneOf": [
{
"$ref": "#/definitions/cpuShares"
},
{
"type": "null"
}
]
}
}
}
15 changes: 15 additions & 0 deletions schema/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
"minimum": 0,
"maximum": 18446744073709552000
},
"percent": {
"type": "integer",
"minimum": 0,
"maximum": 100
},
"intPointer": {
"oneOf": [
{
Expand Down Expand Up @@ -71,6 +76,16 @@
}
]
},
"percentPointer": {
"oneOf": [
{
"$ref": "#/definitions/percent"
},
{
"type": "null"
}
]
},
"stringPointer": {
"oneOf": [
{
Expand Down
54 changes: 54 additions & 0 deletions specs-go/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type Spec struct {
Linux *Linux `json:"linux,omitempty" platform:"linux"`
// Solaris is platform specific configuration for Solaris containers.
Solaris *Solaris `json:"solaris,omitempty" platform:"solaris"`
// Windows is platform specific configuration for Windows based containers, including Hyper-V containers.
Windows *Windows `json:"windows,omitempty" platform:"windows"`
}

// Process contains information to start a specific application inside the container.
Expand Down Expand Up @@ -406,6 +408,58 @@ type Anet struct {
Macaddress string `json:"macAddress,omitempty"`
}

// Windows defines the runtime configuration for Windows based containers, including Hyper-V containers.
type Windows struct {
// Resources contains information for handling resource constraints for the container.
Resources *WindowsResources `json:"resources,omitempty"`
}

// WindowsResources has container runtime resource constraints for containers running on Windows.
type WindowsResources struct {
// Memory restriction configuration.
Memory *WindowsMemoryResources `json:"memory,omitempty"`
// CPU resource restriction configuration.
CPU *WindowsCPUResources `json:"cpu,omitempty"`
// Storage restriction configuration.
Storage *WindowsStorageResources `json:"storage,omitempty"`
// Network restriction configuration.
Network *WindowsNetworkResources `json:"network,omitempty"`
}

// WindowsMemoryResources contains memory resource management settings.
type WindowsMemoryResources struct {
// Memory limit in bytes.
Limit *uint64 `json:"limit,omitempty"`
// Memory reservation in bytes.
Reservation *uint64 `json:"reservation,omitempty"`
}

// WindowsCPUResources contains CPU resource management settings.
type WindowsCPUResources struct {
// Number of CPUs available to the container.
Count *uint64 `json:"count,omitempty"`
// CPU shares (relative weight to other containers with cpu shares). Range is from 1 to 10000.
Shares *uint16 `json:"shares,omitempty"`
// Percent of available CPUs usable by the container.
Percent *uint8 `json:"percent,omitempty"`
}

// WindowsStorageResources contains storage resource management settings.
type WindowsStorageResources struct {
// Specifies maximum Iops for the system drive.
Iops *uint64 `json:"iops,omitempty"`
// Specifies maximum bytes per second for the system drive.
Bps *uint64 `json:"bps,omitempty"`
// Sandbox size specifies the minimum size of the system drive in bytes.
SandboxSize *uint64 `json:"sandboxSize,omitempty"`
}

// WindowsNetworkResources contains network resource management settings.
type WindowsNetworkResources struct {
// EgressBandwidth is the maximum egress bandwidth in bytes per second.
EgressBandwidth *uint64 `json:"egressBandwidth,omitempty"`
}

// Arch used for additional architectures
type Arch string

Expand Down

0 comments on commit d57e63f

Please sign in to comment.