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 StatefulSet template is designed to define and manage a set of Pods with unique, persistent identities and stable hostnames in a Kubernetes cluster. It uses a combination of facets and variables to allow for flexible configurations.

Variables

  • __STS_ID__: This global variable represents the identifier for the StatefulSet, 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": "StatefulSet",
    "facets": ["master"],
    "metadata": "{{ __STS_ID__.metadata }}",
    "apiVersion": "apps/v1"
}

This section is always included (due to the master facet). It sets the kind, apiVersion, and metadata for the StatefulSet resource.

  1. Spec
{
    "spec": {
        "replicas": "{{ __STS_ID__.spec.replicas }}",
        "selector": "{{ __STS_ID__.spec.selector }}",
        "serviceName": "{{ __STS_ID__.spec.serviceName }}"
    },
    "facets": ["addon:spec"]
}

This section defines the core spec for the StatefulSet, including replicas, selector, and the associated service name.

  1. Pod Template
{
    "spec": {
        "template": {
            "spec": {
                "containers": "{{ __STS_ID__.spec.template.spec.containers }}"
            },
            "metadata": "{{ __STS_ID__.spec.template.metadata }}"
        }
    },
    "facets": ["addon:spec", "addon:podtemplate"]
}

This section defines the pod template, including containers and metadata.

  1. Volume Claim Templates
{
    "spec": {
        "volumeClaimTemplates": "{{ __STS_ID__.spec.volumeClaimTemplates }}"
    },
    "facets": ["addon:spec", "addon:volumeclaimtemplates"]
}

This section is unique to StatefulSets and defines the persistent volume claims for each pod.

Design Decisions

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

  2. StatefulSet-Specific Features: The template includes StatefulSet-specific features like serviceName and volumeClaimTemplates, which are crucial for maintaining stable network identities and persistent storage.

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

  4. Flexibility in Storage Configuration: The volumeClaimTemplates section allows for flexible configuration of persistent storage for each pod in the StatefulSet.

  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/statefulset/exec?format=json" -d '{"facets":["master","addon:spec","addon:podtemplate","addon:volumeclaimtemplates"],"values":{"basic_statefulset":{"spec":{"replicas":3,"selector":{"matchLabels":{"app":"nginx"}},"template":{"spec":{"containers":[{"name":"nginx","image":"nginx:1.14.2","ports":[{"name":"web","containerPort":80}],"volumeMounts":[{"name":"www","mountPath":"/usr/share/nginx/html"}]}]},"metadata":{"labels":{"app":"nginx"}}},"serviceName":"nginx","volumeClaimTemplates":[{"spec":{"resources":{"requests":{"storage":"1Gi"}},"accessModes":["ReadWriteOnce"]},"metadata":{"name":"www"}}]},"metadata":{"name":"web","namespace":"default"}}},"globalvars":{"__STS_ID__":"basic_statefulset"}}' | kubectl apply -f -
POST/apis/repos/kubernetes/workload-resources/v1/resources/collections/statefulset/exec
REQUEST
QUERY-STRING PARAMETERS
format
string
No sources available.
API Server https://configfacets.com
API Key
Not set
RESPONSES
No content available.