Class Job

  • All Implemented Interfaces:
    IPodSpec, IPodTemplate, IResource, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

    @Generated(value="jsii-pacmak/1.56.0 (build 55e7d15)",
               date="2022-04-13T14:52:28.886Z")
    @Stability(Stable)
    public class Job
    extends Resource
    implements IPodTemplate
    A Job creates one or more Pods and ensures that a specified number of them successfully terminate.

    As pods successfully complete, the Job tracks the successful completions. When a specified number of successful completions is reached, the task (ie, Job) is complete. Deleting a Job will clean up the Pods it created. A simple case is to create one Job object in order to reliably run one Pod to completion. The Job object will start a new Pod if the first Pod fails or is deleted (for example due to a node hardware failure or a node reboot). You can also use a Job to run multiple Pods in parallel.

    • Constructor Detail

      • Job

        protected Job​(software.amazon.jsii.JsiiObjectRef objRef)
      • Job

        protected Job​(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
      • Job

        @Stability(Stable)
        public Job​(@NotNull
                   software.constructs.Construct scope,
                   @NotNull
                   String id,
                   @Nullable
                   JobProps props)
        Parameters:
        scope - This parameter is required.
        id - This parameter is required.
        props -
      • Job

        @Stability(Stable)
        public Job​(@NotNull
                   software.constructs.Construct scope,
                   @NotNull
                   String id)
        Parameters:
        scope - This parameter is required.
        id - This parameter is required.
    • Method Detail

      • addContainer

        @Stability(Stable)
        @NotNull
        public Container addContainer​(@NotNull
                                      ContainerProps container)
        Add a container to the pod.

        Specified by:
        addContainer in interface IPodSpec
        Parameters:
        container - This parameter is required.
      • addHostAlias

        @Stability(Stable)
        public void addHostAlias​(@NotNull
                                 HostAlias hostAlias)
        Parameters:
        hostAlias - This parameter is required.
      • addInitContainer

        @Stability(Stable)
        @NotNull
        public Container addInitContainer​(@NotNull
                                          ContainerProps container)
        Add an init container to the pod.

        Specified by:
        addInitContainer in interface IPodSpec
        Parameters:
        container - This parameter is required.
      • addVolume

        @Stability(Stable)
        public void addVolume​(@NotNull
                              Volume volume)
        Add a volume to the pod.

        Specified by:
        addVolume in interface IPodSpec
        Parameters:
        volume - This parameter is required.
      • getApiObject

        @Stability(Stable)
        @NotNull
        protected org.cdk8s.ApiObject getApiObject()
        The underlying cdk8s API object.

        Specified by:
        getApiObject in class Resource
        See Also:
        base.Resource.apiObject
      • getContainers

        @Stability(Stable)
        @NotNull
        public List<Container> getContainers()
        The containers belonging to the pod.

        Use addContainer to add containers.

        Specified by:
        getContainers in interface IPodSpec
      • getHostAliases

        @Stability(Stable)
        @NotNull
        public List<HostAlias> getHostAliases()
        An optional list of hosts and IPs that will be injected into the pod's hosts file if specified.

        This is only valid for non-hostNetwork pods.

        Specified by:
        getHostAliases in interface IPodSpec
      • getInitContainers

        @Stability(Stable)
        @NotNull
        public List<Container> getInitContainers()
        The init containers belonging to the pod.

        Use addInitContainer to add init containers.

        Specified by:
        getInitContainers in interface IPodSpec
      • getPodMetadata

        @Stability(Stable)
        @NotNull
        public org.cdk8s.ApiObjectMetadataDefinition getPodMetadata()
        Provides read/write access to the underlying pod metadata of the resource.
        Specified by:
        getPodMetadata in interface IPodTemplate
      • getSecurityContext

        @Stability(Stable)
        @NotNull
        public PodSecurityContext getSecurityContext()
      • getVolumes

        @Stability(Stable)
        @NotNull
        public List<Volume> getVolumes()
        The volumes associated with this pod.

        Use addVolume to add volumes.

        Specified by:
        getVolumes in interface IPodSpec
      • getActiveDeadline

        @Stability(Stable)
        @Nullable
        public org.cdk8s.Duration getActiveDeadline()
        Duration before job is terminated.

        If undefined, there is no deadline.

      • getBackoffLimit

        @Stability(Stable)
        @Nullable
        public Number getBackoffLimit()
        Number of retries before marking failed.
      • getRestartPolicy

        @Stability(Stable)
        @Nullable
        public RestartPolicy getRestartPolicy()
        Restart policy for all containers within the pod.
        Specified by:
        getRestartPolicy in interface IPodSpec
      • getTtlAfterFinished

        @Stability(Stable)
        @Nullable
        public org.cdk8s.Duration getTtlAfterFinished()
        TTL before the job is deleted after it is finished.