> For the complete documentation index, see [llms.txt](https://docs.datafy.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datafy.io/how-it-works/autoscaler-on-kubernetes.md).

# AutoScaler on Kubernetes

Learn how Datafy AutoScaler integrates with the AWS EBS CSI driver: what gets installed, how volume requests are translated, and what happens after uninstall

When a volume is autoscaling, the original EBS volume is replaced by smaller [Datafy-managed volumes](https://docs.datafy.io/how-it-works/how-autoscaler-works.md). In a Kubernetes cluster, the [PersistentVolume](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) that represents this volume still references the original volume ID. Whenever the matching [PersistentVolumeClaim](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims) requires an action at the volume level (such as attaching, mounting, or detaching), the AWS EBS CSI driver, which handles EBS volume operations in Kubernetes, cannot find the correct volume to act on.

Datafy bridges this gap with a conversion layer that intercepts requests received by the CSI driver and translates them to the underlying Datafy-managed volumes. For volumes Datafy does not manage, requests pass through unchanged.

## Installing Datafy on Kubernetes

[Installing AutoScaler](https://docs.datafy.io/set-up-and-installation/datafy-installation/installation.md#kubernetes-cluster) on a Kubernetes cluster adds three main components to your cluster:

* **Datafy agent** — `datafy-agent` DaemonSet, with one pod per node. Performs the same functions as in non-Kubernetes environments: monitoring utilization, orchestrating grow and shrink operations, and managing the virtualization layer.
* **Datafy controller** — `datafy-controller` Deployment. Tracks volume state and manages the integration with the CSI driver.
* **Datafy proxy** — `datafy-proxy` sidecar container added to each `ebs-csi-controller` and `ebs-csi-node` pod. Intercepts and translates CSI driver requests for managed volumes.

{% hint style="success" %}
To verify your installation, check that the following are present in your cluster:

* `datafy-agent` DaemonSet in the `datafy-agent` namespace, with one pod running per node
* `datafy-controller` Deployment in the `datafy-agent` namespace, running
* `ebs-csi-controller` and `ebs-csi-node` pods (in the EBS CSI driver's namespace) each contain a `datafy-proxy` container
  {% endhint %}

The Datafy proxy sidecar is added to CSI driver pods through a Kubernetes [admission webhook](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/) that the controller registers. The webhook adds the sidecar whenever a CSI driver pod starts, whether on initial install, version upgrade, or routine restart, so the integration is preserved across CSI driver updates without manual reconfiguration. The controller also re-adds the sidecar if the `ebs-csi-controller` Deployment or `ebs-csi-node` DaemonSet drifts.

{% hint style="info" %}
Your existing StorageClasses, IAM roles, and CSI configuration remain unchanged. Datafy works alongside the standard driver, not in place of it.
{% endhint %}

## Volume Operations

The cluster operations you'd typically perform on autoscaling volumes work the same as on any other PersistentVolume: the Datafy proxy translates each request to the underlying volumes, and the standard CSI driver carries out the AWS calls using its existing IAM credentials.

* **Pod rescheduling** — when a pod moves between nodes during a drain, rolling update, eviction, or rescaling, the CSI sidecar translates the detach and re-attach calls, and the Datafy agent on each node tears down or sets up the virtualization layer. From the application's perspective, this is identical to a standard pod rescheduling event.
* **Snapshots and backups** — Kubernetes [`VolumeSnapshot`](https://kubernetes.io/docs/concepts/storage/volume-snapshots/) resources are supported, including the CSI snapshotter integration used by tools like Velero. For details, see [Datafy Snapshots](https://docs.datafy.io/volume-lifecycle/datafy-snapshots.md#kubernetes-csi-integration).
* **New autoscaling PVCs** — when a PVC requests an autoscaling volume, the Datafy proxy creates it through Datafy instead of passing the request to the CSI driver, so the PVC is bound to an autoscaling volume from the start. For details, see [Creating Autoscaling Volumes](https://docs.datafy.io/volume-lifecycle/creating-autoscaling-volumes.md#pvcs-in-kubernetes).

### Bottlerocket Local Volumes

On nodes running [Bottlerocket](https://bottlerocket.dev/), the Datafy app shows Bottlerocket's data volume as a **local volume**, named after its `/local` mount path. The volume is created when the node launches, from the node's block device mapping (device `/dev/xvdb` by default), so it isn't a PersistentVolume and the operations above don't apply to it.

{% hint style="danger" %}
Don't reboot a node whose local volume is autoscaling. The container images and other components AutoScaler needs to start are stored on this volume, so after a reboot AutoScaler can't start and the node doesn't recover. Wherever a reboot is recommended, replace the node instead.
{% endhint %}

* **Activating autoscaling** — a local volume can't be created as autoscaling. Activate it with an [autoscaling rule](https://docs.datafy.io/volume-lifecycle/autoscaling-rules.md).
* **Changing size, IOPS, or throughput** — [modifying](https://docs.datafy.io/volume-lifecycle/modify-a-volumes-parameters.md) a local volume isn't supported. Instead, update the data volume's block device mapping in the node group's launch template, then replace the nodes. The new nodes come up with new local volumes, which the rule activates.

## Uninstalling

### Preparing to Uninstall

{% hint style="danger" %}
Deactivate autoscaling on all managed volumes before uninstalling. If Datafy is removed while volumes are still under autoscaling, those volumes will not be accessible. Follow the [uninstall guide](https://docs.datafy.io/set-up-and-installation/uninstalling-datafy.md) to prepare correctly.
{% endhint %}

{% hint style="success" %}
Automatic ID swaps are supported from AutoScaler version 2.0.0, Helm chart version 4.0.0.
{% endhint %}

[Deactivating autoscaling](https://docs.datafy.io/volume-lifecycle/managing-autoscaling-volumes.md#deactivating-autoscaling) creates a new EBS volume with a new ID. Making the volume independent of Datafy requires an ID swap: updating the volume ID referenced by the PersistentVolume to match the new one. Until then, it continues to operate like an autoscaling volume for [CSI-level operations](#volume-operations), such as rescheduling to another node, with the Datafy proxy translating requests to the new volume.

A PVC binds to a PersistentVolume by name, and that binding can't change once made. So the new volume ID can't be written directly onto the existing PersistentVolume while a pod is using it.

Because the volume can't be replaced while a pod is using it, Datafy waits until the next time its workload restarts — a rolling update, a node drain, or any other event that recreates the pod. When the PersistentVolume is free, Datafy performs the ID swap: it recreates the PersistentVolume under the same name, pointing at the new volume ID, and rebinds it to the same PVC. The PVC itself is never touched, so the workload keeps its identity throughout.

{% hint style="info" %}
The PersistentVolume's reclaim policy is set to `Retain` before it's recreated, so no EBS volume is ever deleted as part of an ID swap. Once the swap completes, the new PersistentVolume reverts to its original reclaim policy.
{% endhint %}

To swap every volume's ID without waiting for workloads to restart on their own, restart them yourself — for example with `kubectl rollout restart` — after deactivating autoscaling.

### After Uninstalling

If any PersistentVolumes remain that need their ID swapped, the Datafy controller and Datafy proxy sidecar containers remain after uninstalling, along with the RBAC roles, admission webhook, and other resources they require to operate. The Datafy agent is removed immediately regardless.

Once the IDs of all PersistentVolumes are swapped (or the PersistentVolumes are deleted), the controller removes itself, the CSI sidecar containers, and any other remaining resources. From that point on, the CSI driver operates exactly as it did before Datafy was installed.

{% hint style="info" %}
For versions older than 2.0.0, automatic ID swaps aren't available, so the controller and sidecars stay until every relevant PersistentVolume is deleted. This has no functional impact on the cluster, but if you'd rather not leave them running, contact Datafy support to swap the PersistentVolumes' IDs.
{% endhint %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.datafy.io/how-it-works/autoscaler-on-kubernetes.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
