---
title: "Run StatefulSet"
linkTitle: "StatefulSet"
date: 2024-07-25
weight: 6
description: >
  Run a StatefulSet as a Kueue-managed workload.
---

This page shows how to leverage Kueue's scheduling and resource management
capabilities when running StatefulSets.

We demonstrate how to support scheduling StatefulSets in Kueue based on the
[Plain Pod Group](https://kueue.sigs.k8s.io/v0.19/docs/tasks/run/plain_pods/) integration,
where StatefulSet is represented as a single independent workload.

This guide is for [serving users](/v0.19/docs/tasks#serving-user) that have a basic understanding of Kueue.
For more information, see [Kueue's overview](/v0.19/docs/overview).

## Before you begin

1. The `statefulset` integration is enabled by default.

2. For Kueue v0.15 and earlier, learn how to [install Kueue with a custom manager configuration](/v0.19/docs/installation/#install-a-custom-configured-released-version)
   and ensure that you have the `statefulset` integration enabled, for example:
   ```yaml
   apiVersion: config.kueue.x-k8s.io/v1beta2
   kind: Configuration
   integrations:
     frameworks:
      - "statefulset"
   ```
   {{% alert title="Pod integration requirements" color="primary" %}}
   Since Kueue v0.15, you don't need to explicitly enable `"pod"` integration to use the `"statefulset"` integration.

   For Kueue v0.14 and earlier, `"pod"` integration must be explicitly enabled.

   See [Run Plain Pods](/v0.19/docs/tasks/run/plain_pods/#before-you-begin) for configuration details.
   {{% /alert %}}

3. Check [Administer cluster quotas](/v0.19/docs/tasks/manage/administer_cluster_quotas) for details on the initial Kueue setup.

## Running a StatefulSet admitted by Kueue

When running a StatefulSet on Kueue, take into consideration the following aspects:

### a. Queue selection

The target [local queue](/v0.19/docs/concepts/local_queue) should be specified in the `metadata.labels` section of the StatefulSet configuration.

```yaml
metadata:
   labels:
      kueue.x-k8s.io/queue-name: user-queue
```

### b. Configure the resource needs
The resource needs of the workload can be configured in the `spec.template.spec.containers`.

```yaml
spec:
  template:
     spec:
      containers:
       - resources:
           requests:
             cpu: 3
```

### c. Scaling

Currently, scaling operations on StatefulSets are not supported.
This means you cannot perform scale up or scale down operations directly through Kueue.

## Example
Here is a sample StatefulSet:

{{< include "v0.19/examples/serving-workloads/sample-statefulset.yaml" "yaml" >}}

You can create the StatefulSet using the following command:

```sh
kubectl create -f sample-statefulset.yaml
```
