Class EksContainerDefinition
A container that can be run with EKS orchestration on EC2 resources.
Inheritance
Namespace: Amazon.CDK.AWS.Batch
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class EksContainerDefinition : Construct, IEksContainerDefinition
Syntax (vb)
Public Class EksContainerDefinition
Inherits Construct
Implements IEksContainerDefinition
Remarks
ExampleMetadata: infused
Examples
var jobDefn = new EksJobDefinition(this, "eksf2", new EksJobDefinitionProps {
Container = new EksContainerDefinition(this, "container", new EksContainerDefinitionProps {
Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
Volumes = new [] { EksVolume.EmptyDir(new EmptyDirVolumeOptions {
Name = "myEmptyDirVolume",
MountPath = "/mount/path",
Medium = EmptyDirMediumType.MEMORY,
Readonly = true,
SizeLimit = Size.Mebibytes(2048)
}) }
})
});
Synopsis
Constructors
EksContainerDefinition(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
EksContainerDefinition(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
EksContainerDefinition(Construct, String, IEksContainerDefinitionProps) |
Properties
Args | An array of arguments to the entrypoint. |
Command | The entrypoint for the container. |
CpuLimit | The hard limit of CPUs to present to this container. Must be an even multiple of 0.25. |
CpuReservation | The soft limit of CPUs to reserve for the container Must be an even multiple of 0.25. |
Env | The environment variables to pass to this container. |
GpuLimit | The hard limit of GPUs to present to this container. |
GpuReservation | The soft limit of CPUs to reserve for the container Must be an even multiple of 0.25. |
Image | The image that this container will run. |
ImagePullPolicy | The image pull policy for this container. |
MemoryLimit | The amount (in MiB) of memory to present to the container. |
MemoryReservation | The soft limit (in MiB) of memory to reserve for the container. |
Name | The name of this container. |
Privileged | If specified, gives this container elevated permissions on the host container instance. |
ReadonlyRootFilesystem | If specified, gives this container readonly access to its root file system. |
RunAsGroup | If specified, the container is run as the specified group ID ( |
RunAsRoot | If specified, the container is run as a user with a |
RunAsUser | If specified, this container is run as the specified user ID ( |
Volumes | The Volumes to mount to this container. |
Methods
AddVolume(EksVolume) | Mount a Volume to this container. |
Constructors
EksContainerDefinition(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected EksContainerDefinition(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
EksContainerDefinition(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected EksContainerDefinition(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
EksContainerDefinition(Construct, String, IEksContainerDefinitionProps)
public EksContainerDefinition(Construct scope, string id, IEksContainerDefinitionProps props)
Parameters
- scope Constructs.Construct
- id System.String
- props IEksContainerDefinitionProps
Properties
Args
An array of arguments to the entrypoint.
public virtual string[] Args { get; }
Property Value
System.String[]
Remarks
If this isn't specified, the CMD of the container image is used. This corresponds to the args member in the Entrypoint portion of the Pod in Kubernetes. Environment variable references are expanded using the container's environment. If the referenced environment variable doesn't exist, the reference in the command isn't changed. For example, if the reference is to "$(NAME1)" and the NAME1 environment variable doesn't exist, the command string will remain "$(NAME1)." $$ is replaced with $, and the resulting string isn't expanded. or example, $$(VAR_NAME) is passed as $(VAR_NAME) whether or not the VAR_NAME environment variable exists.
Command
The entrypoint for the container.
public virtual string[] Command { get; }
Property Value
System.String[]
Remarks
This isn't run within a shell.
If this isn't specified, the ENTRYPOINT
of the container image is used.
Environment variable references are expanded using the container's environment.
If the referenced environment variable doesn't exist, the reference in the command isn't changed.
For example, if the reference is to "$(NAME1)"
and the NAME1
environment variable doesn't exist,
the command string will remain "$(NAME1)."
$$
is replaced with $
and the resulting string isn't expanded.
For example, $$(VAR_NAME)
will be passed as $(VAR_NAME)
whether or not the VAR_NAME
environment variable exists.
The entrypoint can't be updated.
CpuLimit
The hard limit of CPUs to present to this container. Must be an even multiple of 0.25.
public virtual Nullable<double> CpuLimit { get; }
Property Value
System.Nullable<System.Double>
Remarks
If your container attempts to exceed this limit, it will be terminated.
At least one of cpuReservation
and cpuLimit
is required.
If both are specified, then cpuLimit
must be at least as large as cpuReservation
.
CpuReservation
The soft limit of CPUs to reserve for the container Must be an even multiple of 0.25.
public virtual Nullable<double> CpuReservation { get; }
Property Value
System.Nullable<System.Double>
Remarks
The container will given at least this many CPUs, but may consume more.
At least one of cpuReservation
and cpuLimit
is required.
If both are specified, then cpuLimit
must be at least as large as cpuReservation
.
Env
The environment variables to pass to this container.
public virtual IDictionary<string, string> Env { get; }
Property Value
System.Collections.Generic.IDictionary<System.String, System.String>
Remarks
Note: Environment variables cannot start with "AWS_BATCH". This naming convention is reserved for variables that AWS Batch sets.
GpuLimit
The hard limit of GPUs to present to this container.
public virtual Nullable<double> GpuLimit { get; }
Property Value
System.Nullable<System.Double>
Remarks
If your container attempts to exceed this limit, it will be terminated.
If both gpuReservation
and gpuLimit
are specified, then gpuLimit
must be equal to gpuReservation
.
GpuReservation
The soft limit of CPUs to reserve for the container Must be an even multiple of 0.25.
public virtual Nullable<double> GpuReservation { get; }
Property Value
System.Nullable<System.Double>
Remarks
The container will given at least this many CPUs, but may consume more.
If both gpuReservation
and gpuLimit
are specified, then gpuLimit
must be equal to gpuReservation
.
Image
The image that this container will run.
public virtual ContainerImage Image { get; }
Property Value
ImagePullPolicy
The image pull policy for this container.
public virtual Nullable<ImagePullPolicy> ImagePullPolicy { get; }
Property Value
System.Nullable<ImagePullPolicy>
MemoryLimit
The amount (in MiB) of memory to present to the container.
public virtual Size MemoryLimit { get; }
Property Value
Remarks
If your container attempts to exceed the allocated memory, it will be terminated.
Must be larger that 4 MiB
At least one of memoryLimit
and memoryReservation
is required
Note: To maximize your resource utilization, provide your jobs with as much memory as possible for the specific instance type that you are using.
MemoryReservation
The soft limit (in MiB) of memory to reserve for the container.
public virtual Size MemoryReservation { get; }
Property Value
Remarks
Your container will be given at least this much memory, but may consume more.
Must be larger that 4 MiB
When system memory is under heavy contention, Docker attempts to keep the container memory to this soft limit. However, your container can consume more memory when it needs to, up to either the hard limit specified with the memory parameter (if applicable), or all of the available memory on the container instance, whichever comes first.
At least one of memoryLimit
and memoryReservation
is required.
If both are specified, then memoryLimit
must be equal to memoryReservation
Note: To maximize your resource utilization, provide your jobs with as much memory as possible for the specific instance type that you are using.
Name
The name of this container.
public virtual string Name { get; }
Property Value
System.String
Privileged
If specified, gives this container elevated permissions on the host container instance.
public virtual Nullable<bool> Privileged { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
The level of permissions are similar to the root user permissions.
This parameter maps to privileged
policy in the Privileged pod security policies in the Kubernetes documentation.
Note: this is only compatible with Kubernetes < v1.25
ReadonlyRootFilesystem
If specified, gives this container readonly access to its root file system.
public virtual Nullable<bool> ReadonlyRootFilesystem { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
This parameter maps to ReadOnlyRootFilesystem
policy in the Volumes and file systems pod security policies in the Kubernetes documentation.
Note: this is only compatible with Kubernetes < v1.25
RunAsGroup
If specified, the container is run as the specified group ID (gid
).
public virtual Nullable<double> RunAsGroup { get; }
Property Value
System.Nullable<System.Double>
Remarks
If this parameter isn't specified, the default is the group that's specified in the image metadata.
This parameter maps to RunAsGroup
and MustRunAs
policy in the Users and groups pod security policies in the Kubernetes documentation.
Note: this is only compatible with Kubernetes < v1.25
RunAsRoot
If specified, the container is run as a user with a uid
other than 0.
public virtual Nullable<bool> RunAsRoot { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Otherwise, no such rule is enforced.
This parameter maps to RunAsUser
and MustRunAsNonRoot
policy in the Users and groups pod security policies in the Kubernetes documentation.
Note: this is only compatible with Kubernetes < v1.25
RunAsUser
If specified, this container is run as the specified user ID (uid
).
public virtual Nullable<double> RunAsUser { get; }
Property Value
System.Nullable<System.Double>
Remarks
This parameter maps to RunAsUser
and MustRunAs
policy in the Users and groups pod security policies in the Kubernetes documentation.
Note: this is only compatible with Kubernetes < v1.25
Volumes
The Volumes to mount to this container.
public virtual EksVolume[] Volumes { get; }
Property Value
Remarks
Automatically added to the Pod.
Methods
AddVolume(EksVolume)
Mount a Volume to this container.
public virtual void AddVolume(EksVolume volume)
Parameters
- volume EksVolume
Remarks
Automatically added to the Pod.