config.go 27 KB

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