I discovered Folding@Home from the following blog while I was sat at my Mother's one Sunday afternoon after helping with the shopping. My Mother having Asthma & COPD, my Father with diabetes and my Step-Father who suffered a bad stroke late last year all fall within the high-risk category. I decided to do my part and see if I could get this up and running on my home PC. Five minutes later I was connected and my PC was completing a folding project on to helping to find therapeutic opportunities for COVID-19. You can repeat this with any machine you have at home by going to Folding@Home.
I then thought how could I take this one step further and combine this with my other work expertise. I set out on the following Saturday afternoon to see if I could get a repeatable deployment running on Azure. Using my Azure MSDN subscription I believe this is the first terraform based deployment. This deployment doesn't require you to login and setup the Azure VM that is completed for you. All that is required is a few code edits and a terraform apply and that's it your up and running. I admit I am not the first to do this and there are some other fantastic github projects as well.
Terraform to setup Folding@Home instances in Azure.
- An Azure account. I used an MSDN subscription for this. With the Azure Free Subscription you will have £150 credits that will allow you to running a Standard F4s_v2 VMs for 24x7 for one month.
- A Service Principal with Contributor rights over your Azure Subscription.
- Install Terraform.
- Install Git.
- Clone the repo to your machine.
- Edit the terraform.tfvars file.
- Edit the cloud-init.yaml file to configure the folding at home client.
- Run terraform init
- Run terraform apply
- Terraform will output the hostname for the folding VMs in Azure. These can be accessed at http://hostname:7396
Open the file with your editor of choice (VS Code recommended) Fill in your values in between the quotations.
- tenant_id: Your Azure Tenant ID
- subscription_id: Your Azure Subscription ID
- client_id: Your Service Principal Client ID
- client_secret: Your Service Principal Secret
- location: Azure Region to deploy to. I chose West Europe
- clientip: Your Public IP you will be viewing your folding from
- fahvmusername: Username used to login to the linux VM
- fahvmpassword: Password used to login to the linux VM
- User: This can be any unique identifier that you want to use to track your work contribution. Read more about users.
- Team: The team that you want to associate your work with. My Team is 248825. Read more about teams.
- Passkey: A unique identifier that ties your contributions directly to you (not just those with your username). Read more about passkeys.
- Allow: Replace x.x.x.x with your public IP to be able to view your host with a web browser. To find out what your public IP is use this handy little website.
- Web-Allow: Replace x.x.x.x with your public IP to be able to view your host with a web browser.
- Password: Set A Password to remotely manage the FAHClient with FAHControl. Download from here.
There are several more advanced options that can be changed, there are as follows.
In the terraform.tfvars file add the lines
- fahvmcount: Then set to the number of VMs you would like to build e.g. 3
- fahvmname: To change the Prefix of the Virtual Machine name.
- fahvmsize: If you would like to change the VM size from the default Standard_F4s_v2 e.g Standard_D2s_v2. I would not recommend the B-series VMs.
- fahvmgpuenabled: Set this value to true if using an Nvidia based VM such as Standard_NC12s_v3. Currently the NVv4 series will fail to deploy as it is an AMD based GPU.
In the cloud-init-yaml file
- GPU: Set value to true if using an Nvidia based Azure VM. Recommended SKU is the NCv3-series. Currently the NVv4 series will fail to deploy as it is an AMD based GPU.