Creating Autoscaling Volumes
Create new EBS volumes and PVCs that autoscale from the moment they're created, with no activation and no initial data copy.
Creating an autoscaling volume gives you a new, empty volume that autoscales from the moment it's created. This is different from activating autoscaling, which applies to an existing volume and starts by copying its data to Datafy Volumes.
Creating the volume as autoscaling, rather than letting an autoscaling rule activate it later, works best for:
Short-lived workloads — a volume that exists for only minutes or hours can spend a large share of its life, or all of it, at full size, waiting for activation to complete.
Very large volumes — the more data there is to copy, the longer activation takes.
There are a few ways to create an autoscaling volume. Choose the one that matches how the volume is used:
PVCs in Kubernetes — annotate a PVC, or set a StorageClass parameter.
Volumes attached to EC2 instances — create and attach the volume with the Datafy API, or with Terraform and the
datafyawsprovider.
Volume Creation Parameters
These parameters apply to every volume created as autoscaling, whatever the method:
Size — the size you request is the volume's maximum size, and the size the filesystem sees. It must be at least your account's Autoscaling Minimum Size. The volume starts at about the Autoscaling Minimum Size (by default, 50 GiB or 10% of the requested size, whichever is larger), and grows up to the requested size as data is written.
Volume type — gp3 only.
IOPS and throughput — 3,000 IOPS and 125 MiB/s by default. You can set 3,000–16,000 IOPS and 125–1,000 MiB/s, with up to 1 MiB/s of throughput for every 4 IOPS.
Encryption — volumes are encrypted by default, with your AWS account's default EBS encryption key. You can set a custom KMS key instead.
Tags — tags you set when creating the volume are added to its Datafy Volumes in AWS, and appear on the volume in the Datafy app.
Volume ID — Datafy returns an ID that identifies the autoscaling volume in the Datafy app and the Datafy API. In Kubernetes, the PersistentVolume bound to the PVC references this ID. It's a virtual ID that doesn't appear in the AWS console. The Datafy Volumes that hold the data carry the tag
datafy:source-volume:idwith this ID.
PVCs in Kubernetes
Create a new autoscaling volume in one of two ways:
Annotate the PVC, to create a single autoscaling volume.
Set a StorageClass parameter, so every PVC that uses the class autoscales.
Annotating a PVC
Add the datafy.io/autoscaling-native: "true" annotation to new PVCs:
The annotation only takes effect before the volume is provisioned:
The value must be
"true"or"false". Only"true"creates an autoscaling volume.You can add, change, or remove the annotation while the PVC is unbound. With a
WaitForFirstConsumerStorageClass, that's until a pod using the PVC is scheduled.Once the PVC is bound to a PersistentVolume, the annotation can't be added. To autoscale a volume that already exists, activate autoscaling on it instead.
Datafy removes the annotation from the PVC when the volume is first attached to a node, and it continues as an autoscaling volume.
Setting a StorageClass Parameter
To make every new PVC of a StorageClass autoscale, add datafy.io/autoscaling-native: "true" to the StorageClass parameters:
When the StorageClass sets the parameter, it applies to every PVC of that class, and the PVC annotation is ignored. Setting the parameter to "false" stops PVCs of that class from autoscaling at creation, even if they're annotated.
StorageClass Parameters That Apply
Of the EBS CSI driver's StorageClass parameters, these apply to autoscaling PVCs:
iopsandthroughput— within the limits in Volume Creation Parameters.iopsPerGBisn't applied, so setiopsexplicitly for more than the default 3,000 IOPS.tagSpecification_<n>— applied as described in Volume Creation Parameters.csi.storage.k8s.io/fstype—ext4orxfs. The CSI driver formats the volume on first mount, as for any PVC.
Autoscaling PVCs are always gp3, whatever type the StorageClass sets.
If Datafy rejects the request, for example because it's below the minimum size, the PVC stays Pending with a ProvisioningFailed event.
Volumes Attached to EC2 Instances
Creating an autoscaling volume for an EC2 instance follows the same flow as creating an EBS volume through AWS. Only the create and attach steps are different: you run them with the Datafy API instead of the EC2 API, or with Terraform using the datafyaws provider. Everything after the attach, such as formatting and mounting, is the same as for any new EBS volume.
Create the volume
aws_ebs_volume with provider = datafyaws and datafy_autoscaling = true
Using the Datafy API
Create the volume with the
create-autoscaling-volumeendpoint. Pass the instance's Availability Zone and the size in GiB, plus any other volume creation parameters. The response includes the new volume ID.Attach the volume with the
attachendpoint. Pass the instance ID and a device name that isn't in use on the instance, such as/dev/sdf. AutoScaler doesn't need to be installed on the instance yet.Once AutoScaler is installed on the instance, format and mount the volume as you would any other EBS volume. Until then, the volume can't be used in any way, including formatting and mounting.
Using Terraform
Instead of the API calls in steps 1 and 2, set datafy_autoscaling = true on an aws_ebs_volume resource, and attach it with aws_volume_attachment, both using the datafyaws provider:
Set
type = "gp3". The plan fails iftypeis unset or set to any other type.size,iops,throughput,encrypted,kms_key_id, andtagsapply as described in Volume Creation Parameters.sizeis the volume's maximum size.datafy_autoscalingcan't be added to or changed on an existing volume. To autoscale a volume that already exists, activate autoscaling on it instead.To remove
datafy_autoscalingfrom the configuration, deactivate autoscaling on the volume first, then delete the argument. Setting it tofalseisn't allowed.To change
size,iops, orthroughputlater, see Modifying Autoscaling Volumes.
After terraform apply, format and mount the volume as in step 3 of Using the Datafy API.
Automating Volume Creation at Launch
You can use the Datafy API calls as part of your automated instance provisioning, for example in the instance's user data.
Last updated
Was this helpful?
