Skip to content

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

duploctl cronjob apply -f 'cronjob.yaml'
Contents of the cronjob.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
FileType('r') action: YamlAction
--patches, --add, --remove, --copy, --replace, --test, --move
The json patch to apply
str action: JsonPatchAction

create

Create a CronJob resource.

CLI Usage

duploctl cronjob create -f 'cronjob.yaml'
Contents of the cronjob.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
FileType('r') action: YamlAction

delete

Delete a CronJob resource by name.

cli usage
duploctl cronjob delete <name>

Returns:

Name Type Description
message dict

A success message.

Raises:

Type Description
DuploError

If the {{kind}} resource could not be found or deleted.

Parameters:

name positional
The resource name
str

find

Find CronJob resources by name.

cli usage
duploctl cronjob find <name>

Returns:

Name Type Description
resource dict

The CronJob object.

Raises:

Type Description
DuploError

If the {{kind}} could not be found.

Parameters:

name positional
The resource name
str

list

Retrieve a List of CronJob resources

cli usage
duploctl cronjob list

Returns:

Name Type Description
list list

A list of CronJob.

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
str
--file, -f, --cli-input
A file to read the input from
FileType('r') action: YamlAction
--patches, --add, --remove, --copy, --replace, --test, --move
The json patch to apply
str action: JsonPatchAction

update_image

Update the image of a cronjob.

Parameters:

name positional
The resource name
str
image positional
The image to use
str

update_schedule

Update the schedule of a cronjob.

Returns: message: A success message.

Parameters:

name positional
The resource name
str
cronschedule positional
The schedule to use
str