config.go 23 KB

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