Getting Started with Consul CLI
in Tutorial with 0 comment
Getting Started with Consul CLI
in Tutorial with 0 comment

Installing the consumer cli

This is only installed on the macOS. You need to install homebrew in advance, and then execute the following command:

 brew instal consul

Check whether the installation is successful

 consul --version  //Back Consul v1.0.0 Protocol 2 spoken by default, understands 2 to 3 (agent will automatically use protocol >2 when speaking to compatible agents)

Using the consumer cli

Consul can be easily controlled by the command line tool (CLI). At this time, Consul is just a single command line application: consult. This application receives some subcommands, such as "agent" or "members". For a complete list of subcommands, see the navigation on the left.

The Consul CLI is an easy-to-use command line application. In case of error, a non-zero exit status code will be returned. It also responds to the - h and - help you most likely expect. Some commands also accept "-" as a parameter to let Consul read standard input.

At any time, to browse all available commands, just run consume without any parameters:

 consul Usage: consul [--version] [--help] <command> [<args>] Available commands are: agent          Runs a Consul agent catalog        Interact with the catalog event          Fire a new event exec           Executes a command on Consul nodes force-leave    Forces a member of the cluster to enter the "left" state info           Provides debugging information for operators. join           Tell Consul agent to join cluster keygen         Generates a new encryption key keyring        Manages gossip layer encryption keys kv             Interact with the key-value store leave          Gracefully leaves the Consul cluster and shuts down lock           Execute a command holding a lock maint          Controls node or service maintenance mode members        Lists the members of a Consul cluster monitor        Stream logs from a Consul agent operator       Provides cluster-level tools for Consul operators reload         Triggers the agent to reload configuration files rtt            Estimates network round trip time between nodes snapshot       Saves, restores and inspects snapshots of Consul server state validate       Validate config files/directories version        Prints the Consul version watch          Watch for changes in Consul

To get help for any specified command, pass the - h parameter to the relevant subcommand. For example, to see the help of the agent subcommand:

 consul agent -h ==> Usage: consul agent [options] Starts the Consul agent and runs until an interrupt is received. The agent represents a single node in a cluster. Command Options -advertise=<value> Sets the advertise address to use. -advertise-wan=<value> Sets address to advertise on WAN instead of -advertise address. -bind=<value> Sets the bind address for cluster communication. -bootstrap Sets server to bootstrap mode. -bootstrap-expect=<value> Sets server to expect bootstrap mode. -client=<value> Sets the address to bind for client access. This includes RPC, DNS, HTTP and HTTPS (if configured). -config-dir=<value> Path to a directory to read configuration files from. This will read every file ending in '.json' as configuration in this directory in alphabetical order. Can be specified multiple times. -config-file=<value> Path to a JSON file to read configuration from. Can be specified multiple times. ... -ui-dir=<value> Path to directory containing the web UI resources.

Closing

Responses