config.go 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. package specs
  2. import "os"
  3. // Spec is the base configuration for the container.
  4. type Spec struct {
  5. // Version of the Open Container Initiative Runtime Specification with which the bundle complies.
  6. Version string `json:"ociVersion"`
  7. // Process configures the container process.
  8. Process *Process `json:"process,omitempty"`
  9. // Root configures the container's root filesystem.
  10. Root *Root `json:"root,omitempty"`
  11. // Hostname configures the container's hostname.
  12. Hostname string `json:"hostname,omitempty"`
  13. // Mounts configures additional mounts (on top of Root).
  14. Mounts []Mount `json:"mounts,omitempty"`
  15. // Hooks configures callbacks for container lifecycle events.
  16. Hooks *Hooks `json:"hooks,omitempty" platform:"linux,solaris"`
  17. // Annotations contains arbitrary metadata for the container.
  18. Annotations map[string]string `json:"annotations,omitempty"`
  19. // Linux is platform-specific configuration for Linux based containers.
  20. Linux *Linux `json:"linux,omitempty" platform:"linux"`
  21. // Solaris is platform-specific configuration for Solaris based containers.
  22. Solaris *Solaris `json:"solaris,omitempty" platform:"solaris"`
  23. // Windows is platform-specific configuration for Windows based containers.
  24. Windows *Windows `json:"windows,omitempty" platform:"windows"`
  25. // VM specifies configuration for virtual-machine-based containers.
  26. VM *VM `json:"vm,omitempty" platform:"vm"`
  27. }
  28. // Process contains information to start a specific application inside the container.
  29. type Process struct {
  30. // Terminal creates an interactive terminal for the container.
  31. Terminal bool `json:"terminal,omitempty"`
  32. // ConsoleSize specifies the size of the console.
  33. ConsoleSize *Box `json:"consoleSize,omitempty"`
  34. // User specifies user information for the process.
  35. User User `json:"user"`
  36. // Args specifies the binary and arguments for the application to execute.
  37. Args []string `json:"args,omitempty"`
  38. // CommandLine specifies the full command line for the application to execute on Windows.
  39. CommandLine string `json:"commandLine,omitempty" platform:"windows"`
  40. // Env populates the process environment for the process.
  41. Env []string `json:"env,omitempty"`
  42. // Cwd is the current working directory for the process and must be
  43. // relative to the container's root.
  44. Cwd string `json:"cwd"`
  45. // Capabilities are Linux capabilities that are kept for the process.
  46. Capabilities *LinuxCapabilities `json:"capabilities,omitempty" platform:"linux"`
  47. // Rlimits specifies rlimit options to apply to the process.
  48. Rlimits []POSIXRlimit `json:"rlimits,omitempty" platform:"linux,solaris"`
  49. // NoNewPrivileges controls whether additional privileges could be gained by processes in the container.
  50. NoNewPrivileges bool `json:"noNewPrivileges,omitempty" platform:"linux"`
  51. // ApparmorProfile specifies the apparmor profile for the container.
  52. ApparmorProfile string `json:"apparmorProfile,omitempty" platform:"linux"`
  53. // Specify an oom_score_adj for the container.
  54. OOMScoreAdj *int `json:"oomScoreAdj,omitempty" platform:"linux"`
  55. // SelinuxLabel specifies the selinux context that the container process is run as.
  56. SelinuxLabel string `json:"selinuxLabel,omitempty" platform:"linux"`
  57. }
  58. // LinuxCapabilities specifies the whitelist of capabilities that are kept for a process.
  59. // http://man7.org/linux/man-pages/man7/capabilities.7.html
  60. type LinuxCapabilities struct {
  61. // Bounding is the set of capabilities checked by the kernel.
  62. Bounding []string `json:"bounding,omitempty" platform:"linux"`
  63. // Effective is the set of capabilities checked by the kernel.
  64. Effective []string `json:"effective,omitempty" platform:"linux"`
  65. // Inheritable is the capabilities preserved across execve.
  66. Inheritable []string `json:"inheritable,omitempty" platform:"linux"`
  67. // Permitted is the limiting superset for effective capabilities.
  68. Permitted []string `json:"permitted,omitempty" platform:"linux"`
  69. // Ambient is the ambient set of capabilities that are kept.
  70. Ambient []string `json:"ambient,omitempty" platform:"linux"`
  71. }
  72. // Box specifies dimensions of a rectangle. Used for specifying the size of a console.
  73. type Box struct {
  74. // Height is the vertical dimension of a box.
  75. Height uint `json:"height"`
  76. // Width is the horizontal dimension of a box.
  77. Width uint `json:"width"`
  78. }
  79. // User specifies specific user (and group) information for the container process.
  80. type User struct {
  81. // UID is the user id.
  82. UID uint32 `json:"uid" platform:"linux,solaris"`
  83. // GID is the group id.
  84. GID uint32 `json:"gid" platform:"linux,solaris"`
  85. // AdditionalGids are additional group ids set for the container's process.
  86. AdditionalGids []uint32 `json:"additionalGids,omitempty" platform:"linux,solaris"`
  87. // Username is the user name.
  88. Username string `json:"username,omitempty" platform:"windows"`
  89. }
  90. // Root contains information about the container's root filesystem on the host.
  91. type Root struct {
  92. // Path is the absolute path to the container's root filesystem.
  93. Path string `json:"path"`
  94. // Readonly makes the root filesystem for the container readonly before the process is executed.
  95. Readonly bool `json:"readonly,omitempty"`
  96. }
  97. // Mount specifies a mount for a container.
  98. type Mount struct {
  99. // Destination is the absolute path where the mount will be placed in the container.
  100. Destination string `json:"destination"`
  101. // Type specifies the mount kind.
  102. Type string `json:"type,omitempty" platform:"linux,solaris"`
  103. // Source specifies the source path of the mount.
  104. Source string `json:"source,omitempty"`
  105. // Options are fstab style mount options.
  106. Options []string `json:"options,omitempty"`
  107. }
  108. // Hook specifies a command that is run at a particular event in the lifecycle of a container
  109. type Hook struct {
  110. Path string `json:"path"`
  111. Args []string `json:"args,omitempty"`
  112. Env []string `json:"env,omitempty"`
  113. Timeout *int `json:"timeout,omitempty"`
  114. }
  115. // Hooks for container setup and teardown
  116. type Hooks struct {
  117. // Prestart is a list of hooks to be run before the container process is executed.
  118. Prestart []Hook `json:"prestart,omitempty"`
  119. // Poststart is a list of hooks to be run after the container process is started.
  120. Poststart []Hook `json:"poststart,omitempty"`
  121. // Poststop is a list of hooks to be run after the container process exits.
  122. Poststop []Hook `json:"poststop,omitempty"`
  123. }
  124. // Linux contains platform-specific configuration for Linux based containers.
  125. type Linux struct {
  126. // UIDMapping specifies user mappings for supporting user namespaces.
  127. UIDMappings []LinuxIDMapping `json:"uidMappings,omitempty"`
  128. // GIDMapping specifies group mappings for supporting user namespaces.
  129. GIDMappings []LinuxIDMapping `json:"gidMappings,omitempty"`
  130. // Sysctl are a set of key value pairs that are set for the container on start
  131. Sysctl map[string]string `json:"sysctl,omitempty"`
  132. // Resources contain cgroup information for handling resource constraints
  133. // for the container
  134. Resources *LinuxResources `json:"resources,omitempty"`
  135. // CgroupsPath specifies the path to cgroups that are created and/or joined by the container.
  136. // The path is expected to be relative to the cgroups mountpoint.
  137. // If resources are specified, the cgroups at CgroupsPath will be updated based on resources.
  138. CgroupsPath string `json:"cgroupsPath,omitempty"`
  139. // Namespaces contains the namespaces that are created and/or joined by the container
  140. Namespaces []LinuxNamespace `json:"namespaces,omitempty"`
  141. // Devices are a list of device nodes that are created for the container
  142. Devices []LinuxDevice `json:"devices,omitempty"`
  143. // Seccomp specifies the seccomp security settings for the container.
  144. Seccomp *LinuxSeccomp `json:"seccomp,omitempty"`
  145. // RootfsPropagation is the rootfs mount propagation mode for the container.
  146. RootfsPropagation string `json:"rootfsPropagation,omitempty"`
  147. // MaskedPaths masks over the provided paths inside the container.
  148. MaskedPaths []string `json:"maskedPaths,omitempty"`
  149. // ReadonlyPaths sets the provided paths as RO inside the container.
  150. ReadonlyPaths []string `json:"readonlyPaths,omitempty"`
  151. // MountLabel specifies the selinux context for the mounts in the container.
  152. MountLabel string `json:"mountLabel,omitempty"`
  153. // IntelRdt contains Intel Resource Director Technology (RDT) information for
  154. // handling resource constraints (e.g., L3 cache, memory bandwidth) for the container
  155. IntelRdt *LinuxIntelRdt `json:"intelRdt,omitempty"`
  156. }
  157. // LinuxNamespace is the configuration for a Linux namespace
  158. type LinuxNamespace struct {
  159. // Type is the type of namespace
  160. Type LinuxNamespaceType `json:"type"`
  161. // Path is a path to an existing namespace persisted on disk that can be joined
  162. // and is of the same type
  163. Path string `json:"path,omitempty"`
  164. }
  165. // LinuxNamespaceType is one of the Linux namespaces
  166. type LinuxNamespaceType string
  167. const (
  168. // PIDNamespace for isolating process IDs
  169. PIDNamespace LinuxNamespaceType = "pid"
  170. // NetworkNamespace for isolating network devices, stacks, ports, etc
  171. NetworkNamespace = "network"
  172. // MountNamespace for isolating mount points
  173. MountNamespace = "mount"
  174. // IPCNamespace for isolating System V IPC, POSIX message queues
  175. IPCNamespace = "ipc"
  176. // UTSNamespace for isolating hostname and NIS domain name
  177. UTSNamespace = "uts"
  178. // UserNamespace for isolating user and group IDs
  179. UserNamespace = "user"
  180. // CgroupNamespace for isolating cgroup hierarchies
  181. CgroupNamespace = "cgroup"
  182. )
  183. // LinuxIDMapping specifies UID/GID mappings
  184. type LinuxIDMapping struct {
  185. // ContainerID is the starting UID/GID in the container
  186. ContainerID uint32 `json:"containerID"`
  187. // HostID is the starting UID/GID on the host to be mapped to 'ContainerID'
  188. HostID uint32 `json:"hostID"`
  189. // Size is the number of IDs to be mapped
  190. Size uint32 `json:"size"`
  191. }
  192. // POSIXRlimit type and restrictions
  193. type POSIXRlimit struct {
  194. // Type of the rlimit to set
  195. Type string `json:"type"`
  196. // Hard is the hard limit for the specified type
  197. Hard uint64 `json:"hard"`
  198. // Soft is the soft limit for the specified type
  199. Soft uint64 `json:"soft"`
  200. }
  201. // LinuxHugepageLimit structure corresponds to limiting kernel hugepages
  202. type LinuxHugepageLimit struct {
  203. // Pagesize is the hugepage size
  204. Pagesize string `json:"pageSize"`
  205. // Limit is the limit of "hugepagesize" hugetlb usage
  206. Limit uint64 `json:"limit"`
  207. }
  208. // LinuxInterfacePriority for network interfaces
  209. type LinuxInterfacePriority struct {
  210. // Name is the name of the network interface
  211. Name string `json:"name"`
  212. // Priority for the interface
  213. Priority uint32 `json:"priority"`
  214. }
  215. // linuxBlockIODevice holds major:minor format supported in blkio cgroup
  216. type linuxBlockIODevice struct {
  217. // Major is the device's major number.
  218. Major int64 `json:"major"`
  219. // Minor is the device's minor number.
  220. Minor int64 `json:"minor"`
  221. }
  222. // LinuxWeightDevice struct holds a `major:minor weight` pair for weightDevice
  223. type LinuxWeightDevice struct {
  224. linuxBlockIODevice
  225. // Weight is the bandwidth rate for the device.
  226. Weight *uint16 `json:"weight,omitempty"`
  227. // LeafWeight is the bandwidth rate for the device while competing with the cgroup's child cgroups, CFQ scheduler only
  228. LeafWeight *uint16 `json:"leafWeight,omitempty"`
  229. }
  230. // LinuxThrottleDevice struct holds a `major:minor rate_per_second` pair
  231. type LinuxThrottleDevice struct {
  232. linuxBlockIODevice
  233. // Rate is the IO rate limit per cgroup per device
  234. Rate uint64 `json:"rate"`
  235. }
  236. // LinuxBlockIO for Linux cgroup 'blkio' resource management
  237. type LinuxBlockIO struct {
  238. // Specifies per cgroup weight
  239. Weight *uint16 `json:"weight,omitempty"`
  240. // Specifies tasks' weight in the given cgroup while competing with the cgroup's child cgroups, CFQ scheduler only
  241. LeafWeight *uint16 `json:"leafWeight,omitempty"`
  242. // Weight per cgroup per device, can override BlkioWeight
  243. WeightDevice []LinuxWeightDevice `json:"weightDevice,omitempty"`
  244. // IO read rate limit per cgroup per device, bytes per second
  245. ThrottleReadBpsDevice []LinuxThrottleDevice `json:"throttleReadBpsDevice,omitempty"`
  246. // IO write rate limit per cgroup per device, bytes per second
  247. ThrottleWriteBpsDevice []LinuxThrottleDevice `json:"throttleWriteBpsDevice,omitempty"`
  248. // IO read rate limit per cgroup per device, IO per second
  249. ThrottleReadIOPSDevice []LinuxThrottleDevice `json:"throttleReadIOPSDevice,omitempty"`
  250. // IO write rate limit per cgroup per device, IO per second
  251. ThrottleWriteIOPSDevice []LinuxThrottleDevice `json:"throttleWriteIOPSDevice,omitempty"`
  252. }
  253. // LinuxMemory for Linux cgroup 'memory' resource management
  254. type LinuxMemory struct {
  255. // Memory limit (in bytes).
  256. Limit *int64 `json:"limit,omitempty"`
  257. // Memory reservation or soft_limit (in bytes).
  258. Reservation *int64 `json:"reservation,omitempty"`
  259. // Total memory limit (memory + swap).
  260. Swap *int64 `json:"swap,omitempty"`
  261. // Kernel memory limit (in bytes).
  262. Kernel *int64 `json:"kernel,omitempty"`
  263. // Kernel memory limit for tcp (in bytes)
  264. KernelTCP *int64 `json:"kernelTCP,omitempty"`
  265. // How aggressive the kernel will swap memory pages.
  266. Swappiness *uint64 `json:"swappiness,omitempty"`
  267. // DisableOOMKiller disables the OOM killer for out of memory conditions
  268. DisableOOMKiller *bool `json:"disableOOMKiller,omitempty"`
  269. }
  270. // LinuxCPU for Linux cgroup 'cpu' resource management
  271. type LinuxCPU struct {
  272. // CPU shares (relative weight (ratio) vs. other cgroups with cpu shares).
  273. Shares *uint64 `json:"shares,omitempty"`
  274. // CPU hardcap limit (in usecs). Allowed cpu time in a given period.
  275. Quota *int64 `json:"quota,omitempty"`
  276. // CPU period to be used for hardcapping (in usecs).
  277. Period *uint64 `json:"period,omitempty"`
  278. // How much time realtime scheduling may use (in usecs).
  279. RealtimeRuntime *int64 `json:"realtimeRuntime,omitempty"`
  280. // CPU period to be used for realtime scheduling (in usecs).
  281. RealtimePeriod *uint64 `json:"realtimePeriod,omitempty"`
  282. // CPUs to use within the cpuset. Default is to use any CPU available.
  283. Cpus string `json:"cpus,omitempty"`
  284. // List of memory nodes in the cpuset. Default is to use any available memory node.
  285. Mems string `json:"mems,omitempty"`
  286. }
  287. // LinuxPids for Linux cgroup 'pids' resource management (Linux 4.3)
  288. type LinuxPids struct {
  289. // Maximum number of PIDs. Default is "no limit".
  290. Limit int64 `json:"limit"`
  291. }
  292. // LinuxNetwork identification and priority configuration
  293. type LinuxNetwork struct {
  294. // Set class identifier for container's network packets
  295. ClassID *uint32 `json:"classID,omitempty"`
  296. // Set priority of network traffic for container
  297. Priorities []LinuxInterfacePriority `json:"priorities,omitempty"`
  298. }
  299. // LinuxRdma for Linux cgroup 'rdma' resource management (Linux 4.11)
  300. type LinuxRdma struct {
  301. // Maximum number of HCA handles that can be opened. Default is "no limit".
  302. HcaHandles *uint32 `json:"hcaHandles,omitempty"`
  303. // Maximum number of HCA objects that can be created. Default is "no limit".
  304. HcaObjects *uint32 `json:"hcaObjects,omitempty"`
  305. }
  306. // LinuxResources has container runtime resource constraints
  307. type LinuxResources struct {
  308. // Devices configures the device whitelist.
  309. Devices []LinuxDeviceCgroup `json:"devices,omitempty"`
  310. // Memory restriction configuration
  311. Memory *LinuxMemory `json:"memory,omitempty"`
  312. // CPU resource restriction configuration
  313. CPU *LinuxCPU `json:"cpu,omitempty"`
  314. // Task resource restriction configuration.
  315. Pids *LinuxPids `json:"pids,omitempty"`
  316. // BlockIO restriction configuration
  317. BlockIO *LinuxBlockIO `json:"blockIO,omitempty"`
  318. // Hugetlb limit (in bytes)
  319. HugepageLimits []LinuxHugepageLimit `json:"hugepageLimits,omitempty"`
  320. // Network restriction configuration
  321. Network *LinuxNetwork `json:"network,omitempty"`
  322. // Rdma resource restriction configuration.
  323. // Limits are a set of key value pairs that define RDMA resource limits,
  324. // where the key is device name and value is resource limits.
  325. Rdma map[string]LinuxRdma `json:"rdma,omitempty"`
  326. }
  327. // LinuxDevice represents the mknod information for a Linux special device file
  328. type LinuxDevice struct {
  329. // Path to the device.
  330. Path string `json:"path"`
  331. // Device type, block, char, etc.
  332. Type string `json:"type"`
  333. // Major is the device's major number.
  334. Major int64 `json:"major"`
  335. // Minor is the device's minor number.
  336. Minor int64 `json:"minor"`
  337. // FileMode permission bits for the device.
  338. FileMode *os.FileMode `json:"fileMode,omitempty"`
  339. // UID of the device.
  340. UID *uint32 `json:"uid,omitempty"`
  341. // Gid of the device.
  342. GID *uint32 `json:"gid,omitempty"`
  343. }
  344. // LinuxDeviceCgroup represents a device rule for the whitelist controller
  345. type LinuxDeviceCgroup struct {
  346. // Allow or deny
  347. Allow bool `json:"allow"`
  348. // Device type, block, char, etc.
  349. Type string `json:"type,omitempty"`
  350. // Major is the device's major number.
  351. Major *int64 `json:"major,omitempty"`
  352. // Minor is the device's minor number.
  353. Minor *int64 `json:"minor,omitempty"`
  354. // Cgroup access permissions format, rwm.
  355. Access string `json:"access,omitempty"`
  356. }
  357. // Solaris contains platform-specific configuration for Solaris application containers.
  358. type Solaris struct {
  359. // SMF FMRI which should go "online" before we start the container process.
  360. Milestone string `json:"milestone,omitempty"`
  361. // Maximum set of privileges any process in this container can obtain.
  362. LimitPriv string `json:"limitpriv,omitempty"`
  363. // The maximum amount of shared memory allowed for this container.
  364. MaxShmMemory string `json:"maxShmMemory,omitempty"`
  365. // Specification for automatic creation of network resources for this container.
  366. Anet []SolarisAnet `json:"anet,omitempty"`
  367. // Set limit on the amount of CPU time that can be used by container.
  368. CappedCPU *SolarisCappedCPU `json:"cappedCPU,omitempty"`
  369. // The physical and swap caps on the memory that can be used by this container.
  370. CappedMemory *SolarisCappedMemory `json:"cappedMemory,omitempty"`
  371. }
  372. // SolarisCappedCPU allows users to set limit on the amount of CPU time that can be used by container.
  373. type SolarisCappedCPU struct {
  374. Ncpus string `json:"ncpus,omitempty"`
  375. }
  376. // SolarisCappedMemory allows users to set the physical and swap caps on the memory that can be used by this container.
  377. type SolarisCappedMemory struct {
  378. Physical string `json:"physical,omitempty"`
  379. Swap string `json:"swap,omitempty"`
  380. }
  381. // SolarisAnet provides the specification for automatic creation of network resources for this container.
  382. type SolarisAnet struct {
  383. // Specify a name for the automatically created VNIC datalink.
  384. Linkname string `json:"linkname,omitempty"`
  385. // Specify the link over which the VNIC will be created.
  386. Lowerlink string `json:"lowerLink,omitempty"`
  387. // The set of IP addresses that the container can use.
  388. Allowedaddr string `json:"allowedAddress,omitempty"`
  389. // Specifies whether allowedAddress limitation is to be applied to the VNIC.
  390. Configallowedaddr string `json:"configureAllowedAddress,omitempty"`
  391. // The value of the optional default router.
  392. Defrouter string `json:"defrouter,omitempty"`
  393. // Enable one or more types of link protection.
  394. Linkprotection string `json:"linkProtection,omitempty"`
  395. // Set the VNIC's macAddress
  396. Macaddress string `json:"macAddress,omitempty"`
  397. }
  398. // Windows defines the runtime configuration for Windows based containers, including Hyper-V containers.
  399. type Windows struct {
  400. // LayerFolders contains a list of absolute paths to directories containing image layers.
  401. LayerFolders []string `json:"layerFolders"`
  402. // Devices are the list of devices to be mapped into the container.
  403. Devices []WindowsDevice `json:"devices,omitempty"`
  404. // Resources contains information for handling resource constraints for the container.
  405. Resources *WindowsResources `json:"resources,omitempty"`
  406. // CredentialSpec contains a JSON object describing a group Managed Service Account (gMSA) specification.
  407. CredentialSpec interface{} `json:"credentialSpec,omitempty"`
  408. // Servicing indicates if the container is being started in a mode to apply a Windows Update servicing operation.
  409. Servicing bool `json:"servicing,omitempty"`
  410. // IgnoreFlushesDuringBoot indicates if the container is being started in a mode where disk writes are not flushed during its boot process.
  411. IgnoreFlushesDuringBoot bool `json:"ignoreFlushesDuringBoot,omitempty"`
  412. // HyperV contains information for running a container with Hyper-V isolation.
  413. HyperV *WindowsHyperV `json:"hyperv,omitempty"`
  414. // Network restriction configuration.
  415. Network *WindowsNetwork `json:"network,omitempty"`
  416. }
  417. // WindowsDevice represents information about a host device to be mapped into the container.
  418. type WindowsDevice struct {
  419. // Device identifier: interface class GUID, etc.
  420. ID string `json:"id"`
  421. // Device identifier type: "class", etc.
  422. IDType string `json:"idType"`
  423. }
  424. // WindowsResources has container runtime resource constraints for containers running on Windows.
  425. type WindowsResources struct {
  426. // Memory restriction configuration.
  427. Memory *WindowsMemoryResources `json:"memory,omitempty"`
  428. // CPU resource restriction configuration.
  429. CPU *WindowsCPUResources `json:"cpu,omitempty"`
  430. // Storage restriction configuration.
  431. Storage *WindowsStorageResources `json:"storage,omitempty"`
  432. }
  433. // WindowsMemoryResources contains memory resource management settings.
  434. type WindowsMemoryResources struct {
  435. // Memory limit in bytes.
  436. Limit *uint64 `json:"limit,omitempty"`
  437. }
  438. // WindowsCPUResources contains CPU resource management settings.
  439. type WindowsCPUResources struct {
  440. // Number of CPUs available to the container.
  441. Count *uint64 `json:"count,omitempty"`
  442. // CPU shares (relative weight to other containers with cpu shares).
  443. Shares *uint16 `json:"shares,omitempty"`
  444. // Specifies the portion of processor cycles that this container can use as a percentage times 100.
  445. Maximum *uint16 `json:"maximum,omitempty"`
  446. }
  447. // WindowsStorageResources contains storage resource management settings.
  448. type WindowsStorageResources struct {
  449. // Specifies maximum Iops for the system drive.
  450. Iops *uint64 `json:"iops,omitempty"`
  451. // Specifies maximum bytes per second for the system drive.
  452. Bps *uint64 `json:"bps,omitempty"`
  453. // Sandbox size specifies the minimum size of the system drive in bytes.
  454. SandboxSize *uint64 `json:"sandboxSize,omitempty"`
  455. }
  456. // WindowsNetwork contains network settings for Windows containers.
  457. type WindowsNetwork struct {
  458. // List of HNS endpoints that the container should connect to.
  459. EndpointList []string `json:"endpointList,omitempty"`
  460. // Specifies if unqualified DNS name resolution is allowed.
  461. AllowUnqualifiedDNSQuery bool `json:"allowUnqualifiedDNSQuery,omitempty"`
  462. // Comma separated list of DNS suffixes to use for name resolution.
  463. DNSSearchList []string `json:"DNSSearchList,omitempty"`
  464. // Name (ID) of the container that we will share with the network stack.
  465. NetworkSharedContainerName string `json:"networkSharedContainerName,omitempty"`
  466. // name (ID) of the network namespace that will be used for the container.
  467. NetworkNamespace string `json:"networkNamespace,omitempty"`
  468. }
  469. // WindowsHyperV contains information for configuring a container to run with Hyper-V isolation.
  470. type WindowsHyperV struct {
  471. // UtilityVMPath is an optional path to the image used for the Utility VM.
  472. UtilityVMPath string `json:"utilityVMPath,omitempty"`
  473. }
  474. // VM contains information for virtual-machine-based containers.
  475. type VM struct {
  476. // Hypervisor specifies hypervisor-related configuration for virtual-machine-based containers.
  477. Hypervisor VMHypervisor `json:"hypervisor,omitempty"`
  478. // Kernel specifies kernel-related configuration for virtual-machine-based containers.
  479. Kernel VMKernel `json:"kernel"`
  480. // Image specifies guest image related configuration for virtual-machine-based containers.
  481. Image VMImage `json:"image,omitempty"`
  482. }
  483. // VMHypervisor contains information about the hypervisor to use for a virtual machine.
  484. type VMHypervisor struct {
  485. // Path is the host path to the hypervisor used to manage the virtual machine.
  486. Path string `json:"path"`
  487. // Parameters specifies parameters to pass to the hypervisor.
  488. Parameters []string `json:"parameters,omitempty"`
  489. }
  490. // VMKernel contains information about the kernel to use for a virtual machine.
  491. type VMKernel struct {
  492. // Path is the host path to the kernel used to boot the virtual machine.
  493. Path string `json:"path"`
  494. // Parameters specifies parameters to pass to the kernel.
  495. Parameters []string `json:"parameters,omitempty"`
  496. // InitRD is the host path to an initial ramdisk to be used by the kernel.
  497. InitRD string `json:"initrd,omitempty"`
  498. }
  499. // VMImage contains information about the virtual machine root image.
  500. type VMImage struct {
  501. // Path is the host path to the root image that the VM kernel would boot into.
  502. Path string `json:"path"`
  503. // Format is the root image format type (e.g. "qcow2", "raw", "vhd", etc).
  504. Format string `json:"format"`
  505. }
  506. // LinuxSeccomp represents syscall restrictions
  507. type LinuxSeccomp struct {
  508. DefaultAction LinuxSeccompAction `json:"defaultAction"`
  509. Architectures []Arch `json:"architectures,omitempty"`
  510. Syscalls []LinuxSyscall `json:"syscalls,omitempty"`
  511. }
  512. // Arch used for additional architectures
  513. type Arch string
  514. // Additional architectures permitted to be used for system calls
  515. // By default only the native architecture of the kernel is permitted
  516. const (
  517. ArchX86 Arch = "SCMP_ARCH_X86"
  518. ArchX86_64 Arch = "SCMP_ARCH_X86_64"
  519. ArchX32 Arch = "SCMP_ARCH_X32"
  520. ArchARM Arch = "SCMP_ARCH_ARM"
  521. ArchAARCH64 Arch = "SCMP_ARCH_AARCH64"
  522. ArchMIPS Arch = "SCMP_ARCH_MIPS"
  523. ArchMIPS64 Arch = "SCMP_ARCH_MIPS64"
  524. ArchMIPS64N32 Arch = "SCMP_ARCH_MIPS64N32"
  525. ArchMIPSEL Arch = "SCMP_ARCH_MIPSEL"
  526. ArchMIPSEL64 Arch = "SCMP_ARCH_MIPSEL64"
  527. ArchMIPSEL64N32 Arch = "SCMP_ARCH_MIPSEL64N32"
  528. ArchPPC Arch = "SCMP_ARCH_PPC"
  529. ArchPPC64 Arch = "SCMP_ARCH_PPC64"
  530. ArchPPC64LE Arch = "SCMP_ARCH_PPC64LE"
  531. ArchS390 Arch = "SCMP_ARCH_S390"
  532. ArchS390X Arch = "SCMP_ARCH_S390X"
  533. ArchPARISC Arch = "SCMP_ARCH_PARISC"
  534. ArchPARISC64 Arch = "SCMP_ARCH_PARISC64"
  535. )
  536. // LinuxSeccompAction taken upon Seccomp rule match
  537. type LinuxSeccompAction string
  538. // Define actions for Seccomp rules
  539. const (
  540. ActKill LinuxSeccompAction = "SCMP_ACT_KILL"
  541. ActTrap LinuxSeccompAction = "SCMP_ACT_TRAP"
  542. ActErrno LinuxSeccompAction = "SCMP_ACT_ERRNO"
  543. ActTrace LinuxSeccompAction = "SCMP_ACT_TRACE"
  544. ActAllow LinuxSeccompAction = "SCMP_ACT_ALLOW"
  545. )
  546. // LinuxSeccompOperator used to match syscall arguments in Seccomp
  547. type LinuxSeccompOperator string
  548. // Define operators for syscall arguments in Seccomp
  549. const (
  550. OpNotEqual LinuxSeccompOperator = "SCMP_CMP_NE"
  551. OpLessThan LinuxSeccompOperator = "SCMP_CMP_LT"
  552. OpLessEqual LinuxSeccompOperator = "SCMP_CMP_LE"
  553. OpEqualTo LinuxSeccompOperator = "SCMP_CMP_EQ"
  554. OpGreaterEqual LinuxSeccompOperator = "SCMP_CMP_GE"
  555. OpGreaterThan LinuxSeccompOperator = "SCMP_CMP_GT"
  556. OpMaskedEqual LinuxSeccompOperator = "SCMP_CMP_MASKED_EQ"
  557. )
  558. // LinuxSeccompArg used for matching specific syscall arguments in Seccomp
  559. type LinuxSeccompArg struct {
  560. Index uint `json:"index"`
  561. Value uint64 `json:"value"`
  562. ValueTwo uint64 `json:"valueTwo,omitempty"`
  563. Op LinuxSeccompOperator `json:"op"`
  564. }
  565. // LinuxSyscall is used to match a syscall in Seccomp
  566. type LinuxSyscall struct {
  567. Names []string `json:"names"`
  568. Action LinuxSeccompAction `json:"action"`
  569. Args []LinuxSeccompArg `json:"args,omitempty"`
  570. }
  571. // LinuxIntelRdt has container runtime resource constraints for Intel RDT
  572. // CAT and MBA features which introduced in Linux 4.10 and 4.12 kernel
  573. type LinuxIntelRdt struct {
  574. // The identity for RDT Class of Service
  575. ClosID string `json:"closID,omitempty"`
  576. // The schema for L3 cache id and capacity bitmask (CBM)
  577. // Format: "L3:<cache_id0>=<cbm0>;<cache_id1>=<cbm1>;..."
  578. L3CacheSchema string `json:"l3CacheSchema,omitempty"`
  579. // The schema of memory bandwidth per L3 cache id
  580. // Format: "MB:<cache_id0>=bandwidth0;<cache_id1>=bandwidth1;..."
  581. // The unit of memory bandwidth is specified in "percentages" by
  582. // default, and in "MBps" if MBA Software Controller is enabled.
  583. MemBwSchema string `json:"memBwSchema,omitempty"`
  584. }