Get a List of Jobs Created by ScaledJob

How to Get a List of Jobs Created by ScaledJob in Kubernetes

Estimated reading time: 2 minutes

ScaledJobs allows for scaling based on events, which is vital for efficiently handling workloads. In this blog post, we will explore how to get a list of jobs created by ScaledJob in Kubernetes.

Problem statement

ScaledJob is a custom resource defined by KEDA that allows you to scale Kubernetes jobs based on external events or metrics. The ScaledJob automatically creates, scales, and manages jobs in response to workload demands.

Occasionally, you may want to identify all the jobs created by the KEDA ScaledJob. KEDA automatically assigns some labels to jobs created by ScaledJobs, as we will see later in this article. The below steps explain how to get a list of all jobs created by ScaledJob.

The Solution: Get a List of Jobs Created by ScaledJob

Step 1: Identify the ScaledJob

First, you need to identify the name of the ScaledJob. You can list all the ScaledJobs in your cluster using the following command:

This command will output a list of all ScaledJobs in your Kubernetes cluster. From this, identify the name of the ScaledJob for which you want to list all the jobs created.

Step 2: Identify the label to filter

KEDA adds the following standard labels to all ScaledJobs:

In this example, we are going to filter based on the label.

Step 3: List Jobs Created by the ScaledJob

To list the jobs created by a specific ScaledJob, you need to filter them based on their labels. KEDA automatically assigns labels to jobs created by ScaledJobs. Indeed, the label includes the ScaledJob name.

Use the following command to list the jobs:

Replace <scaledjob-name> with the name of your ScaledJob. This command will output all jobs created by the specified ScaledJob.

You can also use the --selector option instead of the -l option, which essentially does the same thing.

Example Output:

Further Reading

Leave a Reply

Your email address will not be published. Required fields are marked *