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

Creating microservices architectures using node.js and Kubernetes

Creating microservices architectures using node.js and Kubernetes

Slides for my talk at JSDayES 2017

Paul Goldbaum

May 13, 2017
Tweet

Other Decks in Programming

Transcript

  1. Our current stack MongoDB + Google Datastore Kubernetes through Google

    Container Engine Node.js + Express Apache Spark
  2. Abstract away differences between services Isolate apps from each other

    Reserve resources in shared execution environment Wrap as executable unit
  3. Provides deployment, scaling and management of containerized applications Works on

    some of the main public and private cloud providers and on-premise Serves as a layer of abstraction over the infrastructure Container cluster manager built by Google after Borg
  4. var express = require('express'); var app = express(); app.get('/', function(req,

    res) { res.send('Hello World!'); }) app.listen(3000, function() { console.log('Application running on port 3000!'); })
  5. apiVersion: extensions/v1beta1 kind: Deployment metadata: name: hello-world spec: replicas: 2

    template: metadata: labels: app: hello-world spec: containers: - name: main image: hello-world:v1 kubectl create -f hello-world.yaml
  6. var express = require('express'); var app = express(); app.get('/', function

    (req, res) { res.send('Hello World!'); }) app.get('/status', function (req, res) { res.sendStatus(200); }) app.listen(3000, function() { console.log('Application running on port 3000!'); })
  7. … spec: containers: - name: hello-world image: hello-world:v1 ports: -

    containerPort: 3000 readinessProbe: httpGet: path: /status port: 3000 periodSeconds: 5
  8. … var ready = true; app.get('/status', function (req, res) {

    if (ready) { res.sendStatus(200); } else { res.sendStatus(500); } }) process.on('SIGTERM', function () { ready = false; setTimeout(function() { server.close(function () { process.exit(0); }); }, 10000); }); …
  9. status endpoint / connection drain docker build test environment app

    instrumentation Custom NodeJS Microservices Framework … now what?
  10. apiVersion: v1 kind: Service metadata: name: hello-world spec: ports: -

    port: 3000 targetPort: 3000 selector: app: hello-world
  11. Prometheus Labels can be added to time series to allow

    grouping of data by any criteria Provides powerful query operators Allows to use queries to generate alerts Time-series database created by SoundCloud
  12. Connects to many different backend such as Prometheus, Graphite, InfluxDB,

    Elasticsearch, … Great for having your stats up on a screen in the office Web-based dashboard creator for visualizing time-series and application metrics
  13. Instrumented apps send spans to Zipkin Outgoing requests are marked

    with a correlation ID Zipkin joins spans from a single correlation ID together to form traces Distributed tracing system by Twitter
  14. Measure everything! Microservices are hard, imply a lot more operations

    work Creating a custom microservices framework is key to agility Conclusions
  15. [email protected] Do you want to help us change the world

    of online advertising. Join us! Thank you! Contact: [email protected] - @paulgoldbaum