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

ZEIT, Serverless Deployments

ZEIT, Serverless Deployments

Ondrej Sika

March 01, 2020

More Decks by Ondrej Sika

Other Decks in Programming


  1. @ondrejsika ondrej@sika.io sika.io Ondrej Sika ondrej@sika.io @ondrejsika Install Fest 2020,

    1. 3. 2020 ZEIT, Serverless Deployments
  2. @ondrejsika ondrej@sika.io sika.io Agenda - Serverless Introduction - What is

    ZEIT - Setup ZEIT - Deployments - Examples - Static Website - Next.js Website - Go API (lambdas) - Pricing
  3. @ondrejsika ondrej@sika.io sika.io What is Serverless Serverless computing is a

    cloud-computing execution model in which the cloud provider runs the server, and dynamically manages the allocation of machine resources. Pricing is based on the actual amount of resources consumed by an application, rather than on pre-purchased units of capacity.
  4. @ondrejsika ondrej@sika.io sika.io History of Deployments - Manual deployments on

    physical machines - Deployments to hostings or virtual servers - Docker deployments - Kubernetes deployments - Serverless deployments
  5. @ondrejsika ondrej@sika.io sika.io What is ZEIT Zero config serverless platform

  6. @ondrejsika ondrej@sika.io sika.io ZEIT Features - Zero config deployments -

    Static & lambda deployments (build on top of AWS Lambda) - CDN - DNS - Domains - Github, Gitlab & Bitbucket Integration (for automatic deployments)
  7. @ondrejsika ondrej@sika.io sika.io Setup ZEIT Sign up on https://zeit.co using

    Github, Gitlab, Bitbucket or email
  8. @ondrejsika ondrej@sika.io sika.io Sign to ZEIT Just call `now`and confirm

    sign in from email.
  9. @ondrejsika ondrej@sika.io sika.io Zero Config Deployments Just call `now` from

    and your project will be deployed.
  10. @ondrejsika ondrej@sika.io sika.io What are Lambda Functions Lambda functions are

    simple event handlers (typically for HTTP requests) which are executed on serverless platform without needs of any virtual machine or Docker container.
  11. @ondrejsika ondrej@sika.io sika.io Zero Config Lambda Support If you want

    to use Lambdas on zeit put file containing function (with proper interface) to `api/`. They have native support for Node, Go, Python, and Ruby.
  12. @ondrejsika ondrej@sika.io sika.io Example Node Function module.exports = (req, res)

    => { res.send(`Hello from Node JS!`); };
  13. @ondrejsika ondrej@sika.io sika.io Example Go Function package handler import (

    "fmt" "net/http" ) func Handler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello from Go!") }
  14. @ondrejsika ondrej@sika.io sika.io Example Python Function from http.server import BaseHTTPRequestHandler

    class handler(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.send_header('Content-type','text/plain') self.end_headers() self.wfile.write("Hello from Python!".encode())
  15. @ondrejsika ondrej@sika.io sika.io ZEIT Smart CDN - Static files are

    cached on 32 edge locations (multiple cloud providers) - Lambdas are in closest AWS region
  16. @ondrejsika ondrej@sika.io sika.io ZEIT Domains You can add custom domains

    to ZEIT or buy domains directly. - If you want to add domain, you have to point your nameservers to ZEIT. - You can buy domains from ZEIT Dashboard You can also buy domain using `now domain buy example.com`
  17. @ondrejsika ondrej@sika.io sika.io ZEIT DNS ZEIT has great DNS infrastructure,

    you can manage DNS Records in Dashboard and using CLI - `now alias set example.now.sh example.com` - `now dns add example.com mail A` - `now dns add example.com @ MX mail.example.com 99.`
  18. @ondrejsika ondrej@sika.io sika.io ZEIT Terraform Support - I've written terraform-provider-zeit

    - Support only domains (with buy), DNS Record management, and aliases - Still in progress Homepage: https://github.com/ondrejsika/terraform-provider-zeit
  19. @ondrejsika ondrej@sika.io sika.io Example Terraform Manifest provider "zeit" { token

    = "secret-token" } resource "zeit_domain" "sikademozeit_com" { domain = "sikademozeit.com" expected_price = 12 } resource "zeit_dns" "sikademozeit_com" { domain = zeit_domain.sikademozeit_com.domain name = "" value = "" type = "A" }
  20. @ondrejsika ondrej@sika.io sika.io Example Static Deployment

  21. @ondrejsika ondrej@sika.io sika.io Example Next.js Deployment

  22. @ondrejsika ondrej@sika.io sika.io Example Lambda Deployment

  23. @ondrejsika ondrej@sika.io sika.io Deployment Configuration You can create file `now.json`

    to provide following configuration: - Routes - Environment Variables (for Lambdas & build) - Redirects - Headers - ...
  24. @ondrejsika ondrej@sika.io sika.io Example Deployment with Routes

  25. @ondrejsika ondrej@sika.io sika.io Now Dev You can run deployment in

    development mode `now dev` and ZEIT will automatically sync your changes.
  26. @ondrejsika ondrej@sika.io sika.io Github Integration If you enable Github integration

    every commit will be deployed and every push into master will be production deployment.
  27. @ondrejsika ondrej@sika.io sika.io ZEIT Pricing - Free for small &

    hobby projects - Unlimited deployments (Pro plan) for 20 USD / month See pricing at https://zeit.co/pricing
  28. @ondrejsika ondrej@sika.io sika.io DEMO TIME

  29. @ondrejsika ondrej@sika.io sika.io ZEIT Czech Community - We've started a

    ZEIT community meetups in Prague - First meetup will be 2. 4. 2020 at Braiins More informations: https://www.meetup.com/ZEIT-Czech-Community/
  30. @ondrejsika ondrej@sika.io sika.io sika.link/if20-zeit

  31. @ondrejsika ondrej@sika.io sika.io sika.link/if20-zeit

  32. @ondrejsika ondrej@sika.io sika.io Thank you & Questions Ondrej Sika email:

    ondrej@sika.io www: https://sika.io, https://ondrej-sika.cz twitter: @ondrejsika linkedin: /in/ondrejsika/ Sources: https://sika.link/if20-zeit