{"id":20403,"date":"2016-04-16T15:18:39","date_gmt":"2016-04-16T08:18:39","guid":{"rendered":"https:\/\/kitty.in.th\/?p=20403"},"modified":"2016-04-17T12:29:34","modified_gmt":"2016-04-17T05:29:34","slug":"using-docker-machine-to-deploy-multi-manager-docker-swarm","status":"publish","type":"post","link":"https:\/\/kitty.in.th\/index.php\/2016\/04\/16\/using-docker-machine-to-deploy-multi-manager-docker-swarm\/","title":{"rendered":"Using docker-machine to deploy multi-manager docker swarm"},"content":{"rendered":"<p>Of course, HA is a must in production environment. So, you\u00a0gonna need multi-manager docker swarm.\u00a0It is\u00a0super easy when you know how.<\/p>\n<p>First, you cannot use token, you need a discovery service (consul, etcd, zookeeper). So, create\u00a0one if you don&#8217;t have, e.g.<\/p>\n<pre>$ docker-machine create -d virtualbox consul\r\n$ docker-machine ssh consul\r\ndocker@consul:~$ docker run -d --name consul \\\r\n  --net host gliderlabs\/consul-server \\\r\n  -advertise 192.168.0.100 \\\r\n  -bootstrap-expect 1<\/pre>\n<p>Next, \u00a0create multiple swarm managers (we have obsoleted the term\u00a0swarm master, though.)<\/p>\n<pre>$\u00a0docker-machine create -d virtualbox --swarm \\\r\n  --swarm-master \\\r\n  --swarm-opt replication \\\r\n  --swarm-discovery consul:\/\/192.168.0.100:8500 \\\r\n  --engine-opt cluster-store=consul:\/\/192.168.0.100:8500\u00a0\\\r\n  manager-0 \r\n$\u00a0docker-machine create -d virtualbox --swarm \\\r\n  --swarm-master \\\r\n  --swarm-opt replication \\\r\n  --swarm-discovery consul:\/\/192.168.0.100:8500 \\\r\n  --engine-opt cluster-store=consul:\/\/192.168.0.100:8500\u00a0\\\r\n  manager-1<\/pre>\n<p>Note that you need <em>&#8211;swarm-master<\/em> and <em>&#8211;swarm-opt replication<\/em> to make this\u00a0works. Now, you have it. You can either<\/p>\n<pre>$ eval $(docker-machine env --swarm manager-0)<\/pre>\n<p>or<\/p>\n<pre>$ eval $(docker-machine env --swarm manager-1)<\/pre>\n<p>Check the &#8220;role&#8221; line, one will be the <em>primary<\/em>, the others will be <em>replicas<\/em>.<\/p>\n<p>Normally, you would want to set docker environment to the primary. Somehow, if the primary has failed, one of the replicas will takeover and you can set the environment to the\u00a0replica to control your swarm cluster.\u00a0You can later recover the failed manager, or create a new manager.<\/p>\n<p>Easy, right ? ;)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Of course, HA is a must in production environment. So, you\u00a0gonna need multi-manager docker swarm.\u00a0It is\u00a0super easy when you know how. First, you cannot use token, you need a discovery service (consul, etcd, zookeeper). So, create\u00a0one if you don&#8217;t have, e.g. $ docker-machine create -d virtualbox consul $ docker-machine ssh consul docker@consul:~$ docker run -d &hellip; <a href=\"https:\/\/kitty.in.th\/index.php\/2016\/04\/16\/using-docker-machine-to-deploy-multi-manager-docker-swarm\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Using docker-machine to deploy multi-manager docker swarm<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85],"tags":[325,326],"class_list":["post-20403","post","type-post","status-publish","format-standard","hentry","category-blog","tag-docker","tag-swarm"],"_links":{"self":[{"href":"https:\/\/kitty.in.th\/index.php\/wp-json\/wp\/v2\/posts\/20403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kitty.in.th\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kitty.in.th\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kitty.in.th\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kitty.in.th\/index.php\/wp-json\/wp\/v2\/comments?post=20403"}],"version-history":[{"count":9,"href":"https:\/\/kitty.in.th\/index.php\/wp-json\/wp\/v2\/posts\/20403\/revisions"}],"predecessor-version":[{"id":20427,"href":"https:\/\/kitty.in.th\/index.php\/wp-json\/wp\/v2\/posts\/20403\/revisions\/20427"}],"wp:attachment":[{"href":"https:\/\/kitty.in.th\/index.php\/wp-json\/wp\/v2\/media?parent=20403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kitty.in.th\/index.php\/wp-json\/wp\/v2\/categories?post=20403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kitty.in.th\/index.php\/wp-json\/wp\/v2\/tags?post=20403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}