CronJob
Bases: DuploResourceV3
Duplo CronJob are scheduled jobs that run containers in a Kubernetes cluster.
Commands
apply
Apply a CronJob
Create or Update a CronJob resource with Duplocloud cli.
CLI Usage
Contents of thecronjob.yaml file
AllocationTags: ''
metadata:
name: duploctl
spec:
concurrencyPolicy: Allow
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 3
suspend: false
schedule: 0 0 * * 0
jobTemplate:
metadata: {}
spec:
ttlSecondsAfterFinished: 86400
template:
spec:
dnsPolicy: ClusterFirst
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
restartPolicy: Never
initContainers: []
containers:
- imagePullPolicy: Always
resources: {}
terminationMessagePath: "/dev/termination-log"
terminationMessagePolicy: File
name: app
image: alpine:latest
command:
- echo
- hello
Returns:
| Name | Type | Description |
|---|---|---|
message |
dict
|
Success message. |
Parameters:
--file, -f, --cli-input
A file to read the input from
--patches, --add, --remove, --copy, --replace, --test, --move
The json patch to apply
create
Create a CronJob resource.
CLI Usage
Contents of thecronjob.yaml file
AllocationTags: ''
metadata:
name: duploctl
spec:
concurrencyPolicy: Allow
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 3
suspend: false
schedule: 0 0 * * 0
jobTemplate:
metadata: {}
spec:
ttlSecondsAfterFinished: 86400
template:
spec:
dnsPolicy: ClusterFirst
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
restartPolicy: Never
initContainers: []
containers:
- imagePullPolicy: Always
resources: {}
terminationMessagePath: "/dev/termination-log"
terminationMessagePolicy: File
name: app
image: alpine:latest
command:
- echo
- hello
One liner example
echo """
AllocationTags: ''
metadata:
name: duploctl
spec:
concurrencyPolicy: Allow
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 3
suspend: false
schedule: 0 0 * * 0
jobTemplate:
metadata: {}
spec:
ttlSecondsAfterFinished: 86400
template:
spec:
dnsPolicy: ClusterFirst
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
restartPolicy: Never
initContainers: []
containers:
- imagePullPolicy: Always
resources: {}
terminationMessagePath: "/dev/termination-log"
terminationMessagePolicy: File
name: app
image: alpine:latest
command:
- echo
- hello
""" | duploctl cronjob create -f -
Returns:
| Name | Type | Description |
|---|---|---|
message |
dict
|
Success message. |
Raises:
| Type | Description |
|---|---|
DuploError
|
If the resource could not be created. |
Parameters:
--file, -f, --cli-input
A file to read the input from
delete
find
list
update
Update a V3 resource by name.
Returns:
| Name | Type | Description |
|---|---|---|
message |
Success message. |
Raises:
| Type | Description |
|---|---|
DuploError
|
If the resource could not be created. |
Parameters:
name
positional
The resource name
--file, -f, --cli-input
A file to read the input from
--patches, --add, --remove, --copy, --replace, --test, --move
The json patch to apply
update_image
Update the image of a cronjob.
Parameters:
name
positional
The resource name
image
positional
The image to use
update_schedule
Update the schedule of a cronjob.
Returns: message: A success message.
Parameters:
name
positional
The resource name
cronschedule
positional
The schedule to use