githubEdit

Jobs

Create Kubernetes Jobs in AWS and GCP from the DuploCloud Portal

In Kubernetes, a Job arrow-up-rightis 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 Deploymentsarrow-up-right.

Refer to the Kubernetes Job arrow-up-rightdocumentation for use cases and examples of when to use Kubernetes Jobs.

Using Kubernetes Jobs for Pod management

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, and 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.

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 parallelarrow-up-right. 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

  1. Navigate to Kubernetes -> Job.

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

    Add Kubernetes Job - Basic Options page
  3. Complete the fields as follows:

Name

Enter a name for the Job, e.g., job1. Required.

Cleanup After Finished in Seconds (TTL)

Enter a TTL value in seconds, e.g., 86400.

Restart Policy

Select the restart policy, e.g., Never.

Backoff Limit

Enter the maximum number of retries before the Job is marked failed.

Allocation Tag

Enter Allocation Tags if needed for resource allocation.

  1. Enter the details for Container 1 as needed (Container Name, Docker Image, Command, Environment Variables, Arguments, Other Container Config).

    • If your Job requires Init Containers, click the caret next to Add Container and select Add Init Container.

    • To add more containers, click Add Container as many times as needed and fill in their details.

Container Name

Enter the container name, e.g., main. Required.

Docker Image

Enter the Docker image to run, e.g., nginx:latest. Required.

Command

Enter any commands to run in the container.

Environment Variables

Enter environment variables to set in the container.

Arguments

Enter arguments for the container.

Other Container Config

Enter any additional container configuration.

  1. Click Next. The Advanced Options pane displays.

Add Kubernetes Job - Advanced Options pane
  1. Complete the additional fields as needed:

Other Spec Configuration

Enter any additional container or pod specifications needed.

Metadata Annotations

Enter annotations in key=value format to add custom metadata to the Job or pods.

Metadata Labels

Enter labels in key=value format. To specify an App Name, use: app.duplocloud.net/app-name: "<your-app-name>"

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

K8s Job tab showing the Active CALCULATEPI Job.
circle-info

Tip: Entering an app name in Metadata Labels allows the Job to be grouped by app on the Apps page.

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. The compliance: 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.

To learn more about allocation tags for Kubernetes Jobs, see the Kubernetes documentation on labels and selectorsarrow-up-right and node selectors and node affinityarrow-up-right.

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.

    The Add Tenant Feature pane with Enable K8s Job fault logging by default enabled

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.

The Tenant details page, Settings tab, showing the configured Jobs fault setting

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.

You can also view a Kubernetes Job's details by clicking the menu icon ( ) icon to the left of the Job name and selecting View.

Overview and Details tabs for a KubernetesJob.
Job option menu with View option highlighted.

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

Clicking the Container Name on the Containers page to view a linked K8s job

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

Highlighted search field on the Containers page.

Editing a Kubernetes Job

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

  2. Select the K8s Job you want to edit.

  3. Click the options menu ( ) icon to the left of the K8s Job you want to edit and select Edit.

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

  • Cleanup After Finished in Seconds

  • Other Spec Configuration

  • Metadata Annotations

  • Labels

Job page options menu with Edit option highlighted.

Deleting a Kubernetes Job

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

  2. Select the K8s Job you want to delete.

  3. Click the Job options menu ( ) icon to the left of the Job name and select Delete.

Job options menu with Delete option highlighted

Running Jobs on Shared Hosts

DuploCloud supports running Kubernetes Jobs on Shared Hosts in both AWS and Azure.

For detailed steps, see the Shared Hosts documentation for AWS and Shared Hosts documentation for Azure.

Last updated

Was this helpful?