consul
service discovery and configuration tool
TLDR
Start agent in development mode
$ consul agent -dev
List datacenter members$ consul members
Register service$ consul services register [service.json]
Deregister service$ consul services deregister -id=[service-id]
List services in catalog$ consul catalog services
DNS lookup for service$ dig @127.0.0.1 -p 8600 [web.service.consul]
Store key-value pair$ consul kv put [key] [value]
Get key-value$ consul kv get [key]
Join cluster$ consul join [192.168.1.100]
Validate configuration files$ consul validate [/etc/consul.d/]
Reload agent configuration$ consul reload
SYNOPSIS
consul [options] command [arguments]
DESCRIPTION
consul is HashiCorp's service discovery and configuration tool. It provides service mesh, health checking, key/value storage, multi-datacenter support, and secure service-to-service communication.
PARAMETERS
-dev
Development mode (single node, no persistence)-server
Run agent in server mode-bind addr
Address for internal cluster communications (default: 0.0.0.0)-token token
ACL token for authentication-token-file file
File containing the ACL token-datacenter dc
Target datacenter-http-addr addr
Consul HTTP API address-auto-reload-config
Automatically reload configuration when files change
CONFIGURATION
/etc/consul.d/
Configuration directory for Consul agent settings, services, and checks in HCL or JSON format.
COMMANDS
agent
Run a Consul agentmembers
List cluster membersjoin
Join cluster via agent addressleave
Gracefully leave clustercatalog
Interact with service catalogservices
Register/deregister serviceskv
Key/value store operationsconnect
Service mesh functionalityacl
Access control list managementwatch
Watch for changes in data views and invoke a processevent
Fire a custom user eventexec
Remote execution on cluster nodesoperator
Cluster-level operator toolssnapshot
Save/restore cluster statereload
Reload agent configuration filesvalidate
Validate configuration filesmonitor
Stream logs from a running agentdebug
Create debugging archive
ENVIRONMENT
CONSUL_HTTP_ADDR
HTTP API addressCONSUL_HTTP_TOKEN
ACL tokenCONSUL_CACERT
CA certificate pathCONSUL_HTTP_SSL
Use HTTPS when communicating with Consul
DNS INTERFACE
Default DNS port: 8600
$ dig @127.0.0.1 -p 8600 web.service.consul
CAVEATS
ACL system requires token for most operations when enabled. Development mode stores everything in memory. Production requires proper clustering configuration.
