Custom OS Templates – 5 Ways You Can Use Them
VPS.NET allows you to create your own operating system templates, and then use them on new cloud servers. Giving you the ability to deploy servers exactly how you want them with full customization.
An advanced use case for this would be large applications that need to scale horizontally for short periods of time depending on traffic and usage patterns. A developer can create a custom template with their software already installing and running in a way that once a new cloud server is created, it can instantly start processing requests without the need for additional customization. Using the VPS.NET API can even allow you to automate this for an awesome way to scale both up and down, serving your application efficiently while still keeping costs to a minimum.
Custom templates can be useful for the common folk as well though, ideally saving you time from doing repetitive tasks over and over again on every server you create. Here’s a few examples on how you can use a custom template to make you deployments easier.
For these examples, let’s assume you’re a web developer who offers hosting to your clients. You like to use a different server for each client, here’s a few ways you can use a custom template.
1. Install Your Software
Chances are you’re going to be doing something with your server, you’re not just booting it up and leaving it there all lonely. The bulk of the time that goes into deployment is installing and configuring the various software components needed for your server.
Let’s take a website for example. After you clean out the bloatware, set up a basic firewall, and lock down authentication, you’ll need to install a few things to get your website up and running. Let’s say you need Apache, PHP, and MySQL. Fairly common, right?
Well, you could go through the installation process of each of those every time you launch a new server for a client. Or you could do it once, and save it as a template. This means you have everything ready to go instantly as you create a new cloud server.
Beyond just installing your software, go ahead and make all your little tweaks as well. Maybe you need to disable some PHP functions so your client doesn’t screw things up. Perhaps you need to increase the amount of memory you allow MySQL. You might also want to make configuration tweaks to Apache to get the maximum performance out of it. The beauty is, all the work you put into configuring everything will pay off time and time again every time you launch a new cloud server with this OS template.
All of this can potentially take 30 minutes up to a few hours depending on what you’re doing. You can save yourself this time on every new cloud server by having a custom template, built by you, for you, with all your custom software and configuration.
2. Set Up Your Authentication
Hopefully you’re using SSH keys to log in to your server. In your template, you can load up your public SSH key and even disable SSH password authentication for security altogether. Hell, go ahead and change the port while you’re at it as well. Meaning, next time you spin up a server using this custom template, you’ll have immediate access to the server using your private SSH key and custom port without having to fumble around importing it or dealing with root passwords.
I should note, that this doesn’t mean you can completely disregard root passwords. Choose a super strong one and stash it somewhere safe, just in case you need to use the console.
3. Set Up Your Firewall
As a developer, you probably want to drop all traffic to ports you don’t want open to the public. Even if there’s no service listening on your server. Or perhaps you want to block all traffic to your SSH daemon, white listing only your IP address. Well, rather than having to relearn IPTABLES or go through what’s surely an overwhelming firewall config every single time, just do it once and stick it in a template. The next time you spin up a new server using this template, your base firewall rules will be right there and running, leaving you to only make the configuration tweaks specific to this server or client.
Let’s be honest, IPTABLES is what the almighty Penguin put on this earth to torment all sysadmins.
4. Configure Startup Applications
Nobody likes bloatware. While most Linux distributions are pretty good about bloatware, and most of the basic templates are already running under 20MB RAM out of the box, there’s probably that one thing you always have to remind yourself to diable to save that extra 1MB of RAM. For me, on CentOS and Ubuntu distributions, I have a habit of disabling the saslauthd daemon. Why? I don’t need it, and you should never be running services you don’t need, and you should especially make sure you’re disabling them at startup.
5. Set Up Server Monitoring, Alerts, Bash Scripts, and Crons
Okay, I’m cheating a bit to get this list to 5. However, the power of custom templates is endless and allows you to save an enormous amount of time by doing various base tasks just once, then loading up that OS template for your future cloud servers.
The key is to keep your template up to date. Coming back to it every once in a while and making sure things are how you like them and then saving it again for future use. You also want to make sure the software and configuration in your template is flexible, and something you can add to. You don’t want to create a template that you have to remove from, nor do you want one that has configuration to specific to a particular instance that you can”t easily use it on a new server.