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 Job template is designed to run a pod or set of pods to completion. It uses a combination of facets and variables to allow for flexible configurations.
Variables
: This global variable represents the identifier for the Job, used to access specific fields in the request values.__JOB_ID__
: This variable is used specifically for the serviceAccountName field, allowing reference to a separate ServiceAccount resource.__SA_ID__
Collection Breakdown
- Base
{
"kind": "Job",
"facets": ["master"],
"metadata": "{{ __JOB_ID__.metadata }}",
"apiVersion": "batch/v1"
}
This section is always included (due to the master facet). It sets the kind, apiVersion, and metadata for the Job resource.
- Pod Template
{
"spec": {
"template": {
"spec": {
"containers": "{{ __JOB_ID__.spec.template.spec.containers }}"
}
}
},
"facets": ["addon:spec"]
}
This section defines the pod template, including containers. It's a core part of the Job specification.
- Job-specific fields
{
"spec": {
"backoffLimit": "{{ __JOB_ID__.spec.backoffLimit }}",
"completions": "{{ __JOB_ID__.spec.completions }}",
"parallelism": "{{ __JOB_ID__.spec.parallelism }}",
"activeDeadlineSeconds": "{{ __JOB_ID__.spec.activeDeadlineSeconds }}",
"ttlSecondsAfterFinished": "{{ __JOB_ID__.spec.ttlSecondsAfterFinished }}"
},
"facets": [
"addon:spec",
"addon:backofflimit",
"addon:completions",
"addon:parallelism",
"addon:activedeadlineseconds",
"addon:ttlsecondsafterfinished"
]
}
These sections define Job-specific fields that control the behavior of the Job.
Design Decisions
Modularity: The template is divided into multiple sections with separate facets, allowing users to include only the necessary parts of a Job definition.
Job-Specific Features: The template includes Job-specific features like backoffLimit, completions, parallelism, etc., which are crucial for controlling the execution of the Job.
Comprehensive Pod Specification: The template includes a detailed pod template specification, allowing for fine-grained control over the pods created by the Job.
Flexibility: The use of facets allows for optional inclusion of various Job features, making the template suitable for both simple and complex Job configurations.
Integration with Other Resources: The template allows for integration with other Kubernetes resources, such as ServiceAccounts, through dedicated variables.
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/job/exec?format=json" -d '{"facets":["master","addon:spec"],"values":{"basic_job":{"spec":{"template":{"spec":{"containers":[{"name":"pi","image":"perl","command":["perl","-Mbignum=bpi","-wle","print bpi(2000)"]}],"restartPolicy":"Never"}},"backoffLimit":4},"metadata":{"name":"pi"}}},"globalvars":{"__JOB_ID__":"basic_job"}}' | kubectl apply -f -