index.html 30.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2016-06-09 jeu. 14:07 -->
<meta  http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta  name="viewport" content="width=device-width, initial-scale=1" />
<title>Blackfish: a CoreOS VM to build swarm clusters for Dev &amp; Production</title>
<meta  name="generator" content="Org-mode" />
<style type="text/css">
 <!--/*--><![CDATA[/*><!--*/
  .title  { text-align: center;
             margin-bottom: .2em; }
  .subtitle { text-align: center;
              font-size: medium;
              font-weight: bold;
              margin-top:0; }
  .todo   { font-family: monospace; color: red; }
  .done   { font-family: monospace; color: green; }
  .priority { font-family: monospace; color: orange; }
  .tag    { background-color: #eee; font-family: monospace;
            padding: 2px; font-size: 80%; font-weight: normal; }
  .timestamp { color: #bebebe; }
  .timestamp-kwd { color: #5f9ea0; }
  .org-right  { margin-left: auto; margin-right: 0px;  text-align: right; }
  .org-left   { margin-left: 0px;  margin-right: auto; text-align: left; }
  .org-center { margin-left: auto; margin-right: auto; text-align: center; }
  .underline { text-decoration: underline; }
  #postamble p, #preamble p { font-size: 90%; margin: .2em; }
  p.verse { margin-left: 3%; }
  pre {
    border: 1px solid #ccc;
    box-shadow: 3px 3px 3px #eee;
    padding: 8pt;
    font-family: monospace;
    overflow: auto;
    margin: 1.2em;
  }
  pre.src {
    position: relative;
    overflow: visible;
    padding-top: 1.2em;
  }
  pre.src:before {
    display: none;
    position: absolute;
    background-color: white;
    top: -10px;
    right: 10px;
    padding: 3px;
    border: 1px solid black;
  }
  pre.src:hover:before { display: inline;}
  pre.src-sh:before    { content: 'sh'; }
  pre.src-bash:before  { content: 'sh'; }
  pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
  pre.src-R:before     { content: 'R'; }
  pre.src-perl:before  { content: 'Perl'; }
  pre.src-java:before  { content: 'Java'; }
  pre.src-sql:before   { content: 'SQL'; }

  table { border-collapse:collapse; }
  caption.t-above { caption-side: top; }
  caption.t-bottom { caption-side: bottom; }
  td, th { vertical-align:top;  }
  th.org-right  { text-align: center;  }
  th.org-left   { text-align: center;   }
  th.org-center { text-align: center; }
  td.org-right  { text-align: right;  }
  td.org-left   { text-align: left;   }
  td.org-center { text-align: center; }
  dt { font-weight: bold; }
  .footpara { display: inline; }
  .footdef  { margin-bottom: 1em; }
  .figure { padding: 1em; }
  .figure p { text-align: center; }
  .inlinetask {
    padding: 10px;
    border: 2px solid gray;
    margin: 10px;
    background: #ffffcc;
  }
  #org-div-home-and-up
   { text-align: right; font-size: 70%; white-space: nowrap; }
  textarea { overflow-x: auto; }
  .linenr { font-size: smaller }
  .code-highlighted { background-color: #ffff00; }
  .org-info-js_info-navigation { border-style: none; }
  #org-info-js_console-label
    { font-size: 10px; font-weight: bold; white-space: nowrap; }
  .org-info-js_search-highlight
    { background-color: #ffff00; color: #000000; font-weight: bold; }
  /*]]>*/-->
</style>
<link rel="stylesheet" type="text/css" href="./docs/css/htmlize.css"/>
<link rel="stylesheet" type="text/css" href="./docs/css/readtheorg.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script type="text/javascript" src="./docs/js/readtheorg.js"></script>
<script type="text/javascript">
/*
@licstart  The following is the entire license notice for the
JavaScript code in this tag.

Copyright (C) 2012-2013 Free Software Foundation, Inc.

The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version.  The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.

As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.


@licend  The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
 function CodeHighlightOn(elem, id)
 {
   var target = document.getElementById(id);
   if(null != target) {
     elem.cacheClassElem = elem.className;
     elem.cacheClassTarget = target.className;
     target.className = "code-highlighted";
     elem.className   = "code-highlighted";
   }
 }
 function CodeHighlightOff(elem, id)
 {
   var target = document.getElementById(id);
   if(elem.cacheClassElem)
     elem.className = elem.cacheClassElem;
   if(elem.cacheClassTarget)
     target.className = elem.cacheClassTarget;
 }
/*]]>*///-->
</script>
</head>
<body>
<div id="content">
<h1 class="title">Blackfish: a CoreOS VM to build swarm clusters for Dev &amp; Production</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#orgheadline1">1. Description</a></li>
<li><a href="#orgheadline2">2. Pre-Requisites</a></li>
<li><a href="#orgheadline3">3. Quickstart</a></li>
<li><a href="#orgheadline4">4. Getting Started on AWS</a></li>
<li><a href="#orgheadline8">5. Play with your swarm cluster</a></li>
<li><a href="#orgheadline12">6. Blackfish Components</a></li>
<li><a href="#orgheadline23">7. Considerations &amp; Roadmap</a></li>
<li><a href="#orgheadline24">8. Configure DNS resolution</a></li>
<li><a href="#orgheadline27">9. Registering TLS Certificates</a></li>
</ul>
</div>
</div>
<p>
Note: you may prefer reading the <a href="https://blackfish.gitlab.io/blackfish/index.html">README.html</a> file in your browser.
</p>

<div id="outline-container-orgheadline1" class="outline-2">
<h2 id="orgheadline1"><span class="section-number-2">1</span> Description</h2>
<div class="outline-text-2" id="text-1">
<p>
Blackfish is a pre-built CoreOS VM that ease the bootstrap of swarm clusters. 
It contains all basics services required to ease the deployment of your apps and manage basic production operations.
All the servics are pre configured for production with HA and TLS communication enabled.
</p>

<ul class="org-ul">
<li>a consul cluster with a registrator</li>
<li>an internal HA docker registry</li>
<li>an haproxy load balancer with auto discovery</li>
<li>centralized logs with an HA graylog2 setup</li>
<li>centralized monitoring with telegraf+influx+grafana</li>
</ul>

<p>
The project also comes with all the materials to boot a cluster on your local machine with a Vagrant setup, or on AWS EC2 with terraform scripts.
</p>

<p>
We hope it will help you fill the gap between "Docker in Dev" versus "Docker in Production"
</p>


<div id="orgparagraph1" class="figure">
<p><img src="https://gitlab.com/blackfish/blackfish/raw/master/docs/images/docker-prod.jpg" alt="docker-prod.jpg" />
</p>
<p><span class="figure-number">Figure 1:</span> Docker in Dev VS Prod</p>
</div>


<p>
You'll find other and maybe simpler tutorials or github projects to deploy swarm on AWS, but if you don't want your cluster to be exposed on public facing IPs, you'll then have to get your hands dirty on a lot of other things.
</p>

<p>
Blackfish is built on top of the following components:
</p>
<ul class="org-ul">
<li><a href="http://packer.io/">Packer</a> for building the boxes for various providers (Virtualbox, AWS, Kvm, &#x2026;)</li>
<li><a href="https://www.terraform.io/">Terraform</a> for provisioning the infrastructure on AWS</li>
<li><a href="http://vagrantup.com/">Vagrant</a> for running the swarm cluster in virtualbox</li>
</ul>
</div>
</div>


<div id="outline-container-orgheadline2" class="outline-2">
<h2 id="orgheadline2"><span class="section-number-2">2</span> Pre-Requisites</h2>
<div class="outline-text-2" id="text-2">
<p>
To use this project you will need at least this list of tools properly installed on your box:
</p>

<ul class="org-ul">
<li>docker 1.10</li>
<li>vagrant 1.8</li>
<li>virtualbox 5.0</li>
</ul>
</div>
</div>

<div id="outline-container-orgheadline3" class="outline-2">
<h2 id="orgheadline3"><span class="section-number-2">3</span> Quickstart</h2>
<div class="outline-text-2" id="text-3">
<p>
To quickly bootstrap a swarm cluster with vagrant on your local machine, configure the <a href="nodes.yml">nodes.yml</a> file and type the following commands. 
</p>

<div class="org-src-container">

<pre class="src src-bash">$ git clone https://github.com/yanndegat/blackfish
$ cd blackfish
$ vi nodes.yml
...
</pre>
</div>

<div class="org-src-container">
<label class="org-src-name">nodes.yml</label>
<pre class="src src-yaml" id="orgsrcblock1"><span style="color: #2aa1ae; background-color: #292e34;">---</span>
<span style="color: #7590db;">provider</span>            : <span style="color: #2d9574;">"virtualbox"</span>
<span style="color: #7590db;">admin-network</span>       : 192.168.101.0/24
<span style="color: #7590db;">box</span>                 : yanndegat/blackfish-coreos
<span style="color: #7590db;">id</span>                  : myid
<span style="color: #7590db;">stack</span>               : vagrant
<span style="color: #7590db;">dc</span>                  : dc1
<span style="color: #7590db;">consul-joinip</span>       : 192.168.101.101
<span style="color: #7590db;">consul-key</span>          : hMJ0CFCrpFRQfVeSQBUUdQ==
<span style="color: #7590db;">registry-secret</span>     : A2jMOuYSS+3swzjAR6g1x3iu2vY/cROWYZrJLqYffxA=
<span style="color: #7590db;">ssh-key</span> : ./vagrant.pub
<span style="color: #7590db;">private-ssh-key</span> : ~/.vagrant.d/insecure_private_key
<span style="color: #7590db;">nodes</span>:
  - <span style="color: #7590db;">ip</span>      : 192.168.101.101
    <span style="color: #7590db;">docker-registry</span> : <span style="color: #a45bad;">true</span>
    <span style="color: #7590db;">memory</span>  : <span style="color: #2d9574;">"3072"</span>
    <span style="color: #7590db;">cpus</span>    : <span style="color: #2d9574;">"2"</span>
  - <span style="color: #7590db;">memory</span>  : <span style="color: #2d9574;">"3072"</span>
    <span style="color: #7590db;">cpus</span>    : <span style="color: #2d9574;">"2"</span>
    <span style="color: #7590db;">ip</span>      : 192.168.101.102
  - <span style="color: #7590db;">memory</span>  : <span style="color: #2d9574;">"3072"</span>
    <span style="color: #7590db;">cpus</span>    : <span style="color: #2d9574;">"2"</span>
    <span style="color: #7590db;">ip</span>      : 192.168.101.103
</pre>
</div>

<div class="org-src-container">

<pre class="src src-bash">$ vagrant up
==&gt; box: Loading metadata for box <span style="color: #2d9574;">'yanndegat/blackfish'</span>
    box: URL: https://atlas.hashicorp.com/yanndegat/blackfish
==&gt; box: Adding box <span style="color: #2d9574;">'yanndegat/blackfish'</span> <span style="color: #4f97d7;">(</span>v0.0.5<span style="color: #4f97d7;">)</span> <span style="color: #4f97d7; font-weight: bold;">for</span> provider: virtualbox
    box: Downloading: https://atlas.hashicorp.com/yanndegat/boxes/blackfish/versions/0.0.5/providers/virtualbox.box
    box: Progress: <span style="color: #a45bad;">26%</span> <span style="color: #4f97d7;">(</span>Rate: <span style="color: #a45bad;">1981k/s,</span> Estimated time remaining: <span style="color: #a45bad;">0:02:24</span><span style="color: #4f97d7;">)</span>
...
$
</pre>
</div>

<p>
TLS certificates have been generated in your <code>$HOME/.blackfish/vagrant</code> directory. You have to declare the CA Cert on your host, according to your system. 
</p>

<p>
Once you have registered your <a href="#orgtarget1">tls certificates</a> setup your <a href="#orgtarget2">dns configuration</a>, you can go to <a href="https://consul-agent.service.vagrant:4443/ui">https://consul-agent.service.vagrant:4443/ui</a>
</p>

<p>
Now refer to the <a href="#orgtarget3">Play with swarm</a> section to go futher.
</p>
</div>
</div>

<div id="outline-container-orgheadline4" class="outline-2">
<h2 id="orgheadline4"><span class="section-number-2">4</span> Getting Started on AWS</h2>
<div class="outline-text-2" id="text-4">
<div class="NOTES">
<p>
This section is obsolete. To use blackfish on aws, several terraform scripts are available but they're toooooo complex.
Instead we want to be able to use the same "nodes*yml" configuration files to bootstrap swarm on aws. To do so, we will in a near future
provide some kind of go binary that reads "nodes.yml" &amp; terraform templates and outputs a complete terraform directory.
</p>

<p>
Meanwhile, you can use the <a href="terraform/aws/vpc/">terraform/aws/vpc/</a> templates or refer to the old scripts to bootstrap the vpc, and use vagrant &#x2013;provider=aws to bootstrap the aws nodes. 
</p>

</div>

<p>
Refer to the <a href="terraform/aws/README.html">Aws README</a> file.
</p>


<p>
Here's an exemple of what a nodes.yml for aws could look like
</p>

<div class="org-src-container">

<pre class="src src-yaml"><span style="color: #2aa1ae; background-color: #292e34;">---</span>
<span style="color: #7590db;">provider</span>            : aws
<span style="color: #7590db;">admin-network</span>       : 10.233.1.0/24
<span style="color: #7590db;">stack</span>               : demo
<span style="color: #7590db;">dc</span>                  : one
<span style="color: #7590db;">id</span>                  : prod1
<span style="color: #7590db;">consul-joinip</span>       : 10.233.1.201
<span style="color: #7590db;">consul-key</span>          : dlnA+EWVSiQyfd0vkApmTUu4lDvMlmJcjMy+8dMEVkw=
<span style="color: #7590db;">registry-secret</span>     : rJ/9vXube9iujCjFiniJODQX60Q/XJytUJyOKQfPaLo=

<span style="color: #7590db;">journald-sink</span>       : journald.service.demo:42201
<span style="color: #7590db;">influxdb-url</span>        : http://influxdb.service.demo:48086

<span style="color: #7590db;">labels</span>              :
  - type=control

<span style="color: #7590db;">nodes</span>:
  - <span style="color: #7590db;">ip</span>              : 10.233.1.201
    <span style="color: #7590db;">docker-registry</span> : <span style="color: #a45bad;">true</span>
  - <span style="color: #7590db;">ip</span>              : 10.233.1.202
  - <span style="color: #7590db;">ip</span>              : 10.233.1.203

<span style="color: #7590db;">aws</span>:
  <span style="color: #7590db;">region</span>            : eu-west-1
  <span style="color: #7590db;">access-key-id</span>     : XXXXXXXXXXXXXXX
  <span style="color: #7590db;">secret-access-key</span> : YYYYYYYYYYYYYYYYYYYYYYYYYYYYY
  <span style="color: #7590db;">availability-zone</span> : eu-west-1a
  <span style="color: #7590db;">instance-type</span>     : m3.xlarge
  <span style="color: #7590db;">ebs-optimized</span>     : <span style="color: #a45bad;">false</span>
  <span style="color: #7590db;">keypair-name</span>      : my-keypair
  <span style="color: #7590db;">private-ssh-key</span>   : ~/.ssh/my-keypair.key
  <span style="color: #7590db;">subnet-id</span>         : subnet-d779afb3
  <span style="color: #7590db;">s3bucket</span>          : bucket-742587092752
  <span style="color: #7590db;">security-groups</span>   :
    - sg-2676b741
</pre>
</div>
</div>
</div>


<div id="outline-container-orgheadline8" class="outline-2">
<h2 id="orgheadline8"><span class="section-number-2">5</span> <a id="orgtarget3"></a>Play with your swarm cluster</h2>
<div class="outline-text-2" id="text-5">
<p>
Now we can play with swarm.
</p>
</div>

<div id="outline-container-orgheadline5" class="outline-3">
<h3 id="orgheadline5"><span class="section-number-3">5.1</span> Using the swarm cluster</h3>
<div class="outline-text-3" id="text-5-1">
<p>
You can now use your swarm cluster to run docker containers as simply as you would do to run a container on your local docker engine. All you have to do is 
target the IP of one of your swarm node. 
</p>

<div class="org-src-container">

<pre class="src src-bash">$ export <span style="color: #7590db;">PATH</span>=$<span style="color: #7590db;">PATH</span>:$<span style="color: #4f97d7;">(</span><span style="color: #4f97d7;">pwd</span><span style="color: #4f97d7;">)</span>/bin
$ blackfish vagrant run --rm -it alpine /bin/sh
/ <span style="color: #2aa1ae; background-color: #292e34;"># </span><span style="color: #2aa1ae; background-color: #292e34;">...</span>
</pre>
</div>
</div>
</div>


<div id="outline-container-orgheadline6" class="outline-3">
<h3 id="orgheadline6"><span class="section-number-3">5.2</span> Using the Blackfish internal registry</h3>
<div class="outline-text-3" id="text-5-2">
<p>
The Blackfish internal registry which is automatically started on the swarm cluster is registered on the "registry.service.dev.vagrant:5000" name. So you have to tag &amp; push docker images with this name if you want the nodes to be able to download your images.
</p>

<p>
As the registry has an auto signed TLS certificate, you have to declare its CA Cert on your docker engine and on your system (again according to your OS)
</p>

<div class="org-src-container">

<pre class="src src-bash">$ export <span style="color: #7590db;">PATH</span>=$<span style="color: #7590db;">PATH</span>:$<span style="color: #4f97d7;">(</span><span style="color: #4f97d7;">pwd</span><span style="color: #4f97d7;">)</span>/bin
$ sudo mkdir -p /etc/docker/certs.d/registry.service.vagrant
$ sudo cp ~/.blackfish/vagrant/ca.pem /etc/docker/certs.d/registry.service.vagrant/
$ sudo systemctl restart docker
...
$ docker tag alpine registry.service.vagrant/alpine
$ docker push registry.service.vagrant/alpine
...
$ blackfish vagrant pull registry.service.vagrant/alpine
...
$ blackfish vagrant run --rm -it registry.service.vagrant/alpine /bin/sh
/ <span style="color: #2aa1ae; background-color: #292e34;"># </span><span style="color: #2aa1ae; background-color: #292e34;">...</span>
</pre>
</div>
</div>
</div>


<div id="outline-container-orgheadline7" class="outline-3">
<h3 id="orgheadline7"><span class="section-number-3">5.3</span> Run the examples</h3>
<div class="outline-text-3" id="text-5-3">
<p>
Examples are available in the <a href="examples">examples</a> directory. You can play with them to discover how to work with docker swarm.
</p>
</div>
</div>
</div>


<div id="outline-container-orgheadline12" class="outline-2">
<h2 id="orgheadline12"><span class="section-number-2">6</span> Blackfish Components</h2>
<div class="outline-text-2" id="text-6">
</div><div id="outline-container-orgheadline9" class="outline-3">
<h3 id="orgheadline9"><span class="section-number-3">6.1</span> Architecture guidelines</h3>
<div class="outline-text-3" id="text-6-1">
<p>
The Blackfish VM tries to follow the Immutable Infrastructure precepts:
</p>

<ul class="org-ul">
<li>Every component of the system must be able to boot/reboot without having to be provisionned with configuration elements other than via cloud init.</li>
<li>Every component of the system must be able to discover its pairs and join them</li>
<li>If a component can't boot properly, it must be considered as dead. Don't try to fix it.</li>
<li>To update the system, we must rebuild new components and replace existing ones with the new ones.</li>
</ul>
</div>
</div>


<div id="outline-container-orgheadline10" class="outline-3">
<h3 id="orgheadline10"><span class="section-number-3">6.2</span> Blackfish is architectured with the following components :</h3>
<div class="outline-text-3" id="text-6-2">
<ul class="org-ul">
<li>a consul cluster setup with full encryption setup, which consists of a set of consul agents running in "server" mode, and additionnal nodes running in "agent" mode.
The consul cluster could be used :
<ul class="org-ul">
<li>as a distributed key/value store</li>
<li>as a service discovery</li>
<li>as a dns server</li>
<li>as a backend for swarm master election</li>
</ul></li>

<li>a swarm cluster setup with full encryption setup, which consists of a set of swarm agents running in "server" mode, and additionnal nodes running in agent mode.
Every swarm node will also run a consul agent and a registrator service to declare every running container in consul.</li>

<li>a HA private docker registry with TLS encryption. It's registered under the dns address registry.service.vagrant. 
HA is made possible by the use of a shared filesystem storage.
On AWS, it is possible to configure the registry's backend to target a S3 bucket.</li>

<li>a load balancer service built on top of haproxy and consul-template with auto discovery</li>
</ul>

<p>
Some nodes could play both "consul server" and "swarm server" roles to avoid booting too many servers for small cluster setups.
</p>
</div>
</div>


<div id="outline-container-orgheadline11" class="outline-3">
<h3 id="orgheadline11"><span class="section-number-3">6.3</span> The Nodes.yml</h3>
<div class="outline-text-3" id="text-6-3">
<p>
The philosophy behind the "nodes.yml" files is to configure several "nodes.yml" files that each defines small clusters with special infrastructure features, 
and make them join together to form a complete and robust swarm cluster, multi az, multi dc, with several type of storage, &#x2026;
</p>

<p>
You can select the nodes.yml file you want to target by simply setting the <code>BLACKFISH_NODES_YML</code> env variable
</p>

<div class="org-src-container">

<pre class="src src-bash">$ <span style="color: #7590db;">BLACKFISH_NODES_YML</span>=nodes_mycluster_control.yml vagrant up --provider=aws
...
$ <span style="color: #7590db;">BLACKFISH_NODES_YML</span>=nodes_mycluster_ebs-storage.yml vagrant up --provider=aws
...
$ <span style="color: #7590db;">BLACKFISH_NODES_YML</span>=nodes_mycluster_ssd.yml vagrant up --provider=aws
...
</pre>
</div>
</div>
</div>
</div>


<div id="outline-container-orgheadline23" class="outline-2">
<h2 id="orgheadline23"><span class="section-number-2">7</span> Considerations &amp; Roadmap</h2>
<div class="outline-text-2" id="text-7">
</div><div id="outline-container-orgheadline13" class="outline-3">
<h3 id="orgheadline13"><span class="section-number-3">7.1</span> Volume driver Plugins</h3>
<div class="outline-text-3" id="text-7-1">
<p>
Flocker is available on blackfish but it has been disabled due to a critical bug when running with a docker engine &lt; 1.11.
Rex Ray and Convoy suffer the same bug. Plus flocker's control service is not HA ready.
</p>
</div>
</div>

<div id="outline-container-orgheadline14" class="outline-3">
<h3 id="orgheadline14"><span class="section-number-3">7.2</span> CoreOS Alpha channel</h3>
<div class="outline-text-3" id="text-7-2">
<p>
Too many critical bugs are fixed on every docker release and the alpha channel is the one that sticks to the docker engine. 
When a good configuration of the different components will be stabilized, we will move to more stable channels.
</p>
</div>
</div>


<div id="outline-container-orgheadline15" class="outline-3">
<h3 id="orgheadline15"><span class="section-number-3">7.3</span> Consul + Etcd on the same hosts ?</h3>
<div class="outline-text-3" id="text-7-3">
<p>
It sounds crazy. Yet it is recommanded to use 2 separate consul clusters to run a swarm cluster : One for master election and service discovery, one for the docker overlay network.
As we run on coreos, there's a feature we'd like to enable: the automatic upgrade of coreos nodes based on their channel. To avoid that a whole cluster reboots all its node a the same time, coreos can use etcd to provide coordination.
</p>
</div>
</div>

<div id="outline-container-orgheadline16" class="outline-3">
<h3 id="orgheadline16"><span class="section-number-3">7.4</span> Use docker-machine</h3>
<div class="outline-text-3" id="text-7-4">
<p>
We didn't use docker-machine as it forces us to enter the "post provisionning" way of doing things.
</p>
</div>
</div>

<div id="outline-container-orgheadline17" class="outline-3">
<h3 id="orgheadline17"><span class="section-number-3">7.5</span> Run consul and swarm services as rocker containers</h3>
<div class="outline-text-3" id="text-7-5">
<p>
There are some caveats running the system services as docker containers, even on coreos. The main problem is the process supervision with systemd, as full described in this <a href="https://lwn.net/Articles/676831/">article</a>. 
Plus, we don't want system services to be visible and "killable" by a simple docker remote command.
</p>

<p>
That's why every system component is run with the rocket coreos container engine. 
</p>
</div>
</div>

<div id="outline-container-orgheadline18" class="outline-3">
<h3 id="orgheadline18"><span class="section-number-3">7.6</span> Monitoring</h3>
<div class="outline-text-3" id="text-7-6">
<p>
Monitoring and Log centralization is provided in a simple yet powerful manner :
</p>

<p>
Each node can be configured to report metrics and output its log to a remote machine. 
That way, you can bootstrap a cluster and then run monitoring tools such as graylog2 and influxdb on it, the nodes will automatically start sending to it.
</p>
</div>
</div>


<div id="outline-container-orgheadline19" class="outline-3">
<h3 id="orgheadline19"><span class="section-number-3">7.7</span> Running on GCE</h3>
<div class="outline-text-3" id="text-7-7">
<p>
TBDone
</p>
</div>
</div>

<div id="outline-container-orgheadline20" class="outline-3">
<h3 id="orgheadline20"><span class="section-number-3">7.8</span> Running on Azure</h3>
<div class="outline-text-3" id="text-7-8">
<p>
TBDone
</p>
</div>
</div>

<div id="outline-container-orgheadline21" class="outline-3">
<h3 id="orgheadline21"><span class="section-number-3">7.9</span> Running on premise</h3>
<div class="outline-text-3" id="text-7-9">
<p>
Thats why we'e chosen CoreOs. Coreos comes with powerful tools such as Ignition and coreos-baremetal that allow us to boot our solution on premise infrastructures.
</p>
</div>
</div>

<div id="outline-container-orgheadline22" class="outline-3">
<h3 id="orgheadline22"><span class="section-number-3">7.10</span> How to do rolling upgrades of the infrastructure with terraform&#x2026;?</h3>
<div class="outline-text-3" id="text-7-10">
<p>
well. that has to be defined.
</p>
</div>
</div>
</div>

<div id="outline-container-orgheadline24" class="outline-2">
<h2 id="orgheadline24"><span class="section-number-2">8</span> <a id="orgtarget2"></a>Configure DNS resolution</h2>
<div class="outline-text-2" id="text-8">
<p>
Before using swarm, you have to declare the Blackfish VMs internal DNS in your system. To do so, you have multiple options:
</p>

<ul class="org-ul">
<li>add one of the hosts in your /etc/resolv.conf (quick but dirty)</li>
<li><p>
configure your network manager to add the hosts permanently
</p>
<div class="org-src-container">

<pre class="src src-bash"><span style="color: #4f97d7;">echo</span> <span style="color: #2d9574;">'server=/vagrant/192.168.101.101'</span> | sudo tee -a /etc/NetworkManager/dnsmasq.d/blackfish-vagrant 
sudo systemctl restart NetworkManager.service
</pre>
</div></li>
<li>configure a local dnsmasq service which forwards dns lookups to the Blackfish Dns service according to domain names.</li>
</ul>

<p>
For the latter solution, you can refer to the <a href="./bin/dns">./bin/dns</a> file which runs a dnsmasq forwarder service.
</p>

<div class="org-src-container">

<pre class="src src-bash">$ <span style="color: #2aa1ae; background-color: #292e34;"># </span><span style="color: #2aa1ae; background-color: #292e34;">check your /etc/resolv.conf file</span>
$ cat /etc/resolv.conf
nameserver <span style="color: #a45bad;">127.0.0.1</span>
...
$ <span style="color: #2aa1ae; background-color: #292e34;"># </span><span style="color: #2aa1ae; background-color: #292e34;">eventually run the following command for your next boot (according to your OS)</span>
$ sudo su
root $ echo <span style="color: #2d9574;">"nameserver 127.0.0.1"</span> &gt; /etc/resolv.conf.head
root $ exit
$ ./bin/dns vagrant <span style="color: #a45bad;">192.168.101.101</span>
$ dig registry.service.vagrant

$ ...
</pre>
</div>
</div>
</div>

<div id="outline-container-orgheadline27" class="outline-2">
<h2 id="orgheadline27"><span class="section-number-2">9</span> <a id="orgtarget1"></a> Registering TLS Certificates</h2>
<div class="outline-text-2" id="text-9">
</div><div id="outline-container-orgheadline25" class="outline-3">
<h3 id="orgheadline25"><span class="section-number-3">9.1</span> Registering the CA Root on your OS</h3>
<div class="outline-text-3" id="text-9-1">
<p>
According to your OS and your distro, there are several ways to register the ca.pem on your os
</p>

<div class="org-src-container">
<label class="org-src-name">Example on ubuntu</label>
<pre class="src src-bash" id="orgsrcblock2">$ sudo cp ~/.blackfish/vagrant/ca.pem /usr/local/share/ca-certificates/blackfish-vagrant-ca.crt
$ sudo update-ca-certificates
</pre>
</div>

<div class="org-src-container">
<label class="org-src-name">Example on archlinux</label>
<pre class="src src-bash" id="orgsrcblock3">$ sudo cp ~/.blackfish/vagrant/ca.pem /etc/ca-certificates/trust-source/blackfish-vagrant-ca.crt
$ sudo update-ca-trust
</pre>
</div>
</div>
</div>

<div id="outline-container-orgheadline26" class="outline-3">
<h3 id="orgheadline26"><span class="section-number-3">9.2</span> Registering the certificates on your browser</h3>
<div class="outline-text-3" id="text-9-2">
<p>
Actually, there's a problem with the genererated certificates under chrome/chromium browsers. We have to spend time on it to now why chrome rejects it.
You can still use firefox by following these steps:
</p>
<ul class="org-ul">
<li>go to the <code>Preferences/Advanced/Certificates/View Certificates/Authorities</code> menu</li>
<li>import the <code>$HOME/.blackfish/vagrant/ca.pem</code> file</li>
<li>go to the <code>Preferences/Advanced/Certificates/View Certificates/Your Certificates</code> menu</li>
<li>import the <code>$HOME/.blackfish/vagrant/client.pfx</code></li>
</ul>

<p>
Now you should be able to access the <a href="https://consul-agent.service.vagrant:4443/ui">https://consul-agent.service.vagrant:4443/ui</a> url.
</p>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="date">Created: 2016-06-09 jeu. 14:07</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>