The so-called swarm cluster represents a set of Docker Engine nodes that are run in a swarm mode to constitute a fault-tolerant platform for application hosting with built-in cluster management features. It helps to keep your dockerized services constantly running and available through distributing the workloads across different servers and data centers. Moreover, by its original implementation, Docker swarm provides such extra benefits as automatic disaster recovery, zero-downtime updates, etc. But at the same time, running such a cluster of Docker nodes could be fraught with some difficulties as this technology is rather new and thus still requires considerable system administrator’s efforts for its handling.
That’s why, in today’s article, we will describe how to avoid the complexity of manual swarm building and maintenance with a dedicated Docker Swarm Cluster package for one-click installation. This solution allows setting up a ready-to-go dockerized cluster of the required size in a matter of minutes. So, let’s go on and dive into the specifics of its realization and usage.
Docker Swarm Cluster Topology Specifics
In accordance with the original swarm cluster implementation, structure of the environment you’ll get upon installation of the package is composed of two layers (node groups) with the following prescribed roles:
- Manager - maintains the desired state of your swarm and all of the services that are run on it
- Worker - receives and executes tasks, that are dispatched from Manager node(s)
During installation, you can declare the desired number of containers for each layer (so-called “replicas”) and choose one of the available installation types:
- setting up a bare cluster to subsequently deploy the required Docker image manually
- create a swarm with the already deployed image based on the provided compose file
By default, each node has a pre-allocated room of resources for growth upon the necessity (up to 8 GiB RAM per container). At the same time, you always pay only for the actually consumed capacities due to the pay-per-use Jelastic pricing approach.
Herewith, cluster memory consumption in idle mode is less than 128 MiB (1 cloudlet) per container, which is charged accordingly to your hosting provider pricing. This way, a reliable Docker swarm cluster of 8 nodes can be hosted for a price of just 8 cloudlets!
As an additional benefit of your swarm cluster hosting at Jelastic PaaS, all containers are equally automatically distributed across the available at a platform host nodes (i.e. physical servers) to ensure extra high availability of your application.
- The chosen platform should contain environment region(s) with native Docker container support enabled. You can check a list of the supported providers via the link.
- The included option of public IP attachment to the manager nodes is provided for billing users only.
Swarm Cluster Load Alerts & Scaling
Another significant advantage of the Docker Swarm Cluster package by Jelastic stands for convenient resource consumption statistics tracking, which allows automatic notification about load spikes or drops.
1. By default, the cluster is provided with load alerts that notify you via email about high consumption of some resource (CPU, RAM, network, etc.):
They help to keep you up-to-date with the cluster state and swiftly respond in case of any issues or necessity to enlarge capacities.
2. If you need to provide additional resources for the cluster, you can enlarge the vertical scaling limit (32 cloudlets by default) or add new nodes into the swarm. Both actions can be configured via topology wizard:
Herewith, to take advantage of swarm mode’s fault-tolerance features, Docker recommends implementing an odd number of manager nodes according to your organization’s high-availability requirements.
3. Also, you can pre-configure the automatic horizontal scaling of both manager and worker nodes, which is executed based on the current cluster load. For example, scaling can be performed according to the following conditions:
- add node(s) if RAM or CPU usage is >70% for at least 5 minutes
- remove node(s) if RAM or CPU usage is <40% for at least 5 minutes
In order to keep the odd number of managers, it is recommended to scale the layer by pairs of nodes.
4. Also, to achieve additional high availability and failover protection for Docker services that you’d like to run, you can manually attach nodes from different environment regions or even installations to your swarm cluster. All the required information was sent to you via the appropriate email after the cluster installation.
We’ve already considered the appropriate Docker Engine Inclusion into Swarm Cluster procedure in one of our articles.
Docker Swarm Installation
The Docker Swarm installation from Jelastic Marketplace is fully automated and requires just a few simple steps.
- Free trial installation is available at Jelastic service providers from Switzerland: Flow App Engine and Hidora. Follow the link to get started at one of them
- A set of other providers in different locations offers Docker Swarm within full billing accounts. Choose the one you require and proceed to installation using this link
If you are already registered at one of the mentioned above Jelastic service providers, you can start the installation from your dashboard.
1. Click the Marketplace button at the top of the dashboard pane and search for the Docker Swarm Cluster solution within the opened window.
Hover over the appropriate plank and click Install to continue.
2. In a second, the installation frame will be opened.
Here, you need to tune some details to get the cluster you need:
- Docker Version - version of the Docker Engine CE image
- Manager Nodes - an odd number of manager nodes to be included in a cluster (with public IP being automatically attached to each container)
- Worker Nodes - number of worker nodes to be included in a cluster
- choose deployment type:
- Clean Cluster - to create a bare cluster; as an extra option, you can simultaneously install the Portainer management UI with Let’s Encrypt SSL certificates for convenient operating with cluster nodes
-
- Deploy Stack YML - to perform the docker stack deploy operation after the cluster creation and instantly install the required dockerized services specified in the appropriate compose YML file:
- Environment - a name for your environment
- Display Name - optional alias to be displayed for environment
- Region - preferred environment region (if multiple ones are available)
As an example, we’ll create a bare Docker swarm cluster with 3 manager, 5 worker nodes, and Portainer UI with Let’s Encrypt SSL. So, once all the required configurations are stated, click Install and wait for a few minutes for Jelastic PaaS to automatically perform all the necessary actions.
3. After your cluster is deployed, the corresponding environment will appear on the dashboard.
Next, in order to start working with your cluster, you need to access any of its manager nodes - below, we’ll discover the ways this could be accomplished.
Docker Swarm Connection
After the successful installation, your cluster can be accessed in the following ways for further management:
-
Portainer UI
In case you’ve installed a clean cluster with the Portainer UI & Let’s Encrypt SSL, the appropriate management panel can be accessed by simply opening your environment in a browser via HTTPS (the 443 port).
The required actions could differ depending on a used browser – for example, in Google Chrome, you’ll need to expand the Advanced section and click on the Proceed to {env_URL} link.
The appropriate authentication credentials to enter the Portainer itself can be found within the corresponding email notification you’ve received after the Docker swarm creation.
-
SSH Gate
Use Jelastic SSH Gate to connect to one of the Manager nodes within your Docker swarm environment to start managing the whole cluster. You can establish an SSH connection to the required container directly via the dashboard by clicking on the Web SSH button.
An alternative option is to connect via any preferred SSH client (you’ll need to upload your public key to the dashboard).
Custom Domain & SSL Protection
Before rolling out to production with your Docker swarm cluster, you definitely need to bind a custom domain name for your application and to protect this domain with a trusted SSL certificate.
1. You can review and fulfill the requirements to add SSL protection by clicking the Change Environment Topology button for the required environment (i.e. your Docker swarm cluster).
2. Within the opened wizard, switch to the SSL section. Here, you can see the pre-requirements of the custom SSL configuration for the environment.
Click the Enable button to make the required adjustments automatically and Apply these changes.
3. In a minute, a load balancer node with an external IP address will be added to the environment, allowing to add a custom domain name. Follow the linked guide to view an example of how to:
- purchase a custom domain for your application
- configure DNS record to point from this domain to your Jelastic environment
4. Now, you can proceed with the SSL configuration. Herewith, two options are available:
- automated configuration via the Let's Encrypt SSL add-on
- manual upload of custom SSL certificates
After these manipulations, your Docker swarm cluster will be ready for production. If you want to learn the basics of the services and applications deployment to the swarm cluster, follow the linked guide.
This concludes our article - creating and connecting a swarm cluster with Jelastic PaaS is that simple! Try it out right now and get your reliable and highly scalable cluster with access to native Docker functionality.