{"id":22442185,"url":"https://github.com/colinbut/consul-example","last_synced_at":"2026-02-14T08:32:47.346Z","repository":{"id":69158047,"uuid":"154055030","full_name":"colinbut/consul-example","owner":"colinbut","description":"Consul example","archived":false,"fork":false,"pushed_at":"2018-10-23T20:47:07.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-09T05:06:46.849Z","etag":null,"topics":["consul","consul-agent","consul-api","consul-cluster","consul-configuration","consul-kv","consul-service"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/colinbut.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-21T21:44:44.000Z","updated_at":"2022-02-23T19:49:20.000Z","dependencies_parsed_at":"2023-04-11T22:11:20.685Z","dependency_job_id":null,"html_url":"https://github.com/colinbut/consul-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/colinbut/consul-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinbut%2Fconsul-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinbut%2Fconsul-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinbut%2Fconsul-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinbut%2Fconsul-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/colinbut","download_url":"https://codeload.github.com/colinbut/consul-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinbut%2Fconsul-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29440413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T07:24:13.446Z","status":"ssl_error","status_checked_at":"2026-02-14T07:23:58.969Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["consul","consul-agent","consul-api","consul-cluster","consul-configuration","consul-kv","consul-service"],"created_at":"2024-12-06T02:18:22.997Z","updated_at":"2026-02-14T08:32:47.330Z","avatar_url":"https://github.com/colinbut.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Consul Example\n\nThis repo demonstrates the uses of Hashicorp's Consul.\n\n1. Service Registry\n2. Health Checks\n3. Key-Value (K/V) store\n\n## Table of Contents\n\n* [Intro](#intro)\n    * [Starting Consul Agent](#starting-consul-agent)\n\t* [Querying Consul Agents (Members)](#querying-consul-agent)\n* [Configuration Directory](#configuration-directory)\n* [Services](#services)\n* [HealthChecks](#healthchecks)\n* [Consul Connect](#consul-connect)\n    * [Intentions](#intentions)  \n* [Cluster](#cluster)\n  * [Start the Server \u0026 Client](#start-server-client)\n  * [Joining Cluster](#joining-cluster)\n  * [Query the Nodes](#querying-nodes)\n  * [Leave Cluster](#leave-cluster)\n* [Key/Value (K/V) Store](#kv-store)\n* [UI Web Console](#ui-web-console)\n\n### \u003ca name=\"intro\"\u003e\u003c/a\u003eIntro\n\n#### \u003ca name=\"starting-consul-agent\"\u003e\u003c/a\u003eStarting the Consul agent:\n\n```bash\nconsul agent\n```\n\nStarting in \"Dev\" mode:\n\n```bash\nconsul agent -dev\n```\n\n#### \u003ca name=\"querying-consul-agent\"\u003e\u003c/a\u003eQuerying Agents (Members)\n\nFrom CLI:\n\n```bash\nconsul members --detailed\n```\n\nvia HTTP API:\n```\ncurl localhost:8500/v1/catalog/nodes\n```\n\ndefault port of `8500` applies\n\nor via DNS interface:\n\ne.g.\n```\ndig @127.0.0.1 -p 8600 ip-192-168-20-127.eu-west-1.compute.internal\n```\n\n\"Note that you have to make sure to point your DNS lookups to the Consul agent's DNS server which runs on port 8600 by default.\"\n\n\n### \u003ca name=\"configuration-directory\"\u003e\u003c/a\u003eConfiguration Directory\n\nA 'config' directory for Consul. The directory stores:\n\n1. Service definition files\n2. HealthChecks definitions\n3. Sidecar Proxy definitions\n\nThis config directory is commonly stored under `/etc/conf.d`\n\nCreate the folder before starting up Consul.\n\ne.g.\n```bash\nsudo mkdir /etc/conf.d\n```\n\n### \u003ca name=\"services\"\u003e\u003c/a\u003eServices\n\nYou define 'services' in a \"Service Definition\" file which is of JSON format. See this repo for samples.\n\nYou store the definition files in the Configuration Directory.\n\nIf Consul is already started up after you placed the 'new' Definition files in the Configuration Directory then issue either a Consul reload or SIGNUP\n\ne.g.\n```bash\nconsul reload\n```\n\n__Queries__\ne.g.\n```bash\ncurl http://localhost:8500/v1/catalog/service/web\ncurl 'http://localhost:8500/v1/health/service/web?passing'\n```\n\nor via DNS:\n```bash\ndig @127.0.0.1 -p 8600 rails.web.service.consul SRV\n```\n\n### \u003ca name=\"healthchecks\"\u003e\u003c/a\u003eHealthChecks\n```bash\ncurl http://localhost:8500/v1/health/state/critical\n```\n\nor via DNS:\n```bash\ndig @127.0.0.1 -p 8600 web.service.consul\n```\n\n### \u003ca name=\"consul-connect\"\u003e\u003c/a\u003eConsul Connect\n\n[TBC]\n\n```bash\nconsul connect proxy -sidecar-for socat\nconsul connect proxy -service web -upstream socat:9191\nconsul connect proxy -sidecar-for web\n```\n\n#### \u003ca name=\"intentions\"\u003e\u003c/a\u003eControlling access with Intentions\n\nInteractions in Consul are a way to specify whether a service can or cannot communicate with another service.\n\n__Deny__\n```bash\nconsul intention create -deny web socat\n```\n\n__Allow it again__\n```bash\nconsul intention delete web socat\n\n```\n\n### \u003ca name=\"cluster\"\u003e\u003c/a\u003eCluster\nAssumming you're running more than one node and therefore have multiple nodes forming a cluster.\n\n#### \u003ca name=\"start-server-client\"\u003e\u003c/a\u003eStart the Server \u0026 Client agents on the nodes\nOne agent acts as the 'Server' so you start up the agent as the Server.\n\n```bash\nconsul agent -server -bootstrap-expect=1 \\\n-data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 \\\n-enable-script-checks=true -config-dir=/etc/consul.d\n```\n\nAnother 'member' comes along to this cluster as the 'Client'\n```bash\nconsul agent -data-dir=/tmp/consul -node=agent-two -bind=172.20.20.11 -enable-script-checks=true -config-dir=/etc/consul.d\n```\n\n#### \u003ca name=\"joining-cluster\"\u003e\u003c/a\u003eJoining a cluster\n\nTo join a cluster, run as the agent of any node and connect to one of the nodes already on the cluster by specifying that nodes' IP address.\n\ne.g.\n```bash\nconsul join 172.20.20.11\n```\n\n#### \u003ca name=\"querying-nodes\"\u003e\u003c/a\u003eQuery the nodes\nAgent from one node querying another Agent from a second node.\n\ne.g.\n```bash\ndig @127.0.0.1 -p 8600 agent-two.node.consul\n```\n\n#### \u003ca name=\"leave-cluster\"\u003e\u003c/a\u003eLeave a cluster\n```bash\nconsul leave\n```\n\n### \u003ca name=\"kv-store\"\u003e\u003c/a\u003eK/V Store\n\nThe Key/Value store.\n\n__Put__\n```bash\nconsul kv put redis/config/minconns 1\nconsul kv put redis/config/maxconns 25\nconsul kv put -flags=42 redis/config/users/admin abcd1234\n```\n\n__Get one__\n```bash\nconsul kv get redis/config/minconns\nconsul kv get -detailed redis/config/minconns\n```\n\n__Get All__\n```bash\nconsul kv get -recurse\n```\n\n__Delete__\n```bash\nconsul kv delete redis/config/minconns\nconsul kv delete -recurse redis\n```\n\n__Update__\n```bash\nconsul kv put foo bar\nconsul kv put foo zip\n```\n\n__Atomic Update__\n```bash\nconsul kv put -cas -modify-index=123 foo bar\n```\n\n### \u003ca name=\"ui-web-console\"\u003e\u003c/a\u003eUi Web Console\n\nvia the `-ui` flag on the CLI\n\n```bash\nconsul agent -ui -config-dir=/etc/consul.d\n```\n\nand then you can visit the `/ui` path on the HTTP port of `8500`\n\ne.g.\n```\nhttp://localhost:8500/ui/\n```\n\nThe official Demo Consul UI is located here: `https://demo.consul.io/ui`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolinbut%2Fconsul-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolinbut%2Fconsul-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolinbut%2Fconsul-example/lists"}