LinuxCommandLibrary

consul

service discovery and configuration tool

TLDR

Start agent in development mode

$ consul agent -dev
copy
List datacenter members
$ consul members
copy
Register service
$ consul services register [service.json]
copy
Deregister service
$ consul services deregister -id=[service-id]
copy
List services in catalog
$ consul catalog services
copy
DNS lookup for service
$ dig @127.0.0.1 -p 8600 [web].service.consul
copy
Store key-value pair
$ consul kv put [key] [value]
copy
Get key-value
$ consul kv get [key]
copy
Join cluster
$ consul join [192.168.1.100]
copy

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)
-token token
ACL token for authentication
-datacenter dc
Target datacenter
-http-addr addr
Consul HTTP API address

CONFIGURATION

/etc/consul.d/

Configuration directory for Consul agent settings, services, and checks in HCL or JSON format.

COMMANDS

agent

Run a Consul agent
members
List cluster members
join
Join cluster via agent address
leave
Gracefully leave cluster
catalog
Interact with service catalog
services
Register/deregister services
kv
Key/value store operations
connect
Service mesh functionality
acl
Access control list management
snapshot
Save/restore cluster state
debug
Create debugging archive

ENVIRONMENT

CONSUL_HTTP_ADDR

HTTP API address
CONSUL_HTTP_TOKEN
ACL token
CONSUL_CACERT
CA certificate path

DNS INTERFACE

Default DNS port: 8600

$ dig @127.0.0.1 -p 8600 web.service.consul
copy

CAVEATS

ACL system requires token for most operations when enabled. Development mode stores everything in memory. Production requires proper clustering configuration.

SEE ALSO

vault(1), nomad(1), terraform(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community