numercfd / aws-fasi

Failover AWS Spot Instances
MIT License
11 stars 6 forks source link

Attach EBS #1

Open milvain opened 5 years ago

milvain commented 5 years ago

My question: Hello, I have a question, is it possible to use your function to launch a VM with 2 EBS volumes (one root and one data) and keep these same EBS volumes between switching from spot to on-demand and from on-demand to spot? And on top of that when I stop the ASG during the night and restart the morning, I wouldlike keep the same EBS volumes. Do think that features are possible? Many thanks Best regards

Answer from numercfd: Hi Sylvain,

First of all, thank you. I'm glad to hear that we are helping people build technology.

Yes, it's possible, but not exactly how you want it. You could use the _fasi_ebs parameter. You can tag an EBS and the script will attach it to whichever instance is currently the primary. Note that this only works when using the single instance failover mode.

As you mentioned, you want not only to share a data volume between instances, but also the root volume. I'm not sure how to approach this. While I'm not sure if AWS allows you to reattach the root volume to another instance, I know this is not the recommended practice. Normally, what you would do is to create an snapshot of the instance's root volume and start a new one based on this snapshot.

I'd recommend you to change the way your application saves data and just dump everything inside the EBS dedicated to data. In the Cloud, servers should be ephemeral and expendable. This way you can just set the _fasi_ebs parameters and everything works.

As an after though, I made this script 3 years ago when AWS EFS did not exist. Nowadays you could just use EFS and not worry about reattaching EBS volumes. This is what we currently do here at NUMER. Note that this only works for data volumes, you cannot put a root volume on EFS.

milvain commented 5 years ago

My question: I follow your advises and now it works. My last question is : where I can put the script to mount the EBS because it is attached but not mounted. Is it better to mount in user data or in another place? When I mount the permanent EBS manually, it works.

Answer from numercfd: User data will probably not work for you since it only runs when the instance is created. Unless there are some other requirements, I would not worry too much about it and just create a cron script that runs every minute and check if the volume is mounted and, if not, mounts it.