Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Create a Docker Swarm cluster with Terraform an...

Create a Docker Swarm cluster with Terraform and Ansible

Do you want to start in the world of Infrastructure as Code with a useful case? Let's go creating a multicloud Docker Swarm cluster to run your microservices as a good starting point, using Terraform to provision servers and Ansible to install and configure Docker to run in Swarm mode.

Marcelo Pinheiro

September 30, 2017

Transcript

21 slides
  1. $ whoami • Fireman / Problem Solver / Programmer since

    2000 • Golang, Node.js, Erlang, Ruby, Python, Delphi, C++, C#, C, Java, PHP, ASP and Others • Fought, made coffee, negotiated deadlines • DevOps Engineer @ Work & Co
  2. Infrastructure As Code • One of most traditional requirement that

    implies in some late in the projects is infrastructure: • Manual steps • Slow provision • Knowledge transfer issues
  3. Infrastructure As Code • Infrastructure As Code ables you to

    manage resources using source code or CLI tools • Command-Line interfaces • Recipes to create, configure and manage infrastructure-related resources
  4. Infrastructure As Code • Despite CLI it effectively solves, you

    can have some challenges: • Command-Line Interfaces not supports Idempotency • You still need to store knowledge into Bash scripts • More complexity to locally setup and run
  5. Terraform: Manage Cloud Infrastructure • Created by Hashicorp (Consul, Nomad,

    Vault and others) • Human-readable recipes using Hashicorp DSL • Server instances, virtual networks, object storage, DNS zones / entries, SaaS services and other resources • Ideal solution to manage resources that not changes frequently
  6. Terraform: Manage Cloud Infrastructure • Multi-cloud support • Amazon Web

    Services • Microsoft Azure • Google Cloud • Microsoft Azure and Google Cloud requires some manual configuration steps to proceed
  7. Docker Swarm: Orchestrate Containers • Docker Swarm is the orchestration

    solution for Docker hosts • A pool of servers • Workers: servers that will run all Docker containers • Managers: responsible to coordinate container’s execution between workers • Ordered in less complexity to implement: • Docker Swarm • AWS ECS • Kubernetes
  8. Docker Swarm: Orchestrate Containers • Docker Swarm concepts • Service:

    a container definition to run in Swarm • Stack: a group of services that composes a application • In practice, is Docker Compose with additional definitions
  9. Ansible: Easy Configuration Management • CFEngine, Chef, Puppet and SaltStack

    uses master-agent architecture • One or more master servers • Each node have a client installed • Ansible is masterless architecture • You can run from your machine or any server that have it installed, just have the SSH keys
  10. Ansible: Easy Configuration Management • We will setup a Docker

    Swarm cluster using ansible-playbook • Idempotency for the rescue • Deploy a Docker Swarm stack as example

More Decks by Marcelo Pinheiro

Other Decks in Technology