dnslb is a dns controller which interprets healthchecks from healthagent and healthd and updates dns zones depending on whether the endpoints are reported alive or not.
dnslb is designed to be be run in a fault tolerant cluster. This can be realized using its raft implementation or rely on a kubernetes e nvironment, but can be executed as standalone as well (without leaderelection)
Current state is pre-alpha don't use it for productive infrastructure yet.
Currently only autodns is supported, but support for bind is planned as well.
The election mechanism must be specified. This allows dnslb to be deployed as a fault tolerant cluster, where only one dnslb is active at any time. This can be one of these options:
- singleton
- k8s
- raft
This is used when you do not need a fault tolerant cluster.
Use k8s to select the lader of the cluster.
Use internal raft implementation to select the lader of the cluster.
The raft algorithum is stateful, storing the current leader and members of the cluster. Because of this it must be initialized and configured.
Raft requires each server to have a unique identity and be able to talk to all the other servers to vote on leadership and exchange state.
To provide a unique identity to a raft cluster member use the -instance-id
argument or the instance-identifier
configuration file option.
To provide allow comunication between raft cluster members we must provide a address. This address can be specified with the -raft-address
argument or the raft-address
configuration file option.
To initialize the raft cluster one and only one of the cluster nodes but be bootstrapped. This is done by running dnslb with the -raft-bootstrap
flag.
Once this is done members of the cluster can be added. This requires use the raftadmin
command which also has some documentation.
This example is running 3 instances on a single node, all coomand line options excluding raft have been omitted for clarity.
- Make the raft state directory
$ mkdir /tmp/tmpkui4bj7c
- Make the raft state directory for each instance
$ mkdir /tmp/tmpkui4bj7c/identifier_1 $ mkdir /tmp/tmpkui4bj7c/identifier_2 $ mkdir /tmp/tmpkui4bj7c/identifier_3
- Start the first
dnslb
. Note: that we added a-raft-bootstrap
flag.$ dnslb -election raft -instance-id identifier_1 -raft-address localhost:3648 -raft-dir /tmp/tmpkui4bj7c -raft-bootstrap
- Start the second and third
dnslb
instances. Note: that we did not add a-raft-bootstrap
flag.$ dnslb -election raft -instance-id identifier_2 -raft-address localhost:3650 -raft-dir /tmp/tmpkui4bj7c $ dnslb -election raft -instance-id identifier_3 -raft-address localhost:3652 -raft-dir /tmp/tmpkui4bj7c
- Bind the
dnslb
identifier_2
to thednslb
identifier_1
.Now we have a two dnslb cluster with a leader.$ raftadmin localhost:3648 add_voter identifier_2 localhost:3650 0
- Add the final dnslb to the cluster. You can add as many as you like at this point, but it is recommended that their is an odd number.
$ raftadmin --leader multi:///localhost:3648,localhost:3650 add_voter identifier_3 localhost:3652 0
A raft cluster cannot be changed without a leader being elected.
Useful raftadmin
commands.
- Run with no commands to get list of available commands:
$ raftadmin
Usage: raftadmin <host:port> <command> <args...>
Commands: add_nonvoter, add_voter, applied_index, apply_log, await, barrier, demote_voter, forget, get_configuration, last_contact, last_index, leader, leadership_transfer, leadership_transfer_to_server, remove_server, shutdown, snapshot, state, stats, verify_leader
- Get the raft cluster leader:
$ raftadmin --leader multi:///localhost:3648,localhost:3650,localhost:3652 leader
- Change the raft cluster leader:
$ raftadmin --leader multi:///localhost:3648,localhost:3650,localhost:3652 leadership_transfer
- Change the raft cluster leader to a specified leader. Note we must specify the identifier for the
dnslb
and its raft address.:
$ raftadmin --leader multi:///localhost:3648,localhost:3650,localhost:3652 leadership_transfer_to_server identifier_3 localhost:3652
- Get the current raft cluster configuration.
$ raftadmin --leader multi:///localhost:3648,localhost:3650,localhost:3652 get_configuration
Licensed under MIT.