> ## Documentation Index
> Fetch the complete documentation index at: https://astronomer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure task-level Pod resources

Astro automatically allocates resources to Pods created by the `KubernetesPodOperator`. Unless otherwise specified in your task-level configuration, the amount of resources your task Pod can use is defined by your [default Pod resource configuration](/docs/astro/deployment-resources#configure-kubernetes-pod-resources). To optimize your resource usage, Astronomer recommends specifying [compute resource requests and limits](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) for each task.

## Setup

<Steps>
  <Step title="Define container resources">
    Define a `kubernetes.client.models.V1ResourceRequirements` object and provide that to the `container_resources` argument of the `KubernetesPodOperator`. For example:

    The following code example ensures that when this dag runs, it launches a Kubernetes Pod with exactly 800m of CPU and 3Gi of memory as long as that infrastructure is available in your Deployment. After the task finishes, the Pod terminates gracefully.

    ```python {19} wrap theme={null}
    from airflow.configuration import conf
    from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
    from kubernetes.client import models as k8s

    compute_resources = k8s.V1ResourceRequirements(
        limits={"cpu": "800m", "memory": "3Gi"},
        requests={"cpu": "800m", "memory": "3Gi"}
    )

    namespace = conf.get("kubernetes", "NAMESPACE")

    KubernetesPodOperator(
        namespace=namespace,
        image="<your-docker-image>",
        cmds=["<commands-for-image>"],
        arguments=["<arguments-for-image>"],
        labels={"<pod-label>": "<label-name>"},
        name="<pod-name>",
        container_resources=compute_resources,
        task_id="<task-name>",
        get_logs=True,
        in_cluster=True,
    )
    ```
  </Step>
</Steps>

<Warning>
  When you add custom labels, do not remove or modify the default Airflow labels that Astro applies to KPO Pods. See [Known limitations](/docs/astro/kubernetespodoperator#known-limitations).
</Warning>

<Warning>
  On Astro Hosted, Astro automatically sets resource requests equal to limits for `KubernetesPodOperator` task Pods. This ensures Pods receive a Kubernetes [Guaranteed Quality of Service (QoS) class](https://kubernetes.io/docs/concepts/workloads/pods/pod-qos/#guaranteed), which prevents resource contention and eviction. Because Astro uses the limit values as both requests and limits, your Pods are billed based on the limits you configure, even if actual usage is lower. To avoid unexpected charges, set limits close to the resources your task requires. Check your [Billing and usage](/docs/astro/manage-billing) to view your resource use and associated charges.
</Warning>
