Automated provisioning in an LXD/LXC server virtualization solution using API

Automated provisioning in an LXD/LXC server virtualization solution using API

I like instant coffee. Why? Because its “instant”! No waiting around. Fast feels good, especially when it comes to using services such as telephone services, web hosting, etc. For instance, in VPS hosting, customers now expect their accounts to be provisioned as soon as they place an order. To make this possible, VPS providers are now increasingly turning to automated provisioning solutions.

Provisioning a new VPS includes installing various applications based on the VPS plan, optimizing them and securing the server. This is a time-consuming process, if done manually. Recently when we helped a customer build a competitive VPS hosting service using LXC containers, we automated these tasks for quick provisioning.

To automate provisioning of VPS instances in our server virtualization solution, we used LXC API. The API allowed creation of a portal for customers to quickly deploy new VPS accounts, manage those accounts and scale them up easily. The major features we automated using the portal included VPS creation, management, backups, scaling up and stats.

 

automated provisioning api server virtualization solution

Automated provisioning via Customer portal

VPS creation

Using the customer portal, users could quickly create VPS instances for the plans they ordered. Whenever a new order was placed, the billing portal processed it and enabled the user to create a VPS corresponding to his plan. The ‘create container’ function was executed by the ‘Create’ button in the portal, with the parameters such as the VPS name, plan, configuration etc.

{
 'name': "Ubuntu-04", 
 'architecture': 2,
 'profiles': ["default"], # List of profiles
 'ephemeral': true,
 'config': {'limits.cpu': "1"}, # Config override.
 'source': {'type': "image", 
 'alias': "ubuntu/VPS-01"}, # Name of the alias
}

The script would test the configuration settings of the new container and start it. The newly created VPS was then listed in the user’s account. The following snippet shows that a new VPS named ‘Ubuntu-04’ was created successfully.

root@host:/home/# lxc-ls
 Ubuntu-01 Ubuntu-02 Ubuntu-03
root@host:/home/# /usr/bin/python3 create.py 
 Container state: RUNNING
 Container PID: 30897
root@host:/home/# lxc-ls
 Ubuntu-01     Ubuntu-02     Ubuntu-03     Ubuntu-04

Managing the VPSs

To provide users with the ability to start and stop their VPSs, we configured functions in the customer portal, using the following parameters.

{
 'action': "stop", # State change action (stop, start, restart, freeze or unfreeze)
 'timeout': 30, # A timeout after which the state change is considered as failed
 'force': true # Force the state change (currently only valid for stop and restart where it means killing the container)
}

VPS backups

VPS backups are maintained in the form of snapshots of the containers. The container backup (aka ‘snapshot’) contained all the information of the container at any moment. Using this snapshot, we could restore the container at a later stage.

Our backup script was configured to stop each container at off-peak hours, take its snapshot, start the container and verify its running fine. The backups were labelled with appropriate identifiers and copied over to our external backup server for redundancy.

{
    'name': "Ubuntu-01-snap0",          # Name of the snapshot
    'stateful': true                # Whether to include state too
}

The ‘Backups’ feature was also provided with options for users to configure automatic VPS backups on a daily, weekly and monthly basis.

Along with the above features, users were also given option to ‘scale’ up their VPS instances to add more resources such as storage, IP address, network, memory etc. ‘Reports’ tab gave summary reports of the VPS performance and resource usage to users over a period of time.

Fast provisioning is a core feature in any VPS hosting solution. Here we’ve covered how we automated provisioning of VPSs in an LXC server virtualization solution using API and python scripts. Bobcares helps VPS providers, data centers and web hosts deliver industry standard services through custom configuration and preventive maintenance of server virtualization solutions.

 

  • No: of servers used in this solution : 2
  • Time taken for design and implementation : 40 hrs
Are you looking for a similar solution?

WE CAN HELP YOU

 


Submit a Comment

Your email address will not be published. Required fields are marked *

Bobcares
Bobcares is a server management company that helps businesses deliver uninterrupted and secure online services. Our engineers manage close to 51,500 servers that include virtualized servers, cloud infrastructure, physical server clusters, and more.
MORE ABOUT BOBCARES