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

Introduction to Nomad and Otto

Armon Dadgar
November 17, 2015

Introduction to Nomad and Otto

In this talk I introduce both Nomad and Otto, tools recently announced at HashiConf 2015. Nomad is a distributed cluster scheduler, that makes it easy to declaratively run applications across a cluster of machines. Otto is the spiritual successor to Vagrant, making creating development environments easier, adding deployment to the workflow, and helping micro service oriented workflows.

This talk was presented at the InfraCoders meetup in Santa Clara.

Armon Dadgar

November 17, 2015
Tweet

More Decks by Armon Dadgar

Other Decks in Technology

Transcript

  1. Armon Dadgar
    @armon

    View full-size slide

  2. Management
    Collaboration
    Security
    Web
    Interface
    CLI
    Core
    Functionality
    Open
    Source
    The relationship between Otto and Atlas is like Git and GitHub
    Git
    Otto
    GitHub
    Atlas

    View full-size slide

  3. Nomad
    Distributed Scheduler
    Easily Deploy Applications
    Job Specification

    View full-size slide

  4. example.nomad
    # Define our simple redis job
    job "redis" {
    # Run only in us-east-1
    datacenters = ["us-east-1"]
    # Define the single redis task using Docker
    task "redis" {
    driver = "docker"
    config {
    image = "redis:latest"
    }
    resources {
    cpu = 500 # Mhz
    memory = 256 # MB
    network {
    mbits = 10
    dynamic_ports = ["redis"]
    }
    }
    }
    }

    View full-size slide

  5. Job Specification
    Declares what to run

    View full-size slide

  6. Job Specification
    Nomad determines where and
    manages how to run

    View full-size slide

  7. Job Specification
    Powerful yet simple

    View full-size slide

  8. example.nomad
    # Define our simple redis job
    job "redis" {
    # Run only in us-east-1
    datacenters = ["us-east-1"]
    # Define the single redis task using Docker
    task "redis" {
    driver = "docker"
    config {
    image = "redis:latest"
    }
    resources {
    cpu = 500 # Mhz
    memory = 256 # MB
    network {
    mbits = 10
    dynamic_ports = ["redis"]
    }
    }
    }
    }

    View full-size slide

  9. Containerized
    Virtualized
    Standalone
    Docker
    Qemu / KVM
    Java Jar
    Static Binaries

    View full-size slide

  10. Containerized
    Virtualized
    Standalone
    Docker
    Jetpack
    Windows Server Containers
    Qemu / KVM
    Hyper-V
    Xen
    Java Jar
    Static Binaries
    C#

    View full-size slide

  11. Nomad
    Application Deployment
    Docker
    Multi-Datacenter and Multi-Region
    Flexible Workloads
    Bin Packing
    HCL Job Specifications

    View full-size slide

  12. Nomad
    Easy for developers
    Operationally simple
    Built for scale

    View full-size slide

  13. Easy for developers

    View full-size slide

  14. Terminal
    $ nomad agent -dev
    ==> Starting Nomad agent...
    ==> Nomad agent configuration:
    Atlas:
    Client: true
    Log Level: DEBUG
    Region: global (DC: dc1)
    Server: true
    ==> Nomad agent started! Log data will stream in below:
    [INFO] serf: EventMemberJoin: nomad.global 127.0.0.1
    [INFO] nomad: starting 4 scheduling worker(s) for [service batch _core]
    [INFO] raft: Node at 127.0.0.1:4647 [Follower] entering Follower state
    [INFO] nomad: adding server nomad.global (Addr: 127.0.0.1:4647) (DC: dc1)
    [DEBUG] client: applied fingerprints [storage arch cpu host memory]
    [DEBUG] client: available drivers [docker exec]

    View full-size slide

  15. Operationally simple

    View full-size slide

  16. Client Server

    View full-size slide

  17. Built for scale

    View full-size slide

  18. Built on experience
    gossip consensus

    View full-size slide

  19. Built on research
    gossip consensus

    View full-size slide

  20. Single Region Architecture
    SERVER SERVER SERVER
    CLIENT CLIENT CLIENT
    DC1 DC2 DC3
    FOLLOWER LEADER FOLLOWER
    REPLICATION
    FORWARDING
    REPLICATION
    FORWARDING
    RPC RPC RPC

    View full-size slide

  21. Multi-region Architecture
    SERVER SERVER SERVER
    FOLLOWER LEADER FOLLOWER
    REPLICATION
    FORWARDING
    REPLICATION
    REGION  B
     GOSSIP
    REPLICATION REPLICATION
    FORWARDING
    REGION  FORWARDING
     REGION  A
    SERVER
    FOLLOWER
    SERVER SERVER
    LEADER FOLLOWER

    View full-size slide

  22. Thousands of regions
    Tens of thousands of clients per region
    Thousands of jobs per region

    View full-size slide

  23. Optimistically Concurrent

    View full-size slide

  24. HASHICORP
    Evaluations ~= State Change Event

    View full-size slide

  25. HASHICORP
    Create / Update / Delete Job
    Node Up / Node Down
    Allocation Failed

    View full-size slide

  26. HASHICORP
    “Scheduler” =
    func(Eval) => []AllocUpdates

    View full-size slide

  27. HASHICORP
    Scheduler func’s can specialize
    (Service, Batch, System, etc)

    View full-size slide

  28. HASHICORP
    Evaluation Enqueue

    View full-size slide

  29. HASHICORP
    Evaluation Dequeue

    View full-size slide

  30. HASHICORP
    Plan Generation

    View full-size slide

  31. HASHICORP
    Plan Execution

    View full-size slide

  32. HASHICORP
    External  Event
    Evalua?on  Crea?on
    Evalua?on  Queuing
    Evalua?on  Processing
    Op?mis?c  Coordina?on
    State  Updates

    View full-size slide

  33. Case study
    3 servers in NYC3
    100 clients in NYC3, SFO1, AMS2/3
    1000 Containers

    View full-size slide

  34. Case study
    <1s to schedule
    1s to first start
    6s to 95%
    8s to 99%

    View full-size slide

  35. Nomad
    Easy for developers
    Operationally simple
    Built for scale

    View full-size slide

  36. HASHICORP
    Nomad 0.1
    Released in October
    Service and Batch Scheduler
    Docker, Qemu, Exec, Java Drivers

    View full-size slide

  37. HASHICORP
    Nomad 0.2 - Service Workloads
    Service Discovery
    System Scheduler
    Restart Policies
    Enhanced Constraints

    View full-size slide

  38. HASHICORP
    Nomad 0.3 - Batch Workloads
    Cron
    Job Queuing
    Latency-Aware Scheduling

    View full-size slide

  39. nomadproject.io

    View full-size slide

  40. Otto
    The Successor 

    to Vagrant

    View full-size slide

  41. Vagrant
    Our biggest OSS project
    Built in 2010
    Re-imagined for 2015

    View full-size slide

  42. Vagrant
    What have we learned?

    View full-size slide

  43. Vagrant
    Development environment
    deviation is minimal

    View full-size slide

  44. Vagrant
    Developers want to deploy

    View full-size slide

  45. Vagrant
    Microservices are the future

    View full-size slide

  46. Otto
    The Successor 

    to Vagrant

    View full-size slide

  47. Otto
    Development
    Deployment
    Microservices
    Appfile

    View full-size slide

  48. Lorem ipsum dolor sit amet, consectetur
    adipiscing elit. Nulla quis ex nec
    lectus auctor semper at eu nunc. Nulla
    lorem mi, interdum eget libero
    eleifend, euismod laoreet neque. Donec
    nec enim rhoncus, varius nisi ut,
    hendrerit sem. Cras nec vestibulum
    nunc, blandit cursus eros. Etiam
    tincidunt cursus turpis, sit amet
    lacinia nunc consectetur at. Vestibulum
    nec faucibus neque, a dapibus elit. Cras
    aliquam, enim ut tincidunt aliquam,
    enim nunc hendrerit leo, ac fringilla
    lectus lacus quis arcu.
    Appfile

    View full-size slide

  49. THIS FILE
    INTENTIONALLY
    LEFT BLANK
    Appfile

    View full-size slide

  50. application {
    name = "my-store"
    type = "ruby"
    dependency {
    source = "github.com/hashicorp/otto/examples/postgresql"
    }
    }
    customization "ruby" {
    ruby_version = "2.1"
    }
    Appfile

    View full-size slide

  51. Codification vs. Fossilization

    View full-size slide

  52. Otto is smart.
    Otto will get smarter.

    View full-size slide

  53. Lorem ipsum dolor sit amet, consectetur
    adipiscing elit. Nulla quis ex nec
    lectus auctor semper at eu nunc. Nulla
    lorem mi, interdum eget libero
    eleifend, euismod laoreet neque. Donec
    nec enim rhoncus, varius nisi ut,
    hendrerit sem. Cras nec vestibulum
    nunc, blandit cursus eros. Etiam
    tincidunt cursus turpis, sit amet
    lacinia nunc consectetur at. Vestibulum
    nec faucibus neque, a dapibus elit. Cras
    aliquam, enim ut tincidunt aliquam,
    enim nunc hendrerit leo, ac fringilla
    lectus lacus quis arcu.
    Appfile Compilation

    View full-size slide

  54. $ otto compile
    ==> Loading Appfile...
    ==> Fetching all Appfile dependencies...
    ==> Compiling...
    Application: vault (go)
    Project: vault
    Infrastructure: aws (simple)
    Compiling infra...
    Compiling foundation: consul
    ==> Compiling main application…
    ==> Compilation success!
    This means that Otto is now ready to start a development 

    environment, deploy this application, build the 

    supporting infrastructure, and more. See the help for 

    more information.

    View full-size slide

  55. $ tree .otto
    .otto
    "## appfile
    $ "## Appfile.compiled
    $ # version
    "## compiled
    $ "## app
    $ $ "## dev
    $ $ $ # Vagrantfile
    $ $ "## dev-dep
    $ $ $ "## Vagrantfile
    $ $ $ "## Vagrantfile.fragment
    $ $ $ "## build.sh
    $ $ $ # upstart.conf
    $ $ # foundation-consul
    $ $ "## app-build
    $ $ $ "## main.sh
    $ $ $ # upstart.con

    27 directories, 49 files

    View full-size slide

  56. Fossilization

    View full-size slide

  57. Development
     

    View full-size slide

  58. $ otto dev

    ==> Caching SSH credentials from Vagrant...
    ==> Development environment successfully created!
    IP address: 172.16.1.154
    A development environment has been created for writing
    a generic Ruby-based app.
    Ruby is pre-installed. To work on your project, edit
    files locally on your own machine. The file changes will
    be synced to the development environment.
    When you're ready to build your project, run 'otto dev
    ssh' to enter the development environment. You'll be
    placed directly into the working directory where you can
    run 'bundle' and 'ruby' as you normally would.
    You can access any running web application using the IP
    above.

    View full-size slide

  59. $ otto dev ssh
    ==> Executing SSH. This may take a few seconds...
    Welcome to Ubuntu 12.04.1 LTS
    * Documentation: https://help.ubuntu.com/
    Last login: Sun Sep 27 17:20:30 2015 from 172.16.1.1
    vagrant@precise64:/vagrant$

    View full-size slide

  60. $ otto dev address
    172.16.1.154

    View full-size slide

  61. $ otto dev destroy
    ==> Destroying the local development environment...
    ==> default: Stopping the VMware VM...
    ==> default: Deleting the VM...
    ==> default: Running cleanup tasks for 'shell' provisioner...
    ==> default: Running cleanup tasks for 'shell' provisioner...
    ==> Deleting development environment metadata...
    ==> Development environment has been destroyed!

    View full-size slide

  62. A wonderfully simple
    development experience

    View full-size slide

  63. Development
     

    View full-size slide

  64. Deployment
     

    View full-size slide

  65. Today's Best Practices
    WEB DB MICRO
    SERVICES
    PRIVATE  SUBNET

    PUBLIC  SUBNET

    INTERNAL  NETWORK
    LB
    BASTION NAT

    View full-size slide

  66. WEB DB MICRO
    SERVICES
    PRIVATE  SUBNET

    PUBLIC  SUBNET

    INTERNAL  NETWORK
    LB
    BASTION NAT
    Today's Best Practices
    COMPLEXITY

    View full-size slide

  67. $ otto infra
    $ otto build
    $ otto deploy

    View full-size slide

  68. Microservices
    Monolithic Microservices

    View full-size slide

  69. Microservices

    View full-size slide

  70. Microservices

    View full-size slide

  71. application {
    name = "my-store"
    type = "ruby"
    dependency {
    source = "github.com/hashicorp/otto/examples/postgresql"
    }
    }
    customization "ruby" {
    ruby_version = "2.1"
    }
    Appfile

    View full-size slide

  72. $ otto dev

    [otto] Installing dependency: postgresql
    [otto] Configuring Consul service: postgresql
    ==> Development environment successfully created!
    IP address: 172.16.1.154
    A development environment has been created for writing
    a generic Ruby-based app.
    Ruby is pre-installed. To work on your project, edit
    files locally on your own machine. The file changes will
    be synced to the development environment.
    When you're ready to build your project, run 'otto dev
    ssh' to enter the development environment. You'll be
    placed directly into the working directory where you can
    run 'bundle' and 'ruby' as you normally would.
    You can access any running web application using the IP
    above.

    View full-size slide

  73. $ otto dev ssh
    vagrant@precise64:/otto$ nslookup postgresql.service.consul.
    Server: 127.0.0.1
    Address: 127.0.0.1#53
    Name: postgresql.service.consul
    Address: 192.168.139.214

    View full-size slide

  74. $ otto deploy

    ==> Application deployed!
    Address: ec2-10-1-2-3.us-east-1.compute.amazonaws.com

    View full-size slide

  75. Otto
    Development
    Deployment
    Microservices
    Appfile

    View full-size slide

  76. ottoproject.io

    View full-size slide

  77. QUESTIONS?
    THANK  YOU!

    View full-size slide