Class: AWSCDK::Batch::EKSContainerDefinitionProps

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
batch/eks_container_definition_props.rb

Overview

Props to configure an EksContainerDefinition.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image:, args: nil, command: nil, cpu_limit: nil, cpu_reservation: nil, env: nil, gpu_limit: nil, gpu_reservation: nil, image_pull_policy: nil, memory_limit: nil, memory_reservation: nil, name: nil, privileged: nil, readonly_root_filesystem: nil, run_as_group: nil, run_as_root: nil, run_as_user: nil, volumes: nil) ⇒ EKSContainerDefinitionProps

Returns a new instance of EKSContainerDefinitionProps.

Parameters:

  • image (AWSCDK::ECS::ContainerImage)

    The image that this container will run.

  • args (Array<String>, nil) (defaults to: nil)

    An array of arguments to the entrypoint.

  • command (Array<String>, nil) (defaults to: nil)

    The entrypoint for the container.

  • cpu_limit (Numeric, nil) (defaults to: nil)

    The hard limit of CPUs to present to this container. Must be an even multiple of 0.25.

  • cpu_reservation (Numeric, nil) (defaults to: nil)

    The soft limit of CPUs to reserve for the container Must be an even multiple of 0.25.

  • env (Hash{String => String}, nil) (defaults to: nil)

    The environment variables to pass to this container.

  • gpu_limit (Numeric, nil) (defaults to: nil)

    The hard limit of GPUs to present to this container.

  • gpu_reservation (Numeric, nil) (defaults to: nil)

    The soft limit of CPUs to reserve for the container Must be an even multiple of 0.25.

  • image_pull_policy (AWSCDK::Batch::ImagePullPolicy, nil) (defaults to: nil)

    The image pull policy for this container.

  • memory_limit (AWSCDK::Size, nil) (defaults to: nil)

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

  • memory_reservation (AWSCDK::Size, nil) (defaults to: nil)

    The soft limit (in MiB) of memory to reserve for the container.

  • name (String, nil) (defaults to: nil)

    The name of this container.

  • privileged (Boolean, nil) (defaults to: nil)

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

  • readonly_root_filesystem (Boolean, nil) (defaults to: nil)

    If specified, gives this container readonly access to its root file system.

  • run_as_group (Numeric, nil) (defaults to: nil)

    If specified, the container is run as the specified group ID (gid).

  • run_as_root (Boolean, nil) (defaults to: nil)

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

  • run_as_user (Numeric, nil) (defaults to: nil)

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

  • volumes (Array<AWSCDK::Batch::EKSVolume>, nil) (defaults to: nil)

    The Volumes to mount to this container.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'batch/eks_container_definition_props.rb', line 25

def initialize(image:, args: nil, command: nil, cpu_limit: nil, cpu_reservation: nil, env: nil, gpu_limit: nil, gpu_reservation: nil, image_pull_policy: nil, memory_limit: nil, memory_reservation: nil, name: nil, privileged: nil, readonly_root_filesystem: nil, run_as_group: nil, run_as_root: nil, run_as_user: nil, volumes: nil)
  @image = image
  Jsii::Type.check_type(@image, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNvbnRhaW5lckltYWdlIn0=")), "image")
  @args = args
  Jsii::Type.check_type(@args, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "args") unless @args.nil?
  @command = command
  Jsii::Type.check_type(@command, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "command") unless @command.nil?
  @cpu_limit = cpu_limit
  Jsii::Type.check_type(@cpu_limit, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "cpuLimit") unless @cpu_limit.nil?
  @cpu_reservation = cpu_reservation
  Jsii::Type.check_type(@cpu_reservation, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "cpuReservation") unless @cpu_reservation.nil?
  @env = env
  Jsii::Type.check_type(@env, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "env") unless @env.nil?
  @gpu_limit = gpu_limit
  Jsii::Type.check_type(@gpu_limit, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "gpuLimit") unless @gpu_limit.nil?
  @gpu_reservation = gpu_reservation
  Jsii::Type.check_type(@gpu_reservation, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "gpuReservation") unless @gpu_reservation.nil?
  @image_pull_policy = image_pull_policy
  Jsii::Type.check_type(@image_pull_policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYmF0Y2guSW1hZ2VQdWxsUG9saWN5In0=")), "imagePullPolicy") unless @image_pull_policy.nil?
  @memory_limit = memory_limit
  Jsii::Type.check_type(@memory_limit, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TaXplIn0=")), "memoryLimit") unless @memory_limit.nil?
  @memory_reservation = memory_reservation
  Jsii::Type.check_type(@memory_reservation, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TaXplIn0=")), "memoryReservation") unless @memory_reservation.nil?
  @name = name
  Jsii::Type.check_type(@name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "name") unless @name.nil?
  @privileged = privileged
  Jsii::Type.check_type(@privileged, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "privileged") unless @privileged.nil?
  @readonly_root_filesystem = readonly_root_filesystem
  Jsii::Type.check_type(@readonly_root_filesystem, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "readonlyRootFilesystem") unless @readonly_root_filesystem.nil?
  @run_as_group = run_as_group
  Jsii::Type.check_type(@run_as_group, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "runAsGroup") unless @run_as_group.nil?
  @run_as_root = run_as_root
  Jsii::Type.check_type(@run_as_root, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "runAsRoot") unless @run_as_root.nil?
  @run_as_user = run_as_user
  Jsii::Type.check_type(@run_as_user, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "runAsUser") unless @run_as_user.nil?
  @volumes = volumes
  Jsii::Type.check_type(@volumes, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19iYXRjaC5Fa3NWb2x1bWUifSwia2luZCI6ImFycmF5In19")), "volumes") unless @volumes.nil?
end

Instance Attribute Details

#argsArray<String>? (readonly)

Note:

Default: - no args

An array of arguments to the entrypoint.

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.



81
82
83
# File 'batch/eks_container_definition_props.rb', line 81

def args
  @args
end

#commandArray<String>? (readonly)

Note:

Default: - no command

The entrypoint for the container.

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.



97
98
99
# File 'batch/eks_container_definition_props.rb', line 97

def command
  @command
end

#cpu_limitNumeric? (readonly)

Note:

Default: - No CPU limit

The hard limit of CPUs to present to this container. Must be an even multiple of 0.25.

If your container attempts to exceed this limit, it will be terminated.

At least one of cpu_reservation and cpu_limit is required. If both are specified, then cpu_limit must be at least as large as cpu_reservation.



108
109
110
# File 'batch/eks_container_definition_props.rb', line 108

def cpu_limit
  @cpu_limit
end

#cpu_reservationNumeric? (readonly)

Note:

Default: - No CPUs reserved

The soft limit of CPUs to reserve for the container Must be an even multiple of 0.25.

The container will given at least this many CPUs, but may consume more.

At least one of cpu_reservation and cpu_limit is required. If both are specified, then cpu_limit must be at least as large as cpu_reservation.



119
120
121
# File 'batch/eks_container_definition_props.rb', line 119

def cpu_reservation
  @cpu_reservation
end

#envHash{String => String}? (readonly)

Note:

Default: - no environment variables

The environment variables to pass to this container.

Note: Environment variables cannot start with "AWS_BATCH". This naming convention is reserved for variables that AWS Batch sets.

Returns:

  • (Hash{String => String}, nil)


127
128
129
# File 'batch/eks_container_definition_props.rb', line 127

def env
  @env
end

#gpu_limitNumeric? (readonly)

Note:

Default: - No GPU limit

The hard limit of GPUs to present to this container.

If your container attempts to exceed this limit, it will be terminated.

If both gpu_reservation and gpu_limit are specified, then gpu_limit must be equal to gpu_reservation.



137
138
139
# File 'batch/eks_container_definition_props.rb', line 137

def gpu_limit
  @gpu_limit
end

#gpu_reservationNumeric? (readonly)

Note:

Default: - No GPUs reserved

The soft limit of CPUs to reserve for the container Must be an even multiple of 0.25.

The container will given at least this many CPUs, but may consume more.

If both gpu_reservation and gpu_limit are specified, then gpu_limit must be equal to gpu_reservation.



147
148
149
# File 'batch/eks_container_definition_props.rb', line 147

def gpu_reservation
  @gpu_reservation
end

#imageAWSCDK::ECS::ContainerImage (readonly)

The image that this container will run.



67
68
69
# File 'batch/eks_container_definition_props.rb', line 67

def image
  @image
end

#image_pull_policyAWSCDK::Batch::ImagePullPolicy? (readonly)

Note:

Default: - ALWAYS if the :latest tag is specified, IF_NOT_PRESENT otherwise

The image pull policy for this container.



153
154
155
# File 'batch/eks_container_definition_props.rb', line 153

def image_pull_policy
  @image_pull_policy
end

#memory_limitAWSCDK::Size? (readonly)

Note:

Default: - No memory limit

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

If your container attempts to exceed the allocated memory, it will be terminated.

Must be larger that 4 MiB

At least one of memory_limit and memory_reservation 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.



168
169
170
# File 'batch/eks_container_definition_props.rb', line 168

def memory_limit
  @memory_limit
end

#memory_reservationAWSCDK::Size? (readonly)

Note:

Default: - No memory reserved

The soft limit (in MiB) of memory to reserve for the container.

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 memory_limit and memory_reservation is required. If both are specified, then memory_limit must be equal to memory_reservation

Note: To maximize your resource utilization, provide your jobs with as much memory as possible for the specific instance type that you are using.



190
191
192
# File 'batch/eks_container_definition_props.rb', line 190

def memory_reservation
  @memory_reservation
end

#nameString? (readonly)

Note:

Default: : 'Default'

The name of this container.

Returns:

  • (String, nil)


195
196
197
# File 'batch/eks_container_definition_props.rb', line 195

def name
  @name
end

#privilegedBoolean? (readonly)

Note:

Default: false

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

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



207
208
209
# File 'batch/eks_container_definition_props.rb', line 207

def privileged
  @privileged
end

#readonly_root_filesystemBoolean? (readonly)

Note:

Default: false

If specified, gives this container readonly access to its root file system.

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



217
218
219
# File 'batch/eks_container_definition_props.rb', line 217

def readonly_root_filesystem
  @readonly_root_filesystem
end

#run_as_groupNumeric? (readonly)

Note:

Default: none

If specified, the container is run as the specified group ID (gid).

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



228
229
230
# File 'batch/eks_container_definition_props.rb', line 228

def run_as_group
  @run_as_group
end

#run_as_rootBoolean? (readonly)

Note:

Default: - the container is not required to run as a non-root user

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

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



239
240
241
# File 'batch/eks_container_definition_props.rb', line 239

def run_as_root
  @run_as_root
end

#run_as_userNumeric? (readonly)

Note:

Default: - the user that is specified in the image metadata.

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

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



249
250
251
# File 'batch/eks_container_definition_props.rb', line 249

def run_as_user
  @run_as_user
end

#volumesArray<AWSCDK::Batch::EKSVolume>? (readonly)

Note:

Default: - no volumes

The Volumes to mount to this container.

Automatically added to the Pod.



257
258
259
# File 'batch/eks_container_definition_props.rb', line 257

def volumes
  @volumes
end

Class Method Details

.jsii_propertiesObject



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'batch/eks_container_definition_props.rb', line 259

def self.jsii_properties
  {
    :image => "image",
    :args => "args",
    :command => "command",
    :cpu_limit => "cpuLimit",
    :cpu_reservation => "cpuReservation",
    :env => "env",
    :gpu_limit => "gpuLimit",
    :gpu_reservation => "gpuReservation",
    :image_pull_policy => "imagePullPolicy",
    :memory_limit => "memoryLimit",
    :memory_reservation => "memoryReservation",
    :name => "name",
    :privileged => "privileged",
    :readonly_root_filesystem => "readonlyRootFilesystem",
    :run_as_group => "runAsGroup",
    :run_as_root => "runAsRoot",
    :run_as_user => "runAsUser",
    :volumes => "volumes",
  }
end

Instance Method Details

#to_jsiiObject



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'batch/eks_container_definition_props.rb', line 282

def to_jsii
  result = {}
  result.merge!({
    "image" => @image,
    "args" => @args,
    "command" => @command,
    "cpuLimit" => @cpu_limit,
    "cpuReservation" => @cpu_reservation,
    "env" => @env,
    "gpuLimit" => @gpu_limit,
    "gpuReservation" => @gpu_reservation,
    "imagePullPolicy" => @image_pull_policy,
    "memoryLimit" => @memory_limit,
    "memoryReservation" => @memory_reservation,
    "name" => @name,
    "privileged" => @privileged,
    "readonlyRootFilesystem" => @readonly_root_filesystem,
    "runAsGroup" => @run_as_group,
    "runAsRoot" => @run_as_root,
    "runAsUser" => @run_as_user,
    "volumes" => @volumes,
  })
  result.compact
end