Hi there,
I'm a Symfony developer and need to deploy my website to multiple servers on DigitalOcean. The current tools and services aren't a good fit for my use case anymore, so I'm building Clustermin to help me automate my deployment tasks.
Deploying to multiple servers is a must for high availability. When one server is down, there's another server to continuously serve my website visitors. When I want to upgrade servers, e.g. from Ubuntu 20.04 to 22.04, or resize servers, I can just create new servers and delete the old ones.
 |
A web cluster with just 2 servers. |
So, let's get started.
First, create an account at Clustermin if you don't have one yet.
Next, create a cluster. A cluster is a group of similar servers that serve the same purpose. A web cluster consists of one or multiple servers with Nginx, and PHP8.1 FPM installed, ready to deploy your website.
 |
Create a new Web cluster |
Before connecting your servers to the newly created cluster, add a site first. A Site is your website/web app, or whatever you call it. Clustermin will store your files on /home/clustermin/yoursite.com/current.
 |
Create a new site. Yay free domain!
|
Currently, Clustermin will give you a free subdomain like random.clustermin.net. Use it for testing purposes only.
Clustermin supports deploying from a Git repository, so let's just update the site settings to deploy https://github.com/symfony/demo.git to our servers.
 |
Set up a git repo and deploy script. |
If you deploy your own Git repo, you must visit your repository settings, and add the deploy key first. For Github, just log in to your account, visit your repo, click Settings > Deploy keys and add the copied deploy key from Clustermin.
Now, the final step is adding a new server.
 |
Create a server from DigitalOcean |
To connect your DigitalOcean account to Clustermin, log in to DigitalOcean, visit API, click Generate New Token, copy the key and add it to Clustermin at the Providers tab.
 |
Clustermin is doing something to your server. |
Clustermin will now set up your server and deploy your site. It'll take a while, go grab a cup of coffee.
If the deployment of a site fails, you'll get an email notification like this:
 |
If something breaks, better check the error logs. |
When the deployment is okay, visit your domain and see the newly deployed website:
 |
It works!
|
Install SSL certificate
Now, you may want to get an SSL certificate for your website. If you already have one, just add it to your site on the SSL tab. If you use a test domain at .clustermin.net, everything is ready and you can get your SSL with just one click.
 |
Yay free SSL!
|
If you use your own domain name, follow the instruction on your site to set the CNAME record to random.on.clustermin.com. After that, you can get a free SSL certificate, and have the destination IP addresses auto-updated when you add/remove a server.
Deploy on git push
If you want to enable quick deployment i.e. deploy to your servers on git push, visit Site > Settings, and copy the deploy URL. To set it up on Github, log in to your account, visit the repo > Settings > Webhooks, click Add webhook and paste the copied deploy URL there.
Cron jobs and daemons
Clustermin also supports setting cron jobs and running daemons (with supervisor).
Scale it to infinity
Now your website has been running and working fine on a server. When you need to add new servers, just provision a new server from DigitalOcean and connect it to your server cluster, go grab a cup of coffee and everything is automated for you.
What about the database and cache?
Clustermin currently allows you to create a Redis cache (master replica only). It's recommended to just get a managed database from DigitalOcean. Make sure it accepts connections from your servers (via tags).
Put it behind a load balancer
If you choose to use a load balancer, it's recommended to set SSL at the load balancer. Creating a load balancer at DigitalOcean is pretty straightforward. Just make sure you update the Healthchecks protocol to TCP instead of HTTP.
Comments
Post a Comment