Skip to content

CronJob

Bases: DuploTenantResourceV3

Duplo CronJob are scheduled jobs that run containers in a Kubernetes cluster.

_set_is_any_host_allowed

Helper method to set the 'IsAnyHostAllowed' field based on cronjob annotations.

apply

Apply a service.

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 -

Parameters:

Name Type Description Default
body BODY

The resource to create.

required
wait WAIT

Wait for the resource to be created.

False
wait_check callable

A callable function to check if the resource

None

Returns:

Name Type Description
message dict

Success message.

Raises:

Type Description
DuploError

If the resource could not be created.

delete

Delete a CronJob resource by name.

cli usage
duploctl cronjob delete <name>

Parameters:

Name Type Description Default
name NAME

The name of the CronJob 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 CronJob resources by name.

cli usage
duploctl cronjob find <name>

Parameters:

Name Type Description Default
name NAME

The name of the CronJob resource to find.

required

Returns:

Name Type Description
resource dict

The CronJob object.

Raises:

Type Description
DuploError

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

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.

Parameters:

Name Type Description Default
body str

The resource to update.

required

Returns: Success message. Raises: DuploError: If the resource could not be created.

update_image

Update the image of a cronjob.

Parameters:

Name Type Description Default
name str

The name of the cronjob to update.

required
image str

The new image to use for the cronjob.

required

update_schedule

Update the schedule of a cronjob.

Parameters:

Name Type Description Default
name NAME

The name of the cronjob to update.

required
cronschedule CRONSCHEDULE

The new schedule to use for the cronjob.

required

Returns: message: A success message.