Jobs

Create Kubernetes Jobs in AWS and GCP from the DuploCloud Portal

In Kubernetes, a Job is a controller object representing a task or a set of tasks that runs until successful completion. It is designed to manage short-lived batch workloads in a Kubernetes cluster. Use a Kubernetes Job when you need to run a task or a set of tasks once, to completion, rather than continuously, as in other types of controllers like Deployments.

Refer to the Kubernetes Job documentation for use cases and examples of when to use Kubernetes Jobs.

Using Kubernetes Jobs for Pod management

Pods are the smallest deployable computing units that you can create and manage in Kubernetes. A Pod is a group of one or more containers with shared storage and network resources, including a specification that dictates how to run the containers. A Pod's contents are always co-located and co-scheduled and run in a shared context. A Pod models an application-specific "logical host": it contains one or more tightly coupled application containers.

In the DuploCloud Portal, you can create K8s Jobs to create one or more Pods. The Job retries until a specified number of Pods are successfully executed. Kubernetes Jobs tracks successful terminations. When the specified number of successful terminations are completed, the Job is marked as completed in Kubernetes. Deleting a Kubernetes Job cleans up the Pods that it created. Suspending a Kubernetes Job deletes its active Pods until it is resumed again.

You typically create one Kubernetes Job object to run one Pod to completion reliably. The Job object starts a new Pod if the first Pod fails or is deleted (for example, in case of a node hardware failure or a node reboot).

You can also use a Kubernetes Job to run multiple Pods in parallel. If you want to run a Kubernetes Job (a single task or several in parallel) on a schedule, see Kubernetes CronJobs.

Creating a Kubernetes Job in the DuploCloud portal

  1. In the DuploCloud Portal, select the Tenant from the Tenant list box at the top-left of the DuploCloud Portal.

  2. Navigate to Kubernetes -> Job.

  3. Click Add. The Add Kubernetes Job page displays.

  4. In the Basic Options step, specify the Kubernetes Job name.

  5. In the Container - 1 area, specify the Container Name and associated Docker Image.

  1. In the Command field, specify the command attributes for Container - 1. Click the Info Tip icon for examples. Select and copy commands as needed.

  2. In the Command field, specify the command attributes for Container - 1. Click the Info Tip icon for examples. Select and Copy commands as needed.

  1. In the Init Container - 1 area, specify the Container Name and associated Docker Image.

  2. Click Next to open the Advanced Configuration step.

  3. In the Other Spec Configuration field, specify the Kubernetes Job spec (in YAML) for Init Container - 1. Click the Info Tip icon for examples. Select and copy commands as needed.

  4. Click Create. The Kubernetes Job is created and displayed on the Job page with a status of Active.

  5. In the Init Container - 1 area, specify the Container Name and associated Docker Image.

  6. Click Next to open the Advanced Configuration step.

  7. In the Other Spec Configuration field, specify the Kubernetes Job spec (in YAML) for Init Container - 1. Click the Info Tip icon for examples. Select and Copy commands as needed.

  8. Click Create. The job is created and displayed on the Job page with a status of Active.

Using Allocation Tags with Kubernetes Jobs

Allocation tags for Kubernetes Jobs (labels, node selectors, or node affinity) help manage resources in a Kubernetes environment. They can be useful for:

  • Resource Organization

  • Scheduling and Affinity Rules

  • Resource Quotas and Limits

  • Monitoring and Logging

  • Cost Allocation and Billing

You can add allocation tags in the Allocation Tag field when creating Kubernetes Jobs.

In the YAML below, the following act as allocation tags:

  • labels are key-value pairs used to organize, categorize, and identify resources such as Pods, Nodes, Jobs, and more. Thecompliance: HIPAA label applied in the example indicates that the Kubernetes Job is associated with a HIPAA compliance context.

  • nodeSelector specifies that the Kubernetes Job should be scheduled on specific nodes. In this example, it will be scheduled on nodes with the label security-level: high.

  labels:
    compliance: HIPAA
spec:
  template:
    spec:
      nodeSelector:
        security-level: high

To learn more about allocation tags for Kubernetes Jobs, see the Kubernetes documentation on labels and selectors and node selectors and node affinity.

Managing Kubernetes Jobs faults

You can manage/override Kubernetes Jobs faults on a Tenant or Job level. If a Job fails, and no Tenant- or Job-level fault setting is configured, DuploCloud will generate a fault by default.

Tenant-level Kubernetes Jobs faults

Enable or disable faults for failed Kubernetes Jobs in a specific Tenant.

  1. From the DuploCloud Portal, navigate to Administrator -> Tenant.

  2. Click the Tenant name in the NAME column.

  3. Select the Settings tab, and click Add. The Add Tenant Feature pane displays.

  4. From the Select Feature list box, select Enable K8s job fault logging by default, and use the toggle switch to enable or disable the setting.

  5. Click Add. The Jobs fault setting is added.

You can view the Jobs fault setting on the Tenants page (Navigate to Administrator -> Tenant, select the Tenant name) under the Settings tab. If the value is true, DuploCloud will generate a fault. If the value is false, DuploCloud will not generate a fault.

Jobs-level Kubernetes Jobs faults

You can configure the faults for a specific Job when creating the Job in DuploCloud. Fault settings added this way override Tenant-level settings. On the Add Kubernetes Job page, in the Metadata Annotations field, enter:

duplocloud.net/fault/when-failed: true. or

duplocloud.net/fault/when-failed: false.

When the value is true and the Job fails, DuploCloud will generate a fault. When the value is false and the Job fails, a fault will not be generated.

Viewing a Kubernetes Job

  1. In the DuploCloud Portal, navigate to Kubernetes -> Job.

  2. Select the Kubernetes Job you want to view and click the Overview, Containers, and Details tabs for more information about the Job status and history.

Using the Containers page to view linked Kubernetes Jobs

You can view K8s Jobs linked to Containers by clicking the Container Name on the Containers page (Kubernetes -> Containers).

You can filter container names by using the search field at the top of the page, as in this example:

Editing a Kubernetes Job

  1. In the DuploCloud Portal, navigate to Kubernetes -> Job.

  2. Select the K8s Job you want to edit.

You can edit and modify the following fields in the DuploCloud portal:

  • Cleanup After Finished in Seconds

  • Other Spec Configuration

  • Metadata Annotations

  • Labels

Deleting a Kubernetes Job

  1. In the DuploCloud Portal, navigate to Kubernetes -> Job.

  2. Select the K8s Job you want to delete.

Last updated

Logo

© DuploCloud, Inc. All rights reserved. DuploCloud trademarks used herein are registered trademarks of DuploCloud and affiliates