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 Deployment template is designed to define and manage a set of replica Pods in a Kubernetes cluster. It uses a combination of facets and variables to allow for flexible configurations.

Variables

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

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

  1. Replica and Selector
{
    "spec": {
        "replicas": "{{ __DEPLOYMENT_ID__.spec.replicas }}",
        "selector": "{{ __DEPLOYMENT_ID__.spec.selector }}"
    },
    "facets": ["addon:spec"]
}

This section defines the number of replicas and the selector for the Deployment. It's part of the core spec and is included when the addon:spec facet is used.

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

This section defines the metadata for the Pod template. It's separated to allow for specific customization of Pod metadata.

  1. Containers
{
    "spec": {
        "template": {
            "spec": {
                "containers": "{{ __DEPLOYMENT_ID__.spec.template.spec.containers }}"
            }
        }
    },
    "facets": ["addon:spec", "addon:containers"]
}

This crucial section defines the containers for the Pods. It's separated to allow for easy addition or modification of containers.

Design Decisions

  1. Modularity: The template is divided into multiple sections with separate facets. This allows users to include only the necessary parts of a Deployment definition, reducing complexity for simple use cases while allowing for advanced configurations when needed.

  2. Comprehensive Coverage: The template includes a wide range of Kubernetes Deployment features. For example, the separate sections for initContainers, volumes, and various Pod scheduling options (nodeSelector, affinity, tolerations) allow for complex Deployment configurations.

  3. Reusability: The use of variables (like __DEPLOYMENT_ID__) allows for dynamic content population, making the template reusable for different Deployment configurations.

  4. Separation of Concerns: By using different facets (e.g., addon:containers, addon:volumes, addon:strategy), the template allows for creating Deployments with only the necessary components. This makes it easier to manage and understand different aspects of the Deployment.

  5. Pod Template Integration: The detailed pod template specification is included but separated into different sections (metadata, containers, volumes, etc.). This allows for fine-grained control over the Pods created by the Deployment while keeping the template organized.

  6. Deployment-specific Features: The template includes sections for deployment-specific features like update strategy (addon:strategy), revision history limit (addon:revisionhistory), and readiness settings (addon:readiness). These are crucial for managing the lifecycle of deployed applications and are separated for clarity and optional inclusion.

  7. Integration with Other Resources: The template allows for integration with other Kubernetes resources, such as ServiceAccounts, through dedicated variables (e.g., __SA_ID__). This promotes consistency and reduces errors when referencing external resources.

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 -s -X POST "https://configfacets.com/apis/repos/kubernetes/workload-resources/v1/resources/collections/deployment/exec?format=json" -d '{"facets":["master","addon:spec","addon:podtemplate","addon:containers"],"values":{"basic_deployment":{"spec":{"replicas":3,"selector":{"matchLabels":{"app":"nginx"}},"template":{"spec":{"containers":[{"name":"nginx","image":"nginx:1.14.2","ports":[{"containerPort":80}]}]},"metadata":{"labels":{"app":"nginx"}}}},"metadata":{"name":"nginx-deployment","labels":{"app":"nginx"}}}},"globalvars":{"__DEPLOYMENT_ID__":"basic_deployment"}}' | kubectl apply -f -
POST/apis/repos/kubernetes/workload-resources/v1/resources/collections/deployment/exec
REQUEST
QUERY-STRING PARAMETERS
format
string
No sources available.
API Server https://configfacets.com
API Key
Not set
RESPONSES
No content available.