> For the complete documentation index, see [llms.txt](https://notes.tatusl.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.tatusl.dev/kubernetes/statefulset.md).

# StatefulSet

## Resizing EBS disks of StatefulSet without major downtime

Kubernetes has supported resizing of volumes without recreating PVCs and PVs from version 1.11 with certain disk types. EBS is one of them. However, if VolumeClaimTemplate is used certain tricks needs to be done.

* Find PVCs belonging to StatefulSet, for example `kubectl get pvc --all-namespaces`
* Edit PVC API object on-the-fly, for example: `kubectl edit pvc/$PVC_NAME -n $NAMESPACE`
* Change value of field `spec.resources.requests.storage` and save changes
* Ensure that resize is finished by inspecting PVC with `kubectl describe pvc/$PVC_NAME -n $NAMESPACE`. Events field should state that resize is finished and changes take place after pod restart
* Restart pod in question
* Repeat the steps for all PVCs of the StatefulSet
* Delete StatefulSet without deleting its pods: `kubectl delete sts --cascade=false $STS_NAME -n $NAMESPACE`
* Change disk size in VolumeClaimTemplate and apply changes
* If needed, trigger StatefulSet rollout with `kubectl rollout restart sts $STS_NAME -n rabbitmq`. This will restart the pods one-by-one

In addition, Kubernetes has beta support for resizing an in-use PersistentVolumeClaim from version 1.15: <https://kubernetes.io/docs/concepts/storage/persistent-volumes/#resizing-an-in-use-persistentvolumeclaim>

References:

* <https://github.com/kubernetes/kubernetes/issues/68737#issuecomment-498470138>
* <https://serverfault.com/a/989665>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://notes.tatusl.dev/kubernetes/statefulset.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
