⎈ k8s knowledge compiler

Overprovision Node Capacity For A Cluster [page]deterministic

tasks

This page guides you through configuring [Node](#gloss:node) overprovisioning in your Kubernetes cluster. Node overprovisioning is a strategy that proactively reserves a portion of your cluster's compute resources. This reservation helps reduce the time required to schedule new pods during scaling events, enhancing your cluster's responsiveness to sudden spikes in traffic or workload demands.

By maintaining some unused capacity, you ensure that resources are immediately available when new pods are created, preventing them from entering a pending state while the cluster scales up.

##

  • You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster.
  • You should already have a basic understanding of [Deployments](/docs/concepts/workloads/controllers/deployment/), Pod [priority](#gloss:pod-priority), and [PriorityClasses](#gloss:priority-class).
  • Your cluster must be set up with an [autoscaler](/docs/concepts/cluster-administration/cluster-autoscaling/) that manages nodes based on demand.

## Create a PriorityClass

Begin by defining a PriorityClass for the placeholder Pods. First, create a PriorityClass with a negative priority value, that you will shortly assign to the placeholder pods. Later, you will set up a Deployment that uses this PriorityClass

Then create the PriorityClass:

```shell kubectl apply -f https://k8s.io/examples/priorityclass/low-priority-class.yaml ```

You will next define a Deployment that uses the negative-priority PriorityClass and runs a minimal container. When you add this to your cluster, Kubernetes runs those placeholder pods to reserve capacity. Any time there is a capacity shortage, the control plane will pick one these placeholder pods as the first candidate to [preempt](#gloss:preemption).

## Run Pods that request node capacity

Review the sample manifest:

### Pick a namespace for the placeholder pods

You should select, or create, a [namespace](#gloss:namespace) that the placeholder Pods will go into.

### Create the placeholder deployment

Create a Deployment based on that manifest:

```shell # Change the namespace name "example" kubectl --namespace example apply -f https://k8s.io/examples/deployments/deployment-with-capacity-reservation.yaml ```

## Adjust placeholder resource requests

Configure the resource requests and limits for the placeholder pods to define the amount of overprovisioned resources you want to maintain. This reservation ensures that a specific amount of CPU and memory is kept available for new pods.

To edit the Deployment, modify the `resources` section in the Deployment manifest file to set appropriate requests and limits. You can download that file locally and then edit it with whichever text editor you prefer.

You can also edit the Deployment using kubectl:

```shell kubectl edit deployment capacity-reservation ```

For example, to reserve a total of a 0.5 CPU and 1GiB of memory across 5 placeholder pods, define the resource requests and limits for a single placeholder pod as follows:

```yaml resources: requests: cpu: "100m" memory: "200Mi" limits: cpu: "100m" ```

## Set the desired replica count

### Calculate the total reserved resources

For example, with 5 replicas each reserving 0.1 CPU and 200MiB of memory: Total CPU reserved: 5 × 0.1 = 0.5 (in the Pod specification, you'll write the quantity `500m`) Total memory reserved: 5 × 200MiB = 1GiB (in the Pod specification, you'll write `1 Gi`)

To scale the Deployment, adjust the number of replicas based on your cluster's size and expected workload:

```shell kubectl scale deployment capacity-reservation --replicas=5 ```

Verify the scaling:

```shell kubectl get deployment capacity-reservation ```

The output should reflect the updated number of replicas:

```none NAME READY UP-TO-DATE AVAILABLE AGE capacity-reservation 5/5 5 5 2m ```

> **Not …(trimmed)

Sources

tasks/administer-cluster/node-overprovisioning.md · docOverprovision Node Capacity For A Cluster

Related (15)

references NodeNode conf=1
references Pod Prioritypriority conf=1
references PriorityClassPriorityClasses conf=1
references Preemptionpreempt conf=1
references Namespacenamespace conf=1
part_of {{% heading "prerequisites" %}}describes conf=1
part_of Create a PriorityClassdescribes conf=1
part_of Run Pods that request node capacitydescribes conf=1
part_of Adjust placeholder resource requestsdescribes conf=1
part_of Set the desired replica countdescribes conf=1
part_of {{% heading "whatsnext" %}}describes conf=1
part_of Pick a namespace for the placeholder podsdescribes conf=1
part_of Create the placeholder deploymentdescribes conf=1
part_of Calculate the total reserved resourcesdescribes conf=1
api_for Nodedocuments API object conf=1

← all Docs