Show / Hide Table of Contents

Class EksContainerDefinition

A container that can be run with EKS orchestration on EC2 resources.

Inheritance
object
EksContainerDefinition
Implements
IEksContainerDefinition
IConstruct
IDependable
Namespace: Amazon.CDK.AWS.Batch
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class EksContainerDefinition : Construct, IEksContainerDefinition, IConstruct, IDependable
Syntax (vb)
Public Class EksContainerDefinition Inherits Construct Implements IEksContainerDefinition, IConstruct, IDependable
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(Construct, string, IEksContainerDefinitionProps)

A container that can be run with EKS orchestration on EC2 resources.

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.

PROPERTY_INJECTION_ID

Uniquely identifies this class.

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 (gid).

RunAsRoot

If specified, the container is run as a user with a uid other than 0.

RunAsUser

If specified, this container is run as the specified user ID (uid).

Volumes

The Volumes to mount to this container.

Methods

AddVolume(EksVolume)

Mount a Volume to this container.

Constructors

EksContainerDefinition(Construct, string, IEksContainerDefinitionProps)

A container that can be run with EKS orchestration on EC2 resources.

public EksContainerDefinition(Construct scope, string id, IEksContainerDefinitionProps props)
Parameters
scope Construct
id string
props IEksContainerDefinitionProps
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)
                    }) }
                })
            });

Properties

Args

An array of arguments to the entrypoint.

public virtual string[]? Args { get; }
Property Value

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

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)."</code> <code>$\) 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 double? CpuLimit { get; }
Property Value

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 double? CpuReservation { get; }
Property Value

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

IDictionary<string, 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 double? GpuLimit { get; }
Property Value

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 double? GpuReservation { get; }
Property Value

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

ContainerImage

Remarks

ExampleMetadata: infused

ImagePullPolicy

The image pull policy for this container.

public virtual ImagePullPolicy? ImagePullPolicy { get; }
Property Value

ImagePullPolicy?

Remarks

ExampleMetadata: infused

MemoryLimit

The amount (in MiB) of memory to present to the container.

public virtual Size? MemoryLimit { get; }
Property Value

Size

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

Size

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

string

Remarks

ExampleMetadata: infused

PROPERTY_INJECTION_ID

Uniquely identifies this class.

public static string PROPERTY_INJECTION_ID { get; }
Property Value

string

Remarks

ExampleMetadata: infused

Privileged

If specified, gives this container elevated permissions on the host container instance.

public virtual bool? Privileged { get; }
Property Value

bool?

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 bool? ReadonlyRootFilesystem { get; }
Property Value

bool?

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 double? RunAsGroup { get; }
Property Value

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 bool? RunAsRoot { get; }
Property Value

bool?

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 double? RunAsUser { get; }
Property Value

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

EksVolume[]

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.

Implements

IEksContainerDefinition
Constructs.IConstruct
Constructs.IDependable
Back to top Generated by DocFX