config.go 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  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. // Domainname configures the container's domainname.
  14. Domainname string `json:"domainname,omitempty"`
  15. // Mounts configures additional mounts (on top of Root).
  16. Mounts []Mount `json:"mounts,omitempty"`
  17. // Hooks configures callbacks for container lifecycle events.
  18. Hooks *Hooks `json:"hooks,omitempty" platform:"linux,solaris,zos"`
  19. // Annotations contains arbitrary metadata for the container.
  20. Annotations map[string]string `json:"annotations,omitempty"`
  21. // Linux is platform-specific configuration for Linux based containers.
  22. Linux *Linux `json:"linux,omitempty" platform:"linux"`
  23. // Solaris is platform-specific configuration for Solaris based containers.
  24. Solaris *Solaris `json:"solaris,omitempty" platform:"solaris"`
  25. // Windows is platform-specific configuration for Windows based containers.
  26. Windows *Windows `json:"windows,omitempty" platform:"windows"`
  27. // VM specifies configuration for virtual-machine-based containers.
  28. VM *VM `json:"vm,omitempty" platform:"vm"`
  29. // ZOS is platform-specific configuration for z/OS based containers.
  30. ZOS *ZOS `json:"zos,omitempty" platform:"zos"`
  31. }
  32. // Scheduler represents the scheduling attributes for a process. It is based on
  33. // the Linux sched_setattr(2) syscall.
  34. type Scheduler struct {
  35. // Policy represents the scheduling policy (e.g., SCHED_FIFO, SCHED_RR, SCHED_OTHER).
  36. Policy LinuxSchedulerPolicy `json:"policy"`
  37. // Nice is the nice value for the process, which affects its priority.
  38. Nice int32 `json:"nice,omitempty"`
  39. // Priority represents the static priority of the process.
  40. Priority int32 `json:"priority,omitempty"`
  41. // Flags is an array of scheduling flags.
  42. Flags []LinuxSchedulerFlag `json:"flags,omitempty"`
  43. // The following ones are used by the DEADLINE scheduler.
  44. // Runtime is the amount of time in nanoseconds during which the process
  45. // is allowed to run in a given period.
  46. Runtime uint64 `json:"runtime,omitempty"`
  47. // Deadline is the absolute deadline for the process to complete its execution.
  48. Deadline uint64 `json:"deadline,omitempty"`
  49. // Period is the length of the period in nanoseconds used for determining the process runtime.
  50. Period uint64 `json:"period,omitempty"`
  51. }
  52. // Process contains information to start a specific application inside the container.
  53. type Process struct {
  54. // Terminal creates an interactive terminal for the container.
  55. Terminal bool `json:"terminal,omitempty"`
  56. // ConsoleSize specifies the size of the console.
  57. ConsoleSize *Box `json:"consoleSize,omitempty"`
  58. // User specifies user information for the process.
  59. User User `json:"user"`
  60. // Args specifies the binary and arguments for the application to execute.
  61. Args []string `json:"args,omitempty"`
  62. // CommandLine specifies the full command line for the application to execute on Windows.
  63. CommandLine string `json:"commandLine,omitempty" platform:"windows"`
  64. // Env populates the process environment for the process.
  65. Env []string `json:"env,omitempty"`
  66. // Cwd is the current working directory for the process and must be
  67. // relative to the container's root.
  68. Cwd string `json:"cwd"`
  69. // Capabilities are Linux capabilities that are kept for the process.
  70. Capabilities *LinuxCapabilities `json:"capabilities,omitempty" platform:"linux"`
  71. // Rlimits specifies rlimit options to apply to the process.
  72. Rlimits []POSIXRlimit `json:"rlimits,omitempty" platform:"linux,solaris,zos"`
  73. // NoNewPrivileges controls whether additional privileges could be gained by processes in the container.
  74. NoNewPrivileges bool `json:"noNewPrivileges,omitempty" platform:"linux"`
  75. // ApparmorProfile specifies the apparmor profile for the container.
  76. ApparmorProfile string `json:"apparmorProfile,omitempty" platform:"linux"`
  77. // Specify an oom_score_adj for the container.
  78. OOMScoreAdj *int `json:"oomScoreAdj,omitempty" platform:"linux"`
  79. // Scheduler specifies the scheduling attributes for a process
  80. Scheduler *Scheduler `json:"scheduler,omitempty" platform:"linux"`
  81. // SelinuxLabel specifies the selinux context that the container process is run as.
  82. SelinuxLabel string `json:"selinuxLabel,omitempty" platform:"linux"`
  83. // IOPriority contains the I/O priority settings for the cgroup.
  84. IOPriority *LinuxIOPriority `json:"ioPriority,omitempty" platform:"linux"`
  85. }
  86. // LinuxCapabilities specifies the list of allowed capabilities that are kept for a process.
  87. // http://man7.org/linux/man-pages/man7/capabilities.7.html
  88. type LinuxCapabilities struct {
  89. // Bounding is the set of capabilities checked by the kernel.
  90. Bounding []string `json:"bounding,omitempty" platform:"linux"`
  91. // Effective is the set of capabilities checked by the kernel.
  92. Effective []string `json:"effective,omitempty" platform:"linux"`
  93. // Inheritable is the capabilities preserved across execve.
  94. Inheritable []string `json:"inheritable,omitempty" platform:"linux"`
  95. // Permitted is the limiting superset for effective capabilities.
  96. Permitted []string `json:"permitted,omitempty" platform:"linux"`
  97. // Ambient is the ambient set of capabilities that are kept.
  98. Ambient []string `json:"ambient,omitempty" platform:"linux"`
  99. }
  100. // IOPriority represents I/O priority settings for the container's processes within the process group.
  101. type LinuxIOPriority struct {
  102. Class IOPriorityClass `json:"class"`
  103. Priority int `json:"priority"`
  104. }
  105. // IOPriorityClass represents an I/O scheduling class.
  106. type IOPriorityClass string
  107. // Possible values for IOPriorityClass.
  108. const (
  109. IOPRIO_CLASS_RT IOPriorityClass = "IOPRIO_CLASS_RT"
  110. IOPRIO_CLASS_BE IOPriorityClass = "IOPRIO_CLASS_BE"
  111. IOPRIO_CLASS_IDLE IOPriorityClass = "IOPRIO_CLASS_IDLE"
  112. )
  113. // Box specifies dimensions of a rectangle. Used for specifying the size of a console.
  114. type Box struct {
  115. // Height is the vertical dimension of a box.
  116. Height uint `json:"height"`
  117. // Width is the horizontal dimension of a box.
  118. Width uint `json:"width"`
  119. }
  120. // User specifies specific user (and group) information for the container process.
  121. type User struct {
  122. // UID is the user id.
  123. UID uint32 `json:"uid" platform:"linux,solaris,zos"`
  124. // GID is the group id.
  125. GID uint32 `json:"gid" platform:"linux,solaris,zos"`
  126. // Umask is the umask for the init process.
  127. Umask *uint32 `json:"umask,omitempty" platform:"linux,solaris,zos"`
  128. // AdditionalGids are additional group ids set for the container's process.
  129. AdditionalGids []uint32 `json:"additionalGids,omitempty" platform:"linux,solaris"`
  130. // Username is the user name.
  131. Username string `json:"username,omitempty" platform:"windows"`
  132. }
  133. // Root contains information about the container's root filesystem on the host.
  134. type Root struct {
  135. // Path is the absolute path to the container's root filesystem.
  136. Path string `json:"path"`
  137. // Readonly makes the root filesystem for the container readonly before the process is executed.
  138. Readonly bool `json:"readonly,omitempty"`
  139. }
  140. // Mount specifies a mount for a container.
  141. type Mount struct {
  142. // Destination is the absolute path where the mount will be placed in the container.
  143. Destination string `json:"destination"`
  144. // Type specifies the mount kind.
  145. Type string `json:"type,omitempty" platform:"linux,solaris,zos"`
  146. // Source specifies the source path of the mount.
  147. Source string `json:"source,omitempty"`
  148. // Options are fstab style mount options.
  149. Options []string `json:"options,omitempty"`
  150. // UID/GID mappings used for changing file owners w/o calling chown, fs should support it.
  151. // Every mount point could have its own mapping.
  152. UIDMappings []LinuxIDMapping `json:"uidMappings,omitempty" platform:"linux"`
  153. GIDMappings []LinuxIDMapping `json:"gidMappings,omitempty" platform:"linux"`
  154. }
  155. // Hook specifies a command that is run at a particular event in the lifecycle of a container
  156. type Hook struct {
  157. Path string `json:"path"`
  158. Args []string `json:"args,omitempty"`
  159. Env []string `json:"env,omitempty"`
  160. Timeout *int `json:"timeout,omitempty"`
  161. }
  162. // Hooks specifies a command that is run in the container at a particular event in the lifecycle of a container
  163. // Hooks for container setup and teardown
  164. type Hooks struct {
  165. // Prestart is Deprecated. Prestart is a list of hooks to be run before the container process is executed.
  166. // It is called in the Runtime Namespace
  167. Prestart []Hook `json:"prestart,omitempty"`
  168. // CreateRuntime is a list of hooks to be run after the container has been created but before pivot_root or any equivalent operation has been called
  169. // It is called in the Runtime Namespace
  170. CreateRuntime []Hook `json:"createRuntime,omitempty"`
  171. // CreateContainer is a list of hooks to be run after the container has been created but before pivot_root or any equivalent operation has been called
  172. // It is called in the Container Namespace
  173. CreateContainer []Hook `json:"createContainer,omitempty"`
  174. // StartContainer is a list of hooks to be run after the start operation is called but before the container process is started
  175. // It is called in the Container Namespace
  176. StartContainer []Hook `json:"startContainer,omitempty"`
  177. // Poststart is a list of hooks to be run after the container process is started.
  178. // It is called in the Runtime Namespace
  179. Poststart []Hook `json:"poststart,omitempty"`
  180. // Poststop is a list of hooks to be run after the container process exits.
  181. // It is called in the Runtime Namespace
  182. Poststop []Hook `json:"poststop,omitempty"`
  183. }
  184. // Linux contains platform-specific configuration for Linux based containers.
  185. type Linux struct {
  186. // UIDMapping specifies user mappings for supporting user namespaces.
  187. UIDMappings []LinuxIDMapping `json:"uidMappings,omitempty"`
  188. // GIDMapping specifies group mappings for supporting user namespaces.
  189. GIDMappings []LinuxIDMapping `json:"gidMappings,omitempty"`
  190. // Sysctl are a set of key value pairs that are set for the container on start
  191. Sysctl map[string]string `json:"sysctl,omitempty"`
  192. // Resources contain cgroup information for handling resource constraints
  193. // for the container
  194. Resources *LinuxResources `json:"resources,omitempty"`
  195. // CgroupsPath specifies the path to cgroups that are created and/or joined by the container.
  196. // The path is expected to be relative to the cgroups mountpoint.
  197. // If resources are specified, the cgroups at CgroupsPath will be updated based on resources.
  198. CgroupsPath string `json:"cgroupsPath,omitempty"`
  199. // Namespaces contains the namespaces that are created and/or joined by the container
  200. Namespaces []LinuxNamespace `json:"namespaces,omitempty"`
  201. // Devices are a list of device nodes that are created for the container
  202. Devices []LinuxDevice `json:"devices,omitempty"`
  203. // Seccomp specifies the seccomp security settings for the container.
  204. Seccomp *LinuxSeccomp `json:"seccomp,omitempty"`
  205. // RootfsPropagation is the rootfs mount propagation mode for the container.
  206. RootfsPropagation string `json:"rootfsPropagation,omitempty"`
  207. // MaskedPaths masks over the provided paths inside the container.
  208. MaskedPaths []string `json:"maskedPaths,omitempty"`
  209. // ReadonlyPaths sets the provided paths as RO inside the container.
  210. ReadonlyPaths []string `json:"readonlyPaths,omitempty"`
  211. // MountLabel specifies the selinux context for the mounts in the container.
  212. MountLabel string `json:"mountLabel,omitempty"`
  213. // IntelRdt contains Intel Resource Director Technology (RDT) information for
  214. // handling resource constraints and monitoring metrics (e.g., L3 cache, memory bandwidth) for the container
  215. IntelRdt *LinuxIntelRdt `json:"intelRdt,omitempty"`
  216. // Personality contains configuration for the Linux personality syscall
  217. Personality *LinuxPersonality `json:"personality,omitempty"`
  218. // TimeOffsets specifies the offset for supporting time namespaces.
  219. TimeOffsets map[string]LinuxTimeOffset `json:"timeOffsets,omitempty"`
  220. }
  221. // LinuxNamespace is the configuration for a Linux namespace
  222. type LinuxNamespace struct {
  223. // Type is the type of namespace
  224. Type LinuxNamespaceType `json:"type"`
  225. // Path is a path to an existing namespace persisted on disk that can be joined
  226. // and is of the same type
  227. Path string `json:"path,omitempty"`
  228. }
  229. // LinuxNamespaceType is one of the Linux namespaces
  230. type LinuxNamespaceType string
  231. const (
  232. // PIDNamespace for isolating process IDs
  233. PIDNamespace LinuxNamespaceType = "pid"
  234. // NetworkNamespace for isolating network devices, stacks, ports, etc
  235. NetworkNamespace LinuxNamespaceType = "network"
  236. // MountNamespace for isolating mount points
  237. MountNamespace LinuxNamespaceType = "mount"
  238. // IPCNamespace for isolating System V IPC, POSIX message queues
  239. IPCNamespace LinuxNamespaceType = "ipc"
  240. // UTSNamespace for isolating hostname and NIS domain name
  241. UTSNamespace LinuxNamespaceType = "uts"
  242. // UserNamespace for isolating user and group IDs
  243. UserNamespace LinuxNamespaceType = "user"
  244. // CgroupNamespace for isolating cgroup hierarchies
  245. CgroupNamespace LinuxNamespaceType = "cgroup"
  246. // TimeNamespace for isolating the clocks
  247. TimeNamespace LinuxNamespaceType = "time"
  248. )
  249. // LinuxIDMapping specifies UID/GID mappings
  250. type LinuxIDMapping struct {
  251. // ContainerID is the starting UID/GID in the container
  252. ContainerID uint32 `json:"containerID"`
  253. // HostID is the starting UID/GID on the host to be mapped to 'ContainerID'
  254. HostID uint32 `json:"hostID"`
  255. // Size is the number of IDs to be mapped
  256. Size uint32 `json:"size"`
  257. }
  258. // LinuxTimeOffset specifies the offset for Time Namespace
  259. type LinuxTimeOffset struct {
  260. // Secs is the offset of clock (in secs) in the container
  261. Secs int64 `json:"secs,omitempty"`
  262. // Nanosecs is the additional offset for Secs (in nanosecs)
  263. Nanosecs uint32 `json:"nanosecs,omitempty"`
  264. }
  265. // POSIXRlimit type and restrictions
  266. type POSIXRlimit struct {
  267. // Type of the rlimit to set
  268. Type string `json:"type"`
  269. // Hard is the hard limit for the specified type
  270. Hard uint64 `json:"hard"`
  271. // Soft is the soft limit for the specified type
  272. Soft uint64 `json:"soft"`
  273. }
  274. // LinuxHugepageLimit structure corresponds to limiting kernel hugepages.
  275. // Default to reservation limits if supported. Otherwise fallback to page fault limits.
  276. type LinuxHugepageLimit struct {
  277. // Pagesize is the hugepage size.
  278. // Format: "<size><unit-prefix>B' (e.g. 64KB, 2MB, 1GB, etc.).
  279. Pagesize string `json:"pageSize"`
  280. // Limit is the limit of "hugepagesize" hugetlb reservations (if supported) or usage.
  281. Limit uint64 `json:"limit"`
  282. }
  283. // LinuxInterfacePriority for network interfaces
  284. type LinuxInterfacePriority struct {
  285. // Name is the name of the network interface
  286. Name string `json:"name"`
  287. // Priority for the interface
  288. Priority uint32 `json:"priority"`
  289. }
  290. // LinuxBlockIODevice holds major:minor format supported in blkio cgroup
  291. type LinuxBlockIODevice struct {
  292. // Major is the device's major number.
  293. Major int64 `json:"major"`
  294. // Minor is the device's minor number.
  295. Minor int64 `json:"minor"`
  296. }
  297. // LinuxWeightDevice struct holds a `major:minor weight` pair for weightDevice
  298. type LinuxWeightDevice struct {
  299. LinuxBlockIODevice
  300. // Weight is the bandwidth rate for the device.
  301. Weight *uint16 `json:"weight,omitempty"`
  302. // LeafWeight is the bandwidth rate for the device while competing with the cgroup's child cgroups, CFQ scheduler only
  303. LeafWeight *uint16 `json:"leafWeight,omitempty"`
  304. }
  305. // LinuxThrottleDevice struct holds a `major:minor rate_per_second` pair
  306. type LinuxThrottleDevice struct {
  307. LinuxBlockIODevice
  308. // Rate is the IO rate limit per cgroup per device
  309. Rate uint64 `json:"rate"`
  310. }
  311. // LinuxBlockIO for Linux cgroup 'blkio' resource management
  312. type LinuxBlockIO struct {
  313. // Specifies per cgroup weight
  314. Weight *uint16 `json:"weight,omitempty"`
  315. // Specifies tasks' weight in the given cgroup while competing with the cgroup's child cgroups, CFQ scheduler only
  316. LeafWeight *uint16 `json:"leafWeight,omitempty"`
  317. // Weight per cgroup per device, can override BlkioWeight
  318. WeightDevice []LinuxWeightDevice `json:"weightDevice,omitempty"`
  319. // IO read rate limit per cgroup per device, bytes per second
  320. ThrottleReadBpsDevice []LinuxThrottleDevice `json:"throttleReadBpsDevice,omitempty"`
  321. // IO write rate limit per cgroup per device, bytes per second
  322. ThrottleWriteBpsDevice []LinuxThrottleDevice `json:"throttleWriteBpsDevice,omitempty"`
  323. // IO read rate limit per cgroup per device, IO per second
  324. ThrottleReadIOPSDevice []LinuxThrottleDevice `json:"throttleReadIOPSDevice,omitempty"`
  325. // IO write rate limit per cgroup per device, IO per second
  326. ThrottleWriteIOPSDevice []LinuxThrottleDevice `json:"throttleWriteIOPSDevice,omitempty"`
  327. }
  328. // LinuxMemory for Linux cgroup 'memory' resource management
  329. type LinuxMemory struct {
  330. // Memory limit (in bytes).
  331. Limit *int64 `json:"limit,omitempty"`
  332. // Memory reservation or soft_limit (in bytes).
  333. Reservation *int64 `json:"reservation,omitempty"`
  334. // Total memory limit (memory + swap).
  335. Swap *int64 `json:"swap,omitempty"`
  336. // Kernel memory limit (in bytes).
  337. Kernel *int64 `json:"kernel,omitempty"`
  338. // Kernel memory limit for tcp (in bytes)
  339. KernelTCP *int64 `json:"kernelTCP,omitempty"`
  340. // How aggressive the kernel will swap memory pages.
  341. Swappiness *uint64 `json:"swappiness,omitempty"`
  342. // DisableOOMKiller disables the OOM killer for out of memory conditions
  343. DisableOOMKiller *bool `json:"disableOOMKiller,omitempty"`
  344. // Enables hierarchical memory accounting
  345. UseHierarchy *bool `json:"useHierarchy,omitempty"`
  346. // CheckBeforeUpdate enables checking if a new memory limit is lower
  347. // than the current usage during update, and if so, rejecting the new
  348. // limit.
  349. CheckBeforeUpdate *bool `json:"checkBeforeUpdate,omitempty"`
  350. }
  351. // LinuxCPU for Linux cgroup 'cpu' resource management
  352. type LinuxCPU struct {
  353. // CPU shares (relative weight (ratio) vs. other cgroups with cpu shares).
  354. Shares *uint64 `json:"shares,omitempty"`
  355. // CPU hardcap limit (in usecs). Allowed cpu time in a given period.
  356. Quota *int64 `json:"quota,omitempty"`
  357. // CPU hardcap burst limit (in usecs). Allowed accumulated cpu time additionally for burst in a
  358. // given period.
  359. Burst *uint64 `json:"burst,omitempty"`
  360. // CPU period to be used for hardcapping (in usecs).
  361. Period *uint64 `json:"period,omitempty"`
  362. // How much time realtime scheduling may use (in usecs).
  363. RealtimeRuntime *int64 `json:"realtimeRuntime,omitempty"`
  364. // CPU period to be used for realtime scheduling (in usecs).
  365. RealtimePeriod *uint64 `json:"realtimePeriod,omitempty"`
  366. // CPUs to use within the cpuset. Default is to use any CPU available.
  367. Cpus string `json:"cpus,omitempty"`
  368. // List of memory nodes in the cpuset. Default is to use any available memory node.
  369. Mems string `json:"mems,omitempty"`
  370. // cgroups are configured with minimum weight, 0: default behavior, 1: SCHED_IDLE.
  371. Idle *int64 `json:"idle,omitempty"`
  372. }
  373. // LinuxPids for Linux cgroup 'pids' resource management (Linux 4.3)
  374. type LinuxPids struct {
  375. // Maximum number of PIDs. Default is "no limit".
  376. Limit int64 `json:"limit"`
  377. }
  378. // LinuxNetwork identification and priority configuration
  379. type LinuxNetwork struct {
  380. // Set class identifier for container's network packets
  381. ClassID *uint32 `json:"classID,omitempty"`
  382. // Set priority of network traffic for container
  383. Priorities []LinuxInterfacePriority `json:"priorities,omitempty"`
  384. }
  385. // LinuxRdma for Linux cgroup 'rdma' resource management (Linux 4.11)
  386. type LinuxRdma struct {
  387. // Maximum number of HCA handles that can be opened. Default is "no limit".
  388. HcaHandles *uint32 `json:"hcaHandles,omitempty"`
  389. // Maximum number of HCA objects that can be created. Default is "no limit".
  390. HcaObjects *uint32 `json:"hcaObjects,omitempty"`
  391. }
  392. // LinuxResources has container runtime resource constraints
  393. type LinuxResources struct {
  394. // Devices configures the device allowlist.
  395. Devices []LinuxDeviceCgroup `json:"devices,omitempty"`
  396. // Memory restriction configuration
  397. Memory *LinuxMemory `json:"memory,omitempty"`
  398. // CPU resource restriction configuration
  399. CPU *LinuxCPU `json:"cpu,omitempty"`
  400. // Task resource restriction configuration.
  401. Pids *LinuxPids `json:"pids,omitempty"`
  402. // BlockIO restriction configuration
  403. BlockIO *LinuxBlockIO `json:"blockIO,omitempty"`
  404. // Hugetlb limits (in bytes). Default to reservation limits if supported.
  405. HugepageLimits []LinuxHugepageLimit `json:"hugepageLimits,omitempty"`
  406. // Network restriction configuration
  407. Network *LinuxNetwork `json:"network,omitempty"`
  408. // Rdma resource restriction configuration.
  409. // Limits are a set of key value pairs that define RDMA resource limits,
  410. // where the key is device name and value is resource limits.
  411. Rdma map[string]LinuxRdma `json:"rdma,omitempty"`
  412. // Unified resources.
  413. Unified map[string]string `json:"unified,omitempty"`
  414. }
  415. // LinuxDevice represents the mknod information for a Linux special device file
  416. type LinuxDevice struct {
  417. // Path to the device.
  418. Path string `json:"path"`
  419. // Device type, block, char, etc.
  420. Type string `json:"type"`
  421. // Major is the device's major number.
  422. Major int64 `json:"major"`
  423. // Minor is the device's minor number.
  424. Minor int64 `json:"minor"`
  425. // FileMode permission bits for the device.
  426. FileMode *os.FileMode `json:"fileMode,omitempty"`
  427. // UID of the device.
  428. UID *uint32 `json:"uid,omitempty"`
  429. // Gid of the device.
  430. GID *uint32 `json:"gid,omitempty"`
  431. }
  432. // LinuxDeviceCgroup represents a device rule for the devices specified to
  433. // the device controller
  434. type LinuxDeviceCgroup struct {
  435. // Allow or deny
  436. Allow bool `json:"allow"`
  437. // Device type, block, char, etc.
  438. Type string `json:"type,omitempty"`
  439. // Major is the device's major number.
  440. Major *int64 `json:"major,omitempty"`
  441. // Minor is the device's minor number.
  442. Minor *int64 `json:"minor,omitempty"`
  443. // Cgroup access permissions format, rwm.
  444. Access string `json:"access,omitempty"`
  445. }
  446. // LinuxPersonalityDomain refers to a personality domain.
  447. type LinuxPersonalityDomain string
  448. // LinuxPersonalityFlag refers to an additional personality flag. None are currently defined.
  449. type LinuxPersonalityFlag string
  450. // Define domain and flags for Personality
  451. const (
  452. // PerLinux is the standard Linux personality
  453. PerLinux LinuxPersonalityDomain = "LINUX"
  454. // PerLinux32 sets personality to 32 bit
  455. PerLinux32 LinuxPersonalityDomain = "LINUX32"
  456. )
  457. // LinuxPersonality represents the Linux personality syscall input
  458. type LinuxPersonality struct {
  459. // Domain for the personality
  460. Domain LinuxPersonalityDomain `json:"domain"`
  461. // Additional flags
  462. Flags []LinuxPersonalityFlag `json:"flags,omitempty"`
  463. }
  464. // Solaris contains platform-specific configuration for Solaris application containers.
  465. type Solaris struct {
  466. // SMF FMRI which should go "online" before we start the container process.
  467. Milestone string `json:"milestone,omitempty"`
  468. // Maximum set of privileges any process in this container can obtain.
  469. LimitPriv string `json:"limitpriv,omitempty"`
  470. // The maximum amount of shared memory allowed for this container.
  471. MaxShmMemory string `json:"maxShmMemory,omitempty"`
  472. // Specification for automatic creation of network resources for this container.
  473. Anet []SolarisAnet `json:"anet,omitempty"`
  474. // Set limit on the amount of CPU time that can be used by container.
  475. CappedCPU *SolarisCappedCPU `json:"cappedCPU,omitempty"`
  476. // The physical and swap caps on the memory that can be used by this container.
  477. CappedMemory *SolarisCappedMemory `json:"cappedMemory,omitempty"`
  478. }
  479. // SolarisCappedCPU allows users to set limit on the amount of CPU time that can be used by container.
  480. type SolarisCappedCPU struct {
  481. Ncpus string `json:"ncpus,omitempty"`
  482. }
  483. // SolarisCappedMemory allows users to set the physical and swap caps on the memory that can be used by this container.
  484. type SolarisCappedMemory struct {
  485. Physical string `json:"physical,omitempty"`
  486. Swap string `json:"swap,omitempty"`
  487. }
  488. // SolarisAnet provides the specification for automatic creation of network resources for this container.
  489. type SolarisAnet struct {
  490. // Specify a name for the automatically created VNIC datalink.
  491. Linkname string `json:"linkname,omitempty"`
  492. // Specify the link over which the VNIC will be created.
  493. Lowerlink string `json:"lowerLink,omitempty"`
  494. // The set of IP addresses that the container can use.
  495. Allowedaddr string `json:"allowedAddress,omitempty"`
  496. // Specifies whether allowedAddress limitation is to be applied to the VNIC.
  497. Configallowedaddr string `json:"configureAllowedAddress,omitempty"`
  498. // The value of the optional default router.
  499. Defrouter string `json:"defrouter,omitempty"`
  500. // Enable one or more types of link protection.
  501. Linkprotection string `json:"linkProtection,omitempty"`
  502. // Set the VNIC's macAddress
  503. Macaddress string `json:"macAddress,omitempty"`
  504. }
  505. // Windows defines the runtime configuration for Windows based containers, including Hyper-V containers.
  506. type Windows struct {
  507. // LayerFolders contains a list of absolute paths to directories containing image layers.
  508. LayerFolders []string `json:"layerFolders"`
  509. // Devices are the list of devices to be mapped into the container.
  510. Devices []WindowsDevice `json:"devices,omitempty"`
  511. // Resources contains information for handling resource constraints for the container.
  512. Resources *WindowsResources `json:"resources,omitempty"`
  513. // CredentialSpec contains a JSON object describing a group Managed Service Account (gMSA) specification.
  514. CredentialSpec interface{} `json:"credentialSpec,omitempty"`
  515. // Servicing indicates if the container is being started in a mode to apply a Windows Update servicing operation.
  516. Servicing bool `json:"servicing,omitempty"`
  517. // IgnoreFlushesDuringBoot indicates if the container is being started in a mode where disk writes are not flushed during its boot process.
  518. IgnoreFlushesDuringBoot bool `json:"ignoreFlushesDuringBoot,omitempty"`
  519. // HyperV contains information for running a container with Hyper-V isolation.
  520. HyperV *WindowsHyperV `json:"hyperv,omitempty"`
  521. // Network restriction configuration.
  522. Network *WindowsNetwork `json:"network,omitempty"`
  523. }
  524. // WindowsDevice represents information about a host device to be mapped into the container.
  525. type WindowsDevice struct {
  526. // Device identifier: interface class GUID, etc.
  527. ID string `json:"id"`
  528. // Device identifier type: "class", etc.
  529. IDType string `json:"idType"`
  530. }
  531. // WindowsResources has container runtime resource constraints for containers running on Windows.
  532. type WindowsResources struct {
  533. // Memory restriction configuration.
  534. Memory *WindowsMemoryResources `json:"memory,omitempty"`
  535. // CPU resource restriction configuration.
  536. CPU *WindowsCPUResources `json:"cpu,omitempty"`
  537. // Storage restriction configuration.
  538. Storage *WindowsStorageResources `json:"storage,omitempty"`
  539. }
  540. // WindowsMemoryResources contains memory resource management settings.
  541. type WindowsMemoryResources struct {
  542. // Memory limit in bytes.
  543. Limit *uint64 `json:"limit,omitempty"`
  544. }
  545. // WindowsCPUResources contains CPU resource management settings.
  546. type WindowsCPUResources struct {
  547. // Count is the number of CPUs available to the container. It represents the
  548. // fraction of the configured processor `count` in a container in relation
  549. // to the processors available in the host. The fraction ultimately
  550. // determines the portion of processor cycles that the threads in a
  551. // container can use during each scheduling interval, as the number of
  552. // cycles per 10,000 cycles.
  553. Count *uint64 `json:"count,omitempty"`
  554. // Shares limits the share of processor time given to the container relative
  555. // to other workloads on the processor. The processor `shares` (`weight` at
  556. // the platform level) is a value between 0 and 10000.
  557. Shares *uint16 `json:"shares,omitempty"`
  558. // Maximum determines the portion of processor cycles that the threads in a
  559. // container can use during each scheduling interval, as the number of
  560. // cycles per 10,000 cycles. Set processor `maximum` to a percentage times
  561. // 100.
  562. Maximum *uint16 `json:"maximum,omitempty"`
  563. }
  564. // WindowsStorageResources contains storage resource management settings.
  565. type WindowsStorageResources struct {
  566. // Specifies maximum Iops for the system drive.
  567. Iops *uint64 `json:"iops,omitempty"`
  568. // Specifies maximum bytes per second for the system drive.
  569. Bps *uint64 `json:"bps,omitempty"`
  570. // Sandbox size specifies the minimum size of the system drive in bytes.
  571. SandboxSize *uint64 `json:"sandboxSize,omitempty"`
  572. }
  573. // WindowsNetwork contains network settings for Windows containers.
  574. type WindowsNetwork struct {
  575. // List of HNS endpoints that the container should connect to.
  576. EndpointList []string `json:"endpointList,omitempty"`
  577. // Specifies if unqualified DNS name resolution is allowed.
  578. AllowUnqualifiedDNSQuery bool `json:"allowUnqualifiedDNSQuery,omitempty"`
  579. // Comma separated list of DNS suffixes to use for name resolution.
  580. DNSSearchList []string `json:"DNSSearchList,omitempty"`
  581. // Name (ID) of the container that we will share with the network stack.
  582. NetworkSharedContainerName string `json:"networkSharedContainerName,omitempty"`
  583. // name (ID) of the network namespace that will be used for the container.
  584. NetworkNamespace string `json:"networkNamespace,omitempty"`
  585. }
  586. // WindowsHyperV contains information for configuring a container to run with Hyper-V isolation.
  587. type WindowsHyperV struct {
  588. // UtilityVMPath is an optional path to the image used for the Utility VM.
  589. UtilityVMPath string `json:"utilityVMPath,omitempty"`
  590. }
  591. // VM contains information for virtual-machine-based containers.
  592. type VM struct {
  593. // Hypervisor specifies hypervisor-related configuration for virtual-machine-based containers.
  594. Hypervisor VMHypervisor `json:"hypervisor,omitempty"`
  595. // Kernel specifies kernel-related configuration for virtual-machine-based containers.
  596. Kernel VMKernel `json:"kernel"`
  597. // Image specifies guest image related configuration for virtual-machine-based containers.
  598. Image VMImage `json:"image,omitempty"`
  599. }
  600. // VMHypervisor contains information about the hypervisor to use for a virtual machine.
  601. type VMHypervisor struct {
  602. // Path is the host path to the hypervisor used to manage the virtual machine.
  603. Path string `json:"path"`
  604. // Parameters specifies parameters to pass to the hypervisor.
  605. Parameters []string `json:"parameters,omitempty"`
  606. }
  607. // VMKernel contains information about the kernel to use for a virtual machine.
  608. type VMKernel struct {
  609. // Path is the host path to the kernel used to boot the virtual machine.
  610. Path string `json:"path"`
  611. // Parameters specifies parameters to pass to the kernel.
  612. Parameters []string `json:"parameters,omitempty"`
  613. // InitRD is the host path to an initial ramdisk to be used by the kernel.
  614. InitRD string `json:"initrd,omitempty"`
  615. }
  616. // VMImage contains information about the virtual machine root image.
  617. type VMImage struct {
  618. // Path is the host path to the root image that the VM kernel would boot into.
  619. Path string `json:"path"`
  620. // Format is the root image format type (e.g. "qcow2", "raw", "vhd", etc).
  621. Format string `json:"format"`
  622. }
  623. // LinuxSeccomp represents syscall restrictions
  624. type LinuxSeccomp struct {
  625. DefaultAction LinuxSeccompAction `json:"defaultAction"`
  626. DefaultErrnoRet *uint `json:"defaultErrnoRet,omitempty"`
  627. Architectures []Arch `json:"architectures,omitempty"`
  628. Flags []LinuxSeccompFlag `json:"flags,omitempty"`
  629. ListenerPath string `json:"listenerPath,omitempty"`
  630. ListenerMetadata string `json:"listenerMetadata,omitempty"`
  631. Syscalls []LinuxSyscall `json:"syscalls,omitempty"`
  632. }
  633. // Arch used for additional architectures
  634. type Arch string
  635. // LinuxSeccompFlag is a flag to pass to seccomp(2).
  636. type LinuxSeccompFlag string
  637. const (
  638. // LinuxSeccompFlagLog is a seccomp flag to request all returned
  639. // actions except SECCOMP_RET_ALLOW to be logged. An administrator may
  640. // override this filter flag by preventing specific actions from being
  641. // logged via the /proc/sys/kernel/seccomp/actions_logged file. (since
  642. // Linux 4.14)
  643. LinuxSeccompFlagLog LinuxSeccompFlag = "SECCOMP_FILTER_FLAG_LOG"
  644. // LinuxSeccompFlagSpecAllow can be used to disable Speculative Store
  645. // Bypass mitigation. (since Linux 4.17)
  646. LinuxSeccompFlagSpecAllow LinuxSeccompFlag = "SECCOMP_FILTER_FLAG_SPEC_ALLOW"
  647. // LinuxSeccompFlagWaitKillableRecv can be used to switch to the wait
  648. // killable semantics. (since Linux 5.19)
  649. LinuxSeccompFlagWaitKillableRecv LinuxSeccompFlag = "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV"
  650. )
  651. // Additional architectures permitted to be used for system calls
  652. // By default only the native architecture of the kernel is permitted
  653. const (
  654. ArchX86 Arch = "SCMP_ARCH_X86"
  655. ArchX86_64 Arch = "SCMP_ARCH_X86_64"
  656. ArchX32 Arch = "SCMP_ARCH_X32"
  657. ArchARM Arch = "SCMP_ARCH_ARM"
  658. ArchAARCH64 Arch = "SCMP_ARCH_AARCH64"
  659. ArchMIPS Arch = "SCMP_ARCH_MIPS"
  660. ArchMIPS64 Arch = "SCMP_ARCH_MIPS64"
  661. ArchMIPS64N32 Arch = "SCMP_ARCH_MIPS64N32"
  662. ArchMIPSEL Arch = "SCMP_ARCH_MIPSEL"
  663. ArchMIPSEL64 Arch = "SCMP_ARCH_MIPSEL64"
  664. ArchMIPSEL64N32 Arch = "SCMP_ARCH_MIPSEL64N32"
  665. ArchPPC Arch = "SCMP_ARCH_PPC"
  666. ArchPPC64 Arch = "SCMP_ARCH_PPC64"
  667. ArchPPC64LE Arch = "SCMP_ARCH_PPC64LE"
  668. ArchS390 Arch = "SCMP_ARCH_S390"
  669. ArchS390X Arch = "SCMP_ARCH_S390X"
  670. ArchPARISC Arch = "SCMP_ARCH_PARISC"
  671. ArchPARISC64 Arch = "SCMP_ARCH_PARISC64"
  672. ArchRISCV64 Arch = "SCMP_ARCH_RISCV64"
  673. )
  674. // LinuxSeccompAction taken upon Seccomp rule match
  675. type LinuxSeccompAction string
  676. // Define actions for Seccomp rules
  677. const (
  678. ActKill LinuxSeccompAction = "SCMP_ACT_KILL"
  679. ActKillProcess LinuxSeccompAction = "SCMP_ACT_KILL_PROCESS"
  680. ActKillThread LinuxSeccompAction = "SCMP_ACT_KILL_THREAD"
  681. ActTrap LinuxSeccompAction = "SCMP_ACT_TRAP"
  682. ActErrno LinuxSeccompAction = "SCMP_ACT_ERRNO"
  683. ActTrace LinuxSeccompAction = "SCMP_ACT_TRACE"
  684. ActAllow LinuxSeccompAction = "SCMP_ACT_ALLOW"
  685. ActLog LinuxSeccompAction = "SCMP_ACT_LOG"
  686. ActNotify LinuxSeccompAction = "SCMP_ACT_NOTIFY"
  687. )
  688. // LinuxSeccompOperator used to match syscall arguments in Seccomp
  689. type LinuxSeccompOperator string
  690. // Define operators for syscall arguments in Seccomp
  691. const (
  692. OpNotEqual LinuxSeccompOperator = "SCMP_CMP_NE"
  693. OpLessThan LinuxSeccompOperator = "SCMP_CMP_LT"
  694. OpLessEqual LinuxSeccompOperator = "SCMP_CMP_LE"
  695. OpEqualTo LinuxSeccompOperator = "SCMP_CMP_EQ"
  696. OpGreaterEqual LinuxSeccompOperator = "SCMP_CMP_GE"
  697. OpGreaterThan LinuxSeccompOperator = "SCMP_CMP_GT"
  698. OpMaskedEqual LinuxSeccompOperator = "SCMP_CMP_MASKED_EQ"
  699. )
  700. // LinuxSeccompArg used for matching specific syscall arguments in Seccomp
  701. type LinuxSeccompArg struct {
  702. Index uint `json:"index"`
  703. Value uint64 `json:"value"`
  704. ValueTwo uint64 `json:"valueTwo,omitempty"`
  705. Op LinuxSeccompOperator `json:"op"`
  706. }
  707. // LinuxSyscall is used to match a syscall in Seccomp
  708. type LinuxSyscall struct {
  709. Names []string `json:"names"`
  710. Action LinuxSeccompAction `json:"action"`
  711. ErrnoRet *uint `json:"errnoRet,omitempty"`
  712. Args []LinuxSeccompArg `json:"args,omitempty"`
  713. }
  714. // LinuxIntelRdt has container runtime resource constraints for Intel RDT CAT and MBA
  715. // features and flags enabling Intel RDT CMT and MBM features.
  716. // Intel RDT features are available in Linux 4.14 and newer kernel versions.
  717. type LinuxIntelRdt struct {
  718. // The identity for RDT Class of Service
  719. ClosID string `json:"closID,omitempty"`
  720. // The schema for L3 cache id and capacity bitmask (CBM)
  721. // Format: "L3:<cache_id0>=<cbm0>;<cache_id1>=<cbm1>;..."
  722. L3CacheSchema string `json:"l3CacheSchema,omitempty"`
  723. // The schema of memory bandwidth per L3 cache id
  724. // Format: "MB:<cache_id0>=bandwidth0;<cache_id1>=bandwidth1;..."
  725. // The unit of memory bandwidth is specified in "percentages" by
  726. // default, and in "MBps" if MBA Software Controller is enabled.
  727. MemBwSchema string `json:"memBwSchema,omitempty"`
  728. // EnableCMT is the flag to indicate if the Intel RDT CMT is enabled. CMT (Cache Monitoring Technology) supports monitoring of
  729. // the last-level cache (LLC) occupancy for the container.
  730. EnableCMT bool `json:"enableCMT,omitempty"`
  731. // EnableMBM is the flag to indicate if the Intel RDT MBM is enabled. MBM (Memory Bandwidth Monitoring) supports monitoring of
  732. // total and local memory bandwidth for the container.
  733. EnableMBM bool `json:"enableMBM,omitempty"`
  734. }
  735. // ZOS contains platform-specific configuration for z/OS based containers.
  736. type ZOS struct {
  737. // Devices are a list of device nodes that are created for the container
  738. Devices []ZOSDevice `json:"devices,omitempty"`
  739. }
  740. // ZOSDevice represents the mknod information for a z/OS special device file
  741. type ZOSDevice struct {
  742. // Path to the device.
  743. Path string `json:"path"`
  744. // Device type, block, char, etc.
  745. Type string `json:"type"`
  746. // Major is the device's major number.
  747. Major int64 `json:"major"`
  748. // Minor is the device's minor number.
  749. Minor int64 `json:"minor"`
  750. // FileMode permission bits for the device.
  751. FileMode *os.FileMode `json:"fileMode,omitempty"`
  752. // UID of the device.
  753. UID *uint32 `json:"uid,omitempty"`
  754. // Gid of the device.
  755. GID *uint32 `json:"gid,omitempty"`
  756. }
  757. // LinuxSchedulerPolicy represents different scheduling policies used with the Linux Scheduler
  758. type LinuxSchedulerPolicy string
  759. const (
  760. // SchedOther is the default scheduling policy
  761. SchedOther LinuxSchedulerPolicy = "SCHED_OTHER"
  762. // SchedFIFO is the First-In-First-Out scheduling policy
  763. SchedFIFO LinuxSchedulerPolicy = "SCHED_FIFO"
  764. // SchedRR is the Round-Robin scheduling policy
  765. SchedRR LinuxSchedulerPolicy = "SCHED_RR"
  766. // SchedBatch is the Batch scheduling policy
  767. SchedBatch LinuxSchedulerPolicy = "SCHED_BATCH"
  768. // SchedISO is the Isolation scheduling policy
  769. SchedISO LinuxSchedulerPolicy = "SCHED_ISO"
  770. // SchedIdle is the Idle scheduling policy
  771. SchedIdle LinuxSchedulerPolicy = "SCHED_IDLE"
  772. // SchedDeadline is the Deadline scheduling policy
  773. SchedDeadline LinuxSchedulerPolicy = "SCHED_DEADLINE"
  774. )
  775. // LinuxSchedulerFlag represents the flags used by the Linux Scheduler.
  776. type LinuxSchedulerFlag string
  777. const (
  778. // SchedFlagResetOnFork represents the reset on fork scheduling flag
  779. SchedFlagResetOnFork LinuxSchedulerFlag = "SCHED_FLAG_RESET_ON_FORK"
  780. // SchedFlagReclaim represents the reclaim scheduling flag
  781. SchedFlagReclaim LinuxSchedulerFlag = "SCHED_FLAG_RECLAIM"
  782. // SchedFlagDLOverrun represents the deadline overrun scheduling flag
  783. SchedFlagDLOverrun LinuxSchedulerFlag = "SCHED_FLAG_DL_OVERRUN"
  784. // SchedFlagKeepPolicy represents the keep policy scheduling flag
  785. SchedFlagKeepPolicy LinuxSchedulerFlag = "SCHED_FLAG_KEEP_POLICY"
  786. // SchedFlagKeepParams represents the keep parameters scheduling flag
  787. SchedFlagKeepParams LinuxSchedulerFlag = "SCHED_FLAG_KEEP_PARAMS"
  788. // SchedFlagUtilClampMin represents the utilization clamp minimum scheduling flag
  789. SchedFlagUtilClampMin LinuxSchedulerFlag = "SCHED_FLAG_UTIL_CLAMP_MIN"
  790. // SchedFlagUtilClampMin represents the utilization clamp maximum scheduling flag
  791. SchedFlagUtilClampMax LinuxSchedulerFlag = "SCHED_FLAG_UTIL_CLAMP_MAX"
  792. )