Consul Bootstrapping & DNS - Consul

What are Consul Bootstrapping & DNS?

In this section, we will talk over how the resulting components are used in Consul.

  • Automatic bootstrapping
  • Manual bootstrapping
  • Using DNS Forwarding
  • DNS Caching

Let us now talk over each of these in detail.

Automatic Bootstrapping

Bootstrapping is one of the main features of Consul. When you set up consul for the first time, it is automatically organized to notice, classify and join nodes it comes across. Throughout its cluster formation, automatic bootstrapping is a built-in feature of Consul. To increase more data on consul, the best way is to use the command below –

The output would be as shown in the resulting screenshot.

automatic_bootstrapping

This command will display the real working of consul in real working situations. It will show the Raft Algorithm working in Consul. The automatic bootstrapping command can be revealed using the resulting command –

Automatic bootstrapping cannot be done in -dev mode.

This choice informs Consul of the predictable number of server nodes and mechanically bootstraps when servers are existing.

Manual Bootstrapping

Manual Bootstrapping is an old and valuable feature of Consul. Really, throughout Consul's earlier version, bootstrapping has to be done manually when setting up and using consul for the first time. Later, it was understood that it was not likely to achieve this command line operation at diverse times. Therefore, automatic bootstrapping was presented. You can every time use bootstrapping manually by using the resulting commands.

In this case, we will take up that a 3-node consul cluster is to be built.

There are two choices to do manual bootstrapping

  • Running commands over 2 nodes: On Node B and Node C you can do the resulting −

  • Running command over 1 node −

Using DNS Forwarding

DNS is functioned from port 53. The DNS advancing can be done using BIND, dnsmasq and iptables. By default, the Consul agent runs a DNS server listening on port 8600. By submitting DNS needs to the Consul agent’s DNS server, you can get the IP address of a node running the service in which you are interested.

The Consul DNS crossing point makes the port information for a facility obtainable via the SRV records. Without manually adding logic in your code, you are commonly restricted just to the IP address info (i.e. a record) of the service you are querying.

The best choice is to have numerous BIND servers each running a Consul agent locally. Any requests established by a BIND server would be forwarded to its local Consul Agent DNS Server.

Using Bind

We can use DNS Forwarding using the Bind function. It can be done by using the following command.

The output would be as shown in the resulting screenshot.

bind_function

Let us edit the /etc/bind/named.conf file with the following command.

In the file, please add the following lines below the last line of the code.

The output would be as shown in the resulting screenshot.

bind_command

You can take the resulting Bind command to configure Consul.

Add the following lines when you create the file −

Now you can start running your consul agent by using the following command. (Remember to restart the bind9 service as well.)

The system needs to be arranged to send questions to the local Consul agent’s DNS server. This is done by informing the resolv.conf file on the system to point to 127.0.0.1. In best cases, Consul will need to be configured to run on port 53.

You can add the resulting information to the /etc/resolv.conf:

DNS Caching

Consul helps all DNS results with a ‘0 TTL’ (Time to Live) value. This stops any caching. Though, due to the TTL values, it can be set to allow DNS results to be cached with downstream of Consul. Higher TTL values decrease the number of lookups on the Consul servers and speed lookups for clients, at the cost of progressively stale results.

For this purpose, we are going to use DNS caching using the method below −

The output would be as revealed in the resulting screenshot.

dnsmasq

Now, we can do a very simple configuration −

All we are doing here is stating that DNS requirements for consul services, which are to be allocated with by the DNS server at 127.0.0.1 on port 8600. Without you change the consul defaults, this should work.

In normal cases, the following command should be used.

With Dnsmasq, you should use the following command.

The output would be as shown in the resulting screenshot.

web_service

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Consul Topics