Repositories
v1v
Published by: Kubernetes2Updated

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.

v1
workload
|

Authentication

Add API authentication details

HEADERS
X-APIKEY
string
Send X-APIKEY in Header

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

  • __JOB_ID__: This global variable represents the identifier for the Job, used to access specific fields in the request values.

  • __SA_ID__: This variable is used specifically for the serviceAccountName field, allowing reference to a separate ServiceAccount resource.

Collection Breakdown

  1. 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.

  1. 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.

  1. 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

  1. Modularity: The template is divided into multiple sections with separate facets, allowing users to include only the necessary parts of a Job definition.

  2. Job-Specific Features: The template includes Job-specific features like backoffLimit, completions, parallelism, etc., which are crucial for controlling the execution of the Job.

  3. Comprehensive Pod Specification: The template includes a detailed pod template specification, allowing for fine-grained control over the pods created by the Job.

  4. Flexibility: The use of facets allows for optional inclusion of various Job features, making the template suitable for both simple and complex Job configurations.

  5. 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 -
POST/apis/repos/kubernetes/workload-resources/v1/resources/collections/job/exec
REQUEST
QUERY-STRING PARAMETERS
format
string
No sources available.
API Server https://configfacets.com
API Key
Not set
RESPONSES
No content available.