Skip to content

Start the client agents

Chris edited this page Aug 31, 2016 · 17 revisions

Why client agents are important

Having client agents for both Nomad and Consul are essential. The purpose of the client agents is to automatically be able to communicate with the Nomad/Consul servers so that any requests to the client agent can be forwarded to the server.

As long as the client agents know the address of one running server on start up, they will automatically know the addresses of the server cluster. This is essential because now applications on different machines that want to talk to the server can just send a request to the local agent instead of having a hard coded server address and running the risk of not being able to contact the cluster if that specific server goes down. We will use this technique to set up our Consul and Nomad client agents.

Setup

On my second Ubuntu machine I'm first going to start up the local consul agent and activate some important features:
consul agent -data-dir="/tmp/consul" -ui -bind=<ip> -client=<ip>

  • consul agent starts the agent in client mode. Remember that adding -server starts the agent in server mode
  • -data-dir is here for the same reason we need it for the consul server agent
  • -ui isn't necessary, but it makes the agent listenable on a certain port that we can point our browser to and we end up seeing some really nice UI of statuses of our services, nodes, and key value store. By default, this address is http://127.0.0.1:8500/ui This will not work in our scenario. Keep reading as to why
  • -bind=<ip> also will attach the agent to the ip specified. This is required if there are multiple IPs found. Use the IP of the host machine this agent is on.
  • -client=<ip> is the key in making our Manticore system work. It functions the same way as -bind, only now ALL interactions with the agent must now be made on the IP address specified instead of local host (127.0.0.1). Use the same IP as in the -bind flag.

The -client flag

If you remember, our Consul server didn't set the -client flag and because of that we could run consul without any additional parameters. Now, in order to use the Consul API and the consul command you must append -rpc-addr=<ip>:8400 to all commands and when using the Consul API you use the address you put in the -client flag. The reason why we do this is because when we schedule docker containers we want the applications to be able to use the Consul API by talking to the local agent. But, the local host inside the docker container is different from the local host in the virtual machine, which is Consul's default address for using the API. Therefore, we specify an address that the container application can reach so that it can use the API.

Clone this wiki locally