Consul Cheat Sheet

Welcome to the Consul Cheat Sheet, your quick reference guide for essential commands and operations in HashiCorp Consult

Introduction

Welcome to the Consul Cheat Sheet, your quick reference guide for essential commands and operations in HashiCorp Consul. Consul is a powerful tool for service discovery, key-value store management, and network infrastructure automation. Whether you are a beginner exploring the basics or an experienced user in need of a quick reminder, this cheat sheet provides a concise overview of key Consul commands in a convenient table format.

How to Use

Each entry in this cheat sheet presents a specific Consul command along with a brief description of its purpose. The commands cover a range of functionalities, including starting a Consul agent, interacting with the key-value store, managing ACLs, monitoring the cluster, and utilizing Connect for service mesh capabilities.

Feel free to customize and expand upon these commands based on your specific requirements and use cases. Whether you are working with a single-node development setup or a production-scale Consul cluster, this cheat sheet serves as a handy reference to streamline your interactions with Consul.

Cheat Sheet

No.CommandDescription
1consul agent -devStart a local development Consul agent
2consul agent -server -bootstrap-expect=1Start a single-node Consul server in bootstrap mode
3consul membersList members of the Consul cluster
4consul infoDisplay information about the Consul agent
5consul catalog servicesList services registered with the Consul catalog
6consul kv put key1 value1Put a key-value pair into the Consul key-value store
7consul kv get key1Retrieve the value of a key from the key-value store
8consul kv delete key1Delete a key from the Consul key-value store
9consul monitorMonitor Consul logs in real-time
10consul leaveGracefully leave the Consul cluster
11consul reloadTrigger a configuration reload of the Consul agent
12consul members -detailedDisplay detailed information about Consul members
13consul status leaderShow the current Consul leader
14consul watch -type=key -key=key1Watch a key in the Consul key-value store
15consul event -name=my-eventFire a custom event in the Consul cluster
16consul lock my-key my-commandAcquire a lock on a key for executing a command
17consul lock -name=my-lock my-commandAcquire a named lock for executing a command
18consul acl policy listList ACL policies in Consul
19consul acl role create -name=my-roleCreate a new ACL role in Consul
20consul acl token create -description=my-tokenCreate a new ACL token in Consul
21consul acl binding rule -method=GETCreate an ACL binding rule for HTTP method
22consul operator raft list-peersList Raft peers in the Consul cluster
23consul snapshot save snapshot.snapCreate a snapshot of the Consul server state
24consul operator autopilot healthCheck the health of the Autopilot subsystem
25consul connect envoy -sidecar-for=webGenerate Envoy sidecar configuration for a service
26consul connect proxy -service=webLaunch a proxy for a service in Connect
27consul connect intentions -httpList HTTP intentions in Consul Connect
28consul catalog nodes -service=webList nodes providing a specific service
29consul kv export > backup.jsonExport the entire key-value store to a JSON file
30consul acl bootstrapBootstrap ACLs on a new Consul server
31consul connect intentions create -denyCreate a deny intention in Consul Connect
32consul catalog services -tags=productionList services with specific tags in the Consul catalog
33consul kv put -cas=0 key2 value2Put a key-value pair without check-and-set (CAS)
34consul kv get -recurse keyRecursively retrieve all key-value pairs under a key
35consul monitor -log-level=debugMonitor Consul logs with debug log level
36consul operator keyring use -keyring=my-keyringUse a specific keyring for operator-related commands
37consul config write config.hclWrite a configuration file for Consul
38consul connect proxy -sidecar-for=webLaunch a proxy sidecar for a service in Connect
39consul agent -config-file=my-config.jsonStart Consul agent with a specific configuration file
40consul reload -rpc-addr=127.0.0.1:8400Trigger a configuration reload on a specific RPC address
41consul operator keyring export -keyring=my-keyringExport a keyring for backup or sharing
42consul catalog services -healthList services with health checks in the Consul catalog
43consul connect inject -sidecar-for=webInject Connect proxy configuration into a service
44consul acl token update -id=my-token -name=new-nameUpdate the name of an ACL token
45consul kv put -flags=42 key3 value3Put a key-value pair with a custom numeric flag
46consul agent -retry-join=consul-server-1Join a specific Consul server using retry-join
47consul config write -kind=service my-service.hclWrite a service-specific configuration file
48consul snapshot restore snapshot.snapRestore Consul server state from a snapshot
49consul connect intentions delete -id=my-intentionDelete a specific intention in Consul Connect
50consul versionDisplay the version of Consul