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

I Just Want to Ship My Code: Waypoint, Nomad, and Other Things

Michael Lange
February 18, 2021

I Just Want to Ship My Code: Waypoint, Nomad, and Other Things

Follow a nodejs application through Kubernetes, Nomad, Docker, and Pkg. Maybe learn a thing about how to think about systems along the way!

Michael Lange

February 18, 2021
Tweet

More Decks by Michael Lange

Other Decks in Technology

Transcript

  1. I write JavaScript for the browser ▪ A high-level language

    ▪ The loosest types with judicious coercion ▪ No memory management ▪ No filesystem ▪ Computers are an implementation detail
  2. Copyright © 2021 HashiCorp I just want to ship my

    code. Waypoint, Nomad, and other things.
  3. Black box ▪ Data plane (customer sites) ▪ Control plane

    ▪ Some sorta scheduler ▪ Lotsa DNS for static files ▪ CDN, file propagation ▪ Cgi-bin? Lol? ▪ A bunch of engineers of all varieties
  4. With Waypoint, you get a single config file CODE EDITOR

    project = "example-nodejs" app "example-nodejs" { labels = { "service" = "example-nodejs", "env" = "dev" } build { use "pack" {} registry { use "docker" { image = "example-nodejs" tag = "1" local = true } } } deploy { use "kubernetes" { probe_path = "/" } } release { use "kubernetes" { } } }
  5. What you didn’t see is what’s interesting 1. No Dockerfile

    or docker-compose.yml 2. No ReplicaSet 3. No Deployment 4. No Service 5. No kubectl 6. No YAML
  6. The Power of Abstractions 💪 Build Registry Deploy Release package.json

    *.js *.ejs *.png Source Code Buildpacks Container Image Hub/ECR/GCR ReplicaSet Service kubectl apply Deployment
  7. And the Waypoint File CODE EDITOR project = "example-nodejs" app

    "example-nodejs" { build { use "pack" {} registry { use "docker" { image = "nodejs-example" tag = "1" local = true } } } deploy { use "nomad" { datacenter = "dc1" } } }
  8. And the Waypoint File CODE EDITOR project = "example-nodejs" app

    "example-nodejs" { build { use "pack" {} registry { use "docker" { image = "nodejs-example" tag = "1" local = true } } } deploy { use "nomad" { datacenter = "dc1" } } } project = "example-nodejs" app "example-nodejs" { labels = { "service" = "example-nodejs", "env" = "dev" } build { use "pack" {} registry { use "docker" { image = "example-nodejs" tag = "1" local = true } } } deploy { use "kubernetes" { probe_path = "/" } } release { use "kubernetes" { } } }
  9. Takeaways From the perspective of a product engineer 1. No

    workflow change!!! 1. waypoint init && waypoint up 2. Very little code change 3. Minor conceptual changes to output 4. Both Kubernetes and Nomad are built for common abstractions
  10. Copyright © 2021 HashiCorp I just want to ship my

    code. Waypoint, Nomad, and other things.
  11. A look at Nomad’s Task Driver Model A loosely abstracted,

    unopinionated, pluggable runtime model Ranging from raw processes to VMs to containers. Many are builtin, many are community owned.
  12. The Nomad exec driver 1. Builds a chroot 2. And

    a cgroup 3. Configurable resource limits 4. All on demand
  13. But what about non- executable files? Annotate your package.json file

    to bake files into your binary. CODE EDITOR { "name": "node-js-getting-started", "version": "0.3.0", "description": "A sample Node.js app using Express 4", "engines": { "node": "12.x" }, "main": "index.js", "scripts": { "start": "node index.js", "test": "node test.js" }, "dependencies": { "directory-tree": "^2.2.5", "ejs": "^2.5.6", "express": "^4.15.2" }, "devDependencies": { "got": "^11.3.0", "tape": "^4.7.0" }, "keywords": [ "node", "express" ], "license": "MIT", "bin": "index.js", "pkg": { "assets": [ "views/**/*", "public/**/*" ] } }
  14. Putting it all together ▪ Buildpacks (Dockerfile) ▪ Container Registry

    ▪ docker driver pkg (binary) File server (probably S3) exec Driver
  15. The Power of ABSTRACTIONS!!! 💪 Build Registry Deploy Release package.json

    *.js *.ejs *.png HCL Built in to service jobs pkg BIN :)
  16. Docker Pkg Let’s review some stats Build Time 55.50s Artifact

    Size 1075MB Build Time 4.67s Artifact Size 46MB
  17. Safety NOT Guaranteed ▪ Not ready for production ▪ Check

    out the code though! https://github.com/dingoeatingfuzz/waypoint-plugin-pkg
  18. The moral of the story 1. Consider the whole system

    2. Well defined interfaces help us all 3. Abstractions are all around us 4. Challenge those abstractions from time to time Make time and space for this R&D