Kubernetes v1 Workload resources are fundamental API objects that manage and orchestrate containerized applications within a cluster. These resources define how applications run, scale, and recover from failures. Key workload resources include Pods, Deployments, StatefulSets, DaemonSets, Jobs, and CronJobs, each designed to handle different workload patterns, ensuring reliability, scalability, and maintainability in Kubernetes environments.
Authentication
Add API authentication details
Readme
User instructions for this resource
The CronJob template is designed to create Jobs on a time-based schedule. It uses a combination of facets and variables to allow for flexible configurations.
Variables
: This global variable represents the identifier for the CronJob, used to access specific fields in the request values.__CRONJOB_ID__
Collection Breakdown
- Base
{
"kind": "CronJob",
"facets": ["master"],
"metadata": "{{ __CRONJOB_ID__.metadata }}",
"apiVersion": "batch/v1"
}
This section is always included (due to the master facet). It sets the kind, apiVersion, and metadata for the CronJob resource.
- Spec
{
"spec": {
"schedule": "{{ __CRONJOB_ID__.spec.schedule }}",
"jobTemplate": {
"spec": {
"template": {
"spec": {
"containers": "{{ __CRONJOB_ID__.spec.jobTemplate.spec.template.spec.containers }}"
}
}
}
}
},
"facets": ["addon:spec"]
}
This section defines the core spec for the CronJob, including the schedule and the job template.
- CronJob-specific fields
{
"spec": {
"successfulJobsHistoryLimit": "{{ __CRONJOB_ID__.spec.successfulJobsHistoryLimit }}",
"failedJobsHistoryLimit": "{{ __CRONJOB_ID__.spec.failedJobsHistoryLimit }}",
"concurrencyPolicy": "{{ __CRONJOB_ID__.spec.concurrencyPolicy }}",
"startingDeadlineSeconds": "{{ __CRONJOB_ID__.spec.startingDeadlineSeconds }}",
"suspend": "{{ __CRONJOB_ID__.spec.suspend }}"
},
"facets": [
"addon:spec",
"addon:successfuljobshistorylimit",
"addon:failedjobshistorylimit",
"addon:concurrencypolicy",
"addon:startingdeadlineseconds",
"addon:suspend"
]
}
These sections define CronJob-specific fields that control the behavior of the CronJob.
Design Decisions
Modularity: The template is divided into multiple sections with separate facets, allowing users to include only the necessary parts of a CronJob definition.
CronJob-Specific Features: The template includes CronJob-specific features like schedule, concurrencyPolicy, and job history limits, which are crucial for controlling the execution of the CronJob.
Job Template Integration: The template includes a job template specification, allowing for detailed configuration of the Jobs created by the CronJob.
Flexibility: The use of facets allows for optional inclusion of various CronJob features, making the template suitable for both simple and complex CronJob configurations.
Schedule Management: The template allows for easy configuration of the CronJob schedule, which is a key feature of CronJobs.
Examples
Check Request Body tab section to play around with interactive examples.
Install(
)Example
The Curl tab in the request section below provides the curl command for your resource.
curl -X POST "https://configfacets.com/apis/repos/kubernetes/workload-resources/v1/resources/collections/cronjob/exec?format=json" -d '{"facets":["master","addon:spec"],"values":{"basic_cronjob":{"spec":{"schedule":"*/1 * * * *","jobTemplate":{"spec":{"template":{"spec":{"containers":[{"args":["/bin/sh","-c","date; echo Hello from the Kubernetes cluster"],"name":"hello","image":"busybox"}],"restartPolicy":"OnFailure"}}}}},"metadata":{"name":"hello"}}},"globalvars":{"__CRONJOB_ID__":"basic_cronjob"}}' | kubectl apply -f -