Debian Codegraph @

specs-go/config.go

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