{"id":20766216,"url":"https://github.com/navono/consul-example","last_synced_at":"2025-10-14T05:21:46.085Z","repository":{"id":74496123,"uuid":"193209501","full_name":"navono/consul-example","owner":"navono","description":"consul demonstration","archived":false,"fork":false,"pushed_at":"2019-06-25T11:27:28.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-22T23:22:07.110Z","etag":null,"topics":["consul","docker-compose"],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","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/navono.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":"2019-06-22T08:18:18.000Z","updated_at":"2019-06-25T11:27:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"71b8e6bb-56db-4abb-976f-8047173d00c7","html_url":"https://github.com/navono/consul-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/navono/consul-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navono%2Fconsul-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navono%2Fconsul-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navono%2Fconsul-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navono%2Fconsul-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/navono","download_url":"https://codeload.github.com/navono/consul-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navono%2Fconsul-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018015,"owners_count":26086237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","docker-compose"],"created_at":"2024-11-17T11:22:03.191Z","updated_at":"2025-10-14T05:21:46.063Z","avatar_url":"https://github.com/navono.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# consul-config\n\n## windows\nin `Cmder`:\n\u003e export COMPOSE_CONVERT_WINDOWS_PATHS=1\n\nstart services:\n\u003e docker-compose up -d\n\ncheck status in web:\n\u003e http://localhost:8500\n\nor cli:\n\u003e docker exec -t consul1 consul members\n\n## API 介绍\n```\nkv - Key/Value存储\nagent - Agent控制\ncatalog - 管理nodes和services\nhealth - 管理健康监测\nsession - Session操作\nacl - ACL创建和管理event - 用户Events\nstatus - Consul系统状态\n```\n\n1. agent endpoints：agent endpoints用来和本地agent进行交互，一般用来服务注册和检查注册，支持以下接口\n```\n/v1/agent/checks : 返回本地agent注册的所有检查(包括配置文件和HTTP接口)\n/v1/agent/services : 返回本地agent注册的所有 服务\n/v1/agent/members : 返回agent在集群的gossip pool中看到的成员\n/v1/agent/self : 返回本地agent的配置和成员信息/v1/agent/join/\u003caddress\u003e : 触发本地agent加入node/v1/agent/force-leave/\u003cnode\u003e\u003e: 强制删除node\n/v1/agent/check/register : 在本地agent增加一个检查项，使用PUT方法传输一个json格式的数据/v1/agent/check/deregister/\u003ccheckID\u003e : 注销一个本地agent的检查项/v1/agent/check/pass/\u003ccheckID\u003e : 设置一个本地检查项的状态为passing/v1/agent/check/warn/\u003ccheckID\u003e : 设置一个本地检查项的状态为warning/v1/agent/check/fail/\u003ccheckID\u003e : 设置一个本地检查项的状态为critical\n/v1/agent/service/register : 在本地agent增加一个新的服务项，使用PUT方法传输一个json格式的数据/v1/agent/service/deregister/\u003cserviceID\u003e : 注销一个本地agent的服务项\n```\n\n2. catalog endpoints：catalog endpoints用来注册/注销nodes、services、checks\n```\n/v1/catalog/register : Registers a new node, service, or check/v1/catalog/deregister : Deregisters a node, service, or check/v1/catalog/datacenters : Lists known datacenters\n/v1/catalog/nodes : Lists nodes in a given DC\n/v1/catalog/services : Lists services in a given DC\n/v1/catalog/service/\u003cservice\u003e : Lists the nodes in a given service\n/v1/catalog/node/\u003cnode\u003e : Lists the services provided by a node\n```\n\n3. health endpoints：health endpoints用来查询健康状况相关信息，该功能从catalog中单独分离出来\n```\n/v1/healt/node/\u003cnode\u003e: 返回node所定义的检查，可用参数?dc=\n/v1/health/checks/\u003cservice\u003e: 返回和服务相关联的检查，可用参数?dc=\n/v1/health/service/\u003cservice\u003e: 返回给定datacenter中给定node中service\n/v1/health/state/\u003cstate\u003e: 返回给定datacenter中指定状态的服务，state可以是\"any\", \"unknown\", \"passing\", \"warning\", or \"critical\"，可用参数?dc=\n```\n\n4. session endpoints：session endpoints用来create、update、destory、query sessions\n```\n/v1/session/create: Creates a new session\n/v1/session/destroy/\u003csession\u003e: Destroys a given session\n/v1/session/info/\u003csession\u003e: Queries a given session\n/v1/session/node/\u003cnode\u003e: Lists sessions belonging to a node\n/v1/session/list: Lists all the active sessions\n```\n\n5. acl endpoints：acl endpoints用来create、update、destory、query acl\n```\n/v1/acl/create: Creates a new token with policy\n/v1/acl/update: Update the policy of a token\n/v1/acl/destroy/\u003cid\u003e: Destroys a given token\n/v1/acl/info/\u003cid\u003e: Queries the policy of a given token\n/v1/acl/clone/\u003cid\u003e: Creates a new token by cloning an existing token\n/v1/acl/list: Lists all the active tokens\n```\n\n6. status endpoints：status endpoints用来或者consul 集群的信息\n```\n/v1/status/leader : 返回当前集群的Raft leader\n/v1/status/peers : 返回当前集群中同事\n```\n\n## registration service\nadd node and service:\n\u003e curl -X PUT -d '{\"Datacenter\": \"dc1\", \"Node\": \"amazon\", \"Address\": \"www.amazon.com\", \"Service\": {\"Service\": \"shop\", \"Port\": 80}}' http://127.0.0.1:8500/v1/catalog/register\n\ndelete node:\n\u003e curl -X PUT -d '{\"Datacenter\": \"dc1\", \"Node\": \"amazon\"}' http://127.0.0.1:8500/v1/catalog/deregister\n\n## KV\nadd:\n\u003e curl -X PUT -d 'hello consul' http://127.0.0.1:8500/v1/kv/foo\n\ndelete:\n\u003e curl -X DELETE http://127.0.0.1:8500/v1/kv/foo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnavono%2Fconsul-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnavono%2Fconsul-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnavono%2Fconsul-example/lists"}