Job
Bases: DuploTenantResourceV3
Manage Duplo Kubernetes Jobs
Duplo Jobs provide a way to run containerized tasks to completion in a Kubernetes cluster.
See more details at: https://docs.duplocloud.com/docs/kubernetes-overview/jobs
apply
Apply a Job
Create or Update a Job resource with Duplocloud cli.
CLI Usage
Contents of thejob.yaml
file
metadata:
name: duploctl
spec:
ttlSecondsAfterFinished: 86400
parallelism: 2
completions: 4
template:
spec:
restartPolicy: Never
containers:
- name: app
image: ubuntu:latest
command:
- /bin/bash
- -c
args:
- |
echo "Hello, World!"
sleep 10
echo "Goodbye, World!"
num="$(echo $((1 + $RANDOM % 10)))"
sleep $num
echo "I slept for $num seconds"
sleep 10
initContainers: []
Parameters:
Name | Type | Description | Default |
---|---|---|---|
body
|
BODY
|
The resource to apply. |
required |
wait
|
WAIT
|
Wait for the resource to be created. |
False
|
patches
|
PATCHES
|
The patches to apply to the resource. |
None
|
Returns:
Name | Type | Description |
---|---|---|
message |
dict
|
Success message. |
create
Create a Kubernetes Job.
Creates a new Job with the specified configuration. The Job will create pods and ensure they complete successfully according to the completion criteria.
CLI Usage
Contents of thejob.yaml
file
metadata:
name: duploctl
spec:
ttlSecondsAfterFinished: 86400
parallelism: 2
completions: 4
template:
spec:
restartPolicy: Never
containers:
- name: app
image: ubuntu:latest
command:
- /bin/bash
- -c
args:
- |
echo "Hello, World!"
sleep 10
echo "Goodbye, World!"
num="$(echo $((1 + $RANDOM % 10)))"
sleep $num
echo "I slept for $num seconds"
sleep 10
initContainers: []
Create a Job using a one-liner.
echo """
metadata:
name: duploctl
spec:
ttlSecondsAfterFinished: 86400
parallelism: 2
completions: 4
template:
spec:
restartPolicy: Never
containers:
- name: app
image: ubuntu:latest
command:
- /bin/bash
- -c
args:
- |
echo "Hello, World!"
sleep 10
echo "Goodbye, World!"
num="$(echo $((1 + $RANDOM % 10)))"
sleep $num
echo "I slept for $num seconds"
sleep 10
initContainers: []
""" | duploctl job create -f -
Parameters:
Name | Type | Description | Default |
---|---|---|---|
body
|
BODY
|
The complete Job configuration including container specs, completions, and other parameters. |
required |
Returns:
Name | Type | Description |
---|---|---|
message |
Success message confirming the Job creation. |
Raises:
Type | Description |
---|---|
DuploError
|
If the Job could not be created due to invalid configuration. |
DuploFailedResource
|
If the Job's pods encounter faults during execution. |
delete
Delete a Job resource by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
NAME
|
The name of the Job resource to delete. |
required |
Returns:
Name | Type | Description |
---|---|---|
message |
dict
|
A success message. |
Raises:
Type | Description |
---|---|
DuploError
|
If the {{kind}} resource could not be found or deleted. |
find
Find Job resources by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
NAME
|
The name of the Job resource to find. |
required |
Returns:
Name | Type | Description |
---|---|---|
resource |
dict
|
The Job object. |
Raises:
Type | Description |
---|---|
DuploError
|
If the {{kind}} could not be found. |
list
pods
List pods for a Job.
Retrieve all pods that are managed by the specified Job. The pods are filtered by the Job name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
NAME
|
The name of the Job to get pods for. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
A list of pods associated with the Job, including their status and metadata. |
Raises:
Type | Description |
---|---|
DuploError
|
If the Job could not be found or if there's an error retrieving pods. |
update
Update a V3 resource by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
NAME
|
The name of the resource to update. |
None
|
body
|
BODY
|
The resource to update. |
None
|
patches
|
PATCHES
|
The patches to apply to the resource. |
None
|
Returns:
Name | Type | Description |
---|---|---|
message |
Success message. |
Raises:
Type | Description |
---|---|
DuploError
|
If the resource could not be created. |