Cloud servers are like cattle. You shoot them when they are sick and introduce new ones, which makes cloud infrastructure very dynamic. It becomes hard to keep track of running services and infrastructure configurations. Suppose, you are hosting a web application on cloud. You have to set up HAProxy with a pool of frontend and backend servers for load balancing and high availability. You need to add/ remove servers in your pool to serve the traffic load. When a new server comes up, your infrastructure does not know about it or the service it provides. Also, you need to remove entries of left servers from your HAProxy, so traffic doesn’t get directed to them. You suddenly find yourself that you are not the cowboy who can drive tens of thousands of cows over great distances anymore, but a worried owner of puppies. We need a service discovery system where we can query newly introduced nodes and services, and get notified when a node and service becomes unavailable. We also need a configuration management system to update and validate the configurations of the servers and the infrastructure.
As a solution, Devops and IT Professionals can use “Consul”, a tool that provides easy service discovery and configuration management for IT Infrastructures. It is distributed, highly available and data center aware. Consul runs as a lightweight agent in your servers(An agent can be either a server or a client) It looks like Consul is the rifle we were looking for and with which we can query nodes or services from the consul. In addition, we should also know that Consul supports DNS query lookup. So thanks to this tool, system administrators can save a lot of time by automating services discovery.
The service discovery system is backed by a service catalog, which maintains a high-level view of the cluster and managed by the server agents. The client agents register their services to this catalog, which offers a list of available services and where specific services are running. In that phase, we query the server(s) to get the status or location of a service. In cloud, service discovery is very important to incorporate newly created cloud servers into an existing cluster to make sure that the services are always running and scalable to comply with traffic peaks. With service discovery, we can design self-healing and auto-scaling systems.
Consul also supports checks: system health checks and service health checks to provide a fine-grained monitoring and control of nodes and services. The serf system health check is enabled by default and unhealthy nodes do not appear in the query. We can define custom system and service health checks according to a specific business and platform needs. In the cloud, these checks can be used to create a highly available infrastructure by trafficking requests only to the healthy nodes ,which means that the requests made by users to the applications or services are served properly guaranteeing a good user experience .Unhealthy nodes can be removed to reduce the cost and to create notifications. This allows the tech team to be aware of the state of the infrastructure and react accordingly. Consul provides a key/value store. It can be used to store service configuration or other metadata. We can populate values from Consul into the filesystem using the consul-template daemon to autoconfigure our service or our infrastructure without any manual intervention .
We can configure watches to monitor a view of data (e.g. list of nodes, KV pairs, health checks) and launch a custom handler. This can be used to run automatic solver in cloud servers in case of a service failure. That way the tech team can spend less time in administrating the infrastructure and focus on other tasks such as business intelligence, product development, etc.
As cloud infrastructures are scattered in various zones, we can create consul datacenters distributed among these zones. Consul supports multiple datacenters, so we can aggregate different zones or multiple cloud providers to supervise them together and create a highly available and responsive cloud infrastructure. Thanks to this system. we can both save time when administrating systems automatically and be sure that our application is responsive.
Another tool which enables to save time managing multi-cloud systems is ECmanaged; A platform that provides automatic deployment and monitoring tools in order to unify the different management procedures that each Cloud Provider offers separately.In fact, ECmanaged can be used to automate the deployment of consul. We will discuss deployment and usage of Consul using ECmanaged in details in coming blog posts.