I've faced some real frustration while working with AWS and Kubernetes, especially regarding the absence of a StatefulSet equivalent. In my last job, I had to run ClickHouse on EC2 instances and wanted to leverage auto-scaling groups for easier AMI rotations and self-healing. However, I found it impossible to define launch templates for mounting existing EBS volumes, leading me to rely on user-data scripts to mount the volumes at startup. Unfortunately, this method is susceptible to race conditions. Now, I'm trying to set up a private blockchain network and I'm hitting the same wall. As far as I know, ECS can't handle this either. It seems like a common design issue that would benefit from being integrated into cloud providers.
1 Answer
I've never run into issues mounting EBS volumes or network drives using user-data scripts. If you're experiencing race conditions, it could be because your application starts too early. You might want to look into using systemd options to manage the application start time, making sure it waits for the drive to be available before launching.

I get that! I envisioned a script that lists unattached EBS volumes and attaches the lowest numbered one, but if multiple instances start simultaneously, I’d need some sort of locking mechanism. Still, it might be more straightforward to just keep trying to attach the volumes instead of checking, provided the AWS API behaves consistently.