{"id":20181924,"url":"https://github.com/devteds/swarm-consul","last_synced_at":"2025-04-10T05:10:43.209Z","repository":{"id":132073131,"uuid":"124712897","full_name":"devteds/swarm-consul","owner":"devteds","description":"Test consul cluster on docker swarm cluster (by devteds.com)","archived":false,"fork":false,"pushed_at":"2018-03-11T01:47:07.000Z","size":3,"stargazers_count":14,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T06:22:24.481Z","etag":null,"topics":["consul","consul-cluster","consul-kv","digitalocean","docker","docker-machine","docker-swarm","docker-swarm-cluster","docker-swarm-mode"],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/devteds.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-03-11T01:25:14.000Z","updated_at":"2024-01-26T23:08:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"e1bfde07-d597-49bd-8887-480a5d104d1a","html_url":"https://github.com/devteds/swarm-consul","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devteds%2Fswarm-consul","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devteds%2Fswarm-consul/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devteds%2Fswarm-consul/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devteds%2Fswarm-consul/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devteds","download_url":"https://codeload.github.com/devteds/swarm-consul/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161273,"owners_count":21057555,"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","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-cluster","consul-kv","digitalocean","docker","docker-machine","docker-swarm","docker-swarm-cluster","docker-swarm-mode"],"created_at":"2024-11-14T02:37:09.128Z","updated_at":"2025-04-10T05:10:43.201Z","avatar_url":"https://github.com/devteds.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e Find more examples and short videos on development \u0026 deployments with docker, aws etc on [devteds.com](https://devteds.com)\n\n# Consul Cluster on Docker Swarm Cluster\n\nRun consul cluster as containers on swarm cluster. This is an example code created while testing consul on docker swarm and it is very basic.\n\n*Tested on docker version Docker version 17.12.0-ce, build c97c6d6*\n\n## Swarm Cluster\nSpin up 3 nodes (droplets) on DigitalOcean and create a swarm cluster of those 3 nodes\n\nOptionally, edit `swarm.sh` to change DigitalOcean droplet configs.\n\n```\nexport DO_TOKEN=\u003cDigitalOcean API Access Token\u003e\n./swarm.sh\n```\n\n## Consul Cluster \n\nCreate a consul cluster of 5 nodes/agents (containers),\n\n- Two consul client nodes\n- Two consul server nodes\n- One consul server node as bootstrap\n\n```\neval $(docker-machine env node-1)\ndocker stack deploy -c consul.yml kv\n```\n\nVerify the stack \u0026 agents/containers. There may be some errors before all the nodes in the consul cluster start up and complete leader election. Give it about 30 seconds to gossip and complete leader election.\n\n```\ndocker stack ps -f \"desired-state=running\" kv\ndocker service logs kv_server-bootstrap\ndocker service logs kv_server\ndocker service logs kv_client\n\ndocker service inspect kv_server-bootstrap\n```\n\n## Consul UI\n\n```\nopen http://$(docker-machine ip node-1):8500/ui\n```\n\n## Test Consul CLI\n\nLogin to server-bootstrap's container shell\n\n```\n# On Swarm Manager Node\neval $(docker-machine env node-1)\n\n# Switch to Consul Server (bootstrap)\nconsul_node=$(docker stack ps kv | grep server-bootstrap | awk '{print $4}' | head -1)\neval $(docker-machine env \"$consul_node\")\n\n# Exec into Consul Bootstrap Container\nconsul_container_id=$(docker ps | grep server-bootstrap | awk '{print $1}' | head -1)\ndocker exec -ti $consul_container_id /bin/sh\n```\n\nTest a few consul commands on server-bootstrap's container shell,\n\n```\nconsul agent --help\nconsul info\nconsul catalog nodes\nconsul catalog datacenters\nconsul members\n```\n\nFind more commands at https://www.consul.io/docs/commands/index.html\n\n\n## Clean up\n\n```\ndocker-machine rm -f node-1 node-2 node-3\n```\n\n# More\n\nVisit https://devteds.com for short videos on development / deployment with docker and cloud\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevteds%2Fswarm-consul","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevteds%2Fswarm-consul","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevteds%2Fswarm-consul/lists"}