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. 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
  2. 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"] } } } }
  3. 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"] } } } }
  4. Terminal $ nomad agent -dev ==> Starting Nomad agent... ==>

    Nomad agent configuration: Atlas: <disabled> 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]
  5. Single Region Architecture SERVER SERVER SERVER CLIENT CLIENT CLIENT DC1

    DC2 DC3 FOLLOWER LEADER FOLLOWER REPLICATION FORWARDING REPLICATION FORWARDING RPC RPC RPC
  6. 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
  7. 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
  8. application { name = "my-store" type = "ruby" dependency {

    source = "github.com/hashicorp/otto/examples/postgresql" } } customization "ruby" { ruby_version = "2.1" } Appfile
  9. 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 
  10. $ 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.
  11. $ 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
  12. $ 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.
  13. $ 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$
  14. $ 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!
  15. Today's Best Practices WEB DB MICRO SERVICES PRIVATE  SUBNET 

    PUBLIC  SUBNET  INTERNAL  NETWORK LB BASTION NAT
  16. WEB DB MICRO SERVICES PRIVATE  SUBNET  PUBLIC  SUBNET 

    INTERNAL  NETWORK LB BASTION NAT Today's Best Practices COMPLEXITY
  17. application { name = "my-store" type = "ruby" dependency {

    source = "github.com/hashicorp/otto/examples/postgresql" } } customization "ruby" { ruby_version = "2.1" } Appfile
  18. $ 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.
  19. $ 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