Coder Social home page Coder Social logo

devteds / swarm-consul Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 6.0 3 KB

Test consul cluster on docker swarm cluster (by devteds.com)

Shell 100.00%
docker consul consul-kv digitalocean docker-swarm docker-swarm-mode docker-swarm-cluster consul-cluster docker-machine

swarm-consul's Introduction

Find more examples and short videos on development & deployments with docker, aws etc on devteds.com

Consul Cluster on Docker Swarm Cluster

Run consul cluster as containers on swarm cluster. This is an example code created while testing consul on docker swarm and it is very basic.

Tested on docker version Docker version 17.12.0-ce, build c97c6d6

Swarm Cluster

Spin up 3 nodes (droplets) on DigitalOcean and create a swarm cluster of those 3 nodes

Optionally, edit swarm.sh to change DigitalOcean droplet configs.

export DO_TOKEN=<DigitalOcean API Access Token>
./swarm.sh

Consul Cluster

Create a consul cluster of 5 nodes/agents (containers),

  • Two consul client nodes
  • Two consul server nodes
  • One consul server node as bootstrap
eval $(docker-machine env node-1)
docker stack deploy -c consul.yml kv

Verify the stack & 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.

docker stack ps -f "desired-state=running" kv
docker service logs kv_server-bootstrap
docker service logs kv_server
docker service logs kv_client

docker service inspect kv_server-bootstrap

Consul UI

open http://$(docker-machine ip node-1):8500/ui

Test Consul CLI

Login to server-bootstrap's container shell

# On Swarm Manager Node
eval $(docker-machine env node-1)

# Switch to Consul Server (bootstrap)
consul_node=$(docker stack ps kv | grep server-bootstrap | awk '{print $4}' | head -1)
eval $(docker-machine env "$consul_node")

# Exec into Consul Bootstrap Container
consul_container_id=$(docker ps | grep server-bootstrap | awk '{print $1}' | head -1)
docker exec -ti $consul_container_id /bin/sh

Test a few consul commands on server-bootstrap's container shell,

consul agent --help
consul info
consul catalog nodes
consul catalog datacenters
consul members

Find more commands at https://www.consul.io/docs/commands/index.html

Clean up

docker-machine rm -f node-1 node-2 node-3

More

Visit https://devteds.com for short videos on development / deployment with docker and cloud

swarm-consul's People

Contributors

shettigarc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.