class: center, middle, title-slide count: false # From Zero to WOW! with Nomad ![:scale 70%](images/Nomad_PrimaryLogo_FullColor.svg) --- # Agenda 1. Introduction 1. What is Nomad? 1. Nomenclature 1. Architecture Overview 1. Starting Simple 1. Running Your First Job 1. Scaling Things Up 1. Where Next? 1. Q&A --- # Introduction ## Russ Parsloe -- * Solutions Engineer -- * Working at HashiCorp for almost 2 years... -- * ...still feel fairly new with Nomad... -- * ...so let's learn the basics together! 🙌 --- # What is Nomad? -- * Modern, lightweight workload scheduler ??? What is a workload scheduler? Back when I was a server administrator, this was me. Application teams would raise a ticket and throw code over a fence to my team to arrange computer, storage and networking. The problem was that it wasn't a particular fast or scalable solution. And we generally weren't able to purchase additional equipment to run new applications on, so it often meant trying to find a suitable home on the existing infrastructure. Thankfully we now have Nomad to do all this hard work for us. By creating a giant pool of compute, network and storage, we can let Nomad place workloads wherever it's most efficient. -- * Supports containers, traditional VMs and static binaries ??? In practice, it's rare to find an organisation that has moved all of their workloads to containers. We live in a world where we have many different types of technologies in use that we need to manage. This is why Nomad supports a wide range of drivers such as Docker, Java and binaries running natively on the host. -- * Uses simple job config files ??? This makes it easy for people to understand and deploy workloads on Nomad -- * Automatic & efficient workload placement -- * Supports rolling, canary and blue/green deployments ??? This allows us to define how upgrades take place that best fits our requirements. * Rolling performs a set number of updates, waiting for them to be healthy before continuing the upgrade * Canary creates a new allocation allowing you to perform testing before rolling it out everywhere * Blue/green lets you deploy a separate set of resources and then flip over once you are happy it's good to go -- * Automated failure recovery ??? If something fails a health check, maybe there was a crash or an error, Nomad can redeploy a fresh copy of your application and get things working again --- # Why Nomad? -- * Need to support mixed environments -- * Move legacy applications to cloud -- * Get maximum efficiency from hardware ??? Most servers operate at around 2% utilisation. Maybe with Nomad we can get to 20% utilisation. That might not sound like a massive jump, but if you do the maths, if we previously needed 100 servers to run your workloads, with Nomad, you'd only need 10 -- * Automated machine placement ??? Nomad automatically works out where to best place your workload. You can define additional parameters and constraints to make sure machines are run according to your needs -- * Enable self-service provisioning ??? No longer do we want to be a in a world of raising tickets, waiting to reach the front of the queue, then finding out there was an issue and having to go through the whole process again! Put that control back into the hands of the people consuming the resources, and abstract away the complexities of operating the underlying systems --- # But seriously, why **Nomad**? -- * Simplicity/ease of use * Single binary ??? As we'll see in the demo later, Nomad is just a single binary with an easy to remember mental model. This makes setting up, operating and upgrading much simpler -- * Flexibility * Containers/VMs * Service or batch jobs * Linux and Windows (and Mac OS!) -- * Scalability and performance - C1M ??? You might not need the highest levels of performance, but we wanted to push Nomad to see what it could do. A couple of years ago, we did the Million Container Challenge where we spun up 1 million containers in less than 5 minutes. --- # Million Container Challenge ![:scale 100%](images/c1m-results.png) .center[https://www.hashicorp.com/c1m] ??? One cool story I heard about this - one customer that utilises high performance computing saw this, and said "1 million containers is cute - how about we use Nomad to do this with 40 million?". Operating on the principle that if we can scale up high, we can scale down too, Nomad has got your covered wherever you fit in that sliding scale! --- # Nomenclature **Job** - _a specification provided by users that declares a workload for Nomad_ ```ruby # This declares a job named "docs". There can # be exactly one job declaration per job file job "docs" { ... } ``` --- # Nomenclature **Task Group** - _a set of tasks that must be run together on the same client node_ ```ruby job "docs" { group "web" { # All tasks in this group will run on # the same node ... } group "logging" { # These tasks must also run together # but may be a different node from web ... } } ``` --- # Nomenclature **Task** - _the smallest unit of work in Nomad_ ```ruby job "docs" { group "example" { task "server" { # ... } } } ``` --- # Nomenclature **Driver** – _represents the basic means of executing your Tasks e.g. Docker, Java, Qemu etc_ ```ruby task "server" { driver = "docker" ... } ``` --- # Nomenclature **Allocation** - _a mapping between a task group in a job and a client node_ --- # Nomenclature **Evaluation** - _the mechanism by which Nomad makes scheduling decisions_ --- # Nomenclature **Bin Packing** - _optimizes resources by efficiently bin packing tasks onto client machines to maximise utilisation_ .center[![:scale 25%](images/bad_tetris.gif)] --- # Architecture **Client** - _a machine that tasks can be run on_ **Server** - _manages all jobs and clients, run evaluations, and create task allocations_ .center[![:scale 100%](images/nomad-architecture-region.png)] --- # Starting Simple -- * Unlikely we'll need to schedule 1 million containers -- * Let start simply, running Nomad locally -- * Your OS might work differently from mine - always check the docs for the latest info -- * Some software I've already installed such as Docker --- # Download and Installation -- * Nomad is available from [nomadproject.io](https://www.nomadproject.io/) for Windows, Mac and Linux -- * Download zip for your OS, unzip, and you're done --- class: center, middle # DEMO: Download and Install --- # Running Nomad -- * We are going to use Dev mode -- * Agent runs as both server and client -- * DO NOT USE IN PRODUCTION - data is not persisted -- ```bash $ nomad agent -dev ``` --- class: center, middle # DEMO: Running Nomad --- # Java Driver .center[![:scale 80%](images/java_warning.png)] -- * Disable Java Driver -- * Use `driver.blacklist` parameter in client [config](https://www.nomadproject.io/docs/configuration/client.html#quot-driver-blacklist-quot-) --- class: center, middle # DEMO: Running Nomad - take 2 --- # Nomad UI -- * User Interface available on port 4646 -- * View clients and servers -- * Run and view jobs --- class: center, middle # DEMO: Nomad User Interface --- # Running Our First Job -- * Define our job in a simple job file -- * Run **http-echo** Docker container -- * Renders a HTML page containing the argument provided to it - e.g. "Hello World!" -- * Listens on a port provided by another argument - e.g. port 8080 --- class: center, middle # DEMO: Running Our First Job - http-echo --- # Scaling Up Our Applications -- * What if we want more than one instance of the application running? -- * Increase the count! -- ```ruby group "echo" { count = 5 task "server" { ... } } ``` -- * Resubmit the job --- class: center, middle # DEMO: Scaling Up The Application --- # Making Our Job Dynamic -- * Multiple tasks cannot all share the same port -- * This can lead to collisions when using static ports -- * Can use dynamic port assignment to run many instances on a single node -- * [Runtime Environment Variables](https://www.nomadproject.io/docs/runtime/interpolation.html) can be used in job files --- class: center, middle # DEMO: Using Dynamic Variables --- # Service Discovery -- * When scheduling workloads dynamically, port numbers and even host names can change frequently -- * Applications still need a simple way to address other resources and components -- * A service catalog provides a simple way to find other services -- * A very famous one is Consul! --- # Service Discovery -- * Need to solve 2 challenges -- * We need a way to run Consul -- * We need to register our http-echo application in the registry -- * We can solve both easily with Nomad! --- # Using Consul on Nomad -- * We'll schedule Consul to run natively on my Mac using the [Raw Exec](https://www.nomadproject.io/docs/drivers/raw_exec.html) task driver -- * We can use the [artifact](https://www.nomadproject.io/docs/job-specification/artifact.html) stanza to download binary and unzip it - nothing to install! -- * Nomad supports Consul natively with the [service](https://www.nomadproject.io/docs/job-specification/service.html) stanza --- class: center, middle # DEMO: Running Consul and Registering Our Application --- # Service Discovery -- * Dynamic ports can be queried in Consul catalog -- * Fine for machine-to-machine communication -- * Less ideal for us browser users --- # Introducing Fabio -- .center[![](images/fabio.gif)] --- # Introducing Fabio -- * HTTP and TCP reverse proxy -- * Originally developed by eBay -- * Auto-configures itself using Consul info -- * Single binary -- * More info - https://fabiolb.net/ --- class: center, middle # DEMO: Running Fabio --- # Updating our application -- * Different update strategies -- * We will use a canary update -- * If successful, we'll update rest of our application --- class: center, middle # DEMO: Updating our application --- # What we covered -- * Download, install and run Nomad -- * Run multiple instances of a web application -- * Service discovery and health checking -- * Load balancing -- * Updating our application --- .center[![:scale 100%](images/wow.gif)] --- # Next Steps -- * Try this for yourself! -- * Run through [Learn](https://learn.hashicorp.com/nomad) portal and [guides](https://www.nomadproject.io/guides/index.html) -- * Check out [documentation](https://www.nomadproject.io/docs/index.html) -- * Build a multi-node, multi-region cluster! -- * Deploy a million containers!