Consul – Dynamic Infrastructure
Consul is a distributed service mesh to create dynamic infrastructure and manage service configurations across any runtime platform. The project is hosted at Github under the Mozilla Public License, version 2.0.
Consul provides several key features:
- Service Discover
- Health Checking
- Service Segmentation
It aims to shift from static infrastructure to dynamic infrastructure changes the approach to networking from host-based to service-based.
Consul has service discovery, registration and health check process that can be more useful to create service-based networking. These features allow services to scale up/down and handle failure without load balancer.
It uses LAN and WAN gossip protocols to manage membership and broadcast messages to the cluster. Also RPC uses to allow a client to make a request of a server.
- 3 Server (1 bootstrap and 2 server)
- Consul Binaries
- Application user to perform installation
Step 1: Download binaries
Step 2: Extract and manage permissions
I extracted consul binaries under “/appdata/consulv1” directory. You need to perform these steps at all servers that you will add Cluster.(1 bootstrap and 2 Server)
#chmod u+x consul
#chown appuser:appgroup consul
Step 3: Create configuration file for bootstrap and server.
It is important to set this flag for only one server in datacenter. In a datacenter there must be only one bootstrap server.
It is optional to change service ports. I only want to show that you can manage ports on Consul. If you don’t want to change default ports then remove ports from configuration file.
Step 4: Create service configuration file
I added service configuration file for RHEL7-Centos and Fedora. If you have run on another platform you should create a service file to start and stop Consul.
--Start Bootstrap First--
#systemctl enable consul-bootstrap
#systemctl start consul-bootstrap
#systemctl enable consul-server
#systemctl start consul-server
I added a basic python code to show how to check consul servers’ health and register an existing service to the consul.