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

ZEIT, Serverless Deployments

ZEIT, Serverless Deployments

Ondrej Sika

March 01, 2020
Tweet

More Decks by Ondrej Sika

Other Decks in Programming

Transcript

  1. @ondrejsika [email protected] sika.io
    Ondrej Sika
    [email protected]
    @ondrejsika
    Install Fest 2020, 1. 3. 2020
    ZEIT,
    Serverless Deployments

    View Slide

  2. @ondrejsika [email protected] sika.io
    Agenda
    - Serverless Introduction
    - What is ZEIT
    - Setup ZEIT
    - Deployments
    - Examples
    - Static Website
    - Next.js Website
    - Go API (lambdas)
    - Pricing

    View Slide

  3. @ondrejsika [email protected] 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.

    View Slide

  4. @ondrejsika [email protected] sika.io
    History of Deployments
    - Manual deployments on physical machines
    - Deployments to hostings or virtual servers
    - Docker deployments
    - Kubernetes deployments
    - Serverless deployments

    View Slide

  5. @ondrejsika [email protected] sika.io
    What is ZEIT
    Zero config serverless platform

    View Slide

  6. @ondrejsika [email protected] 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)

    View Slide

  7. @ondrejsika [email protected] sika.io
    Setup ZEIT
    Sign up on https://zeit.co using Github, Gitlab, Bitbucket or email

    View Slide

  8. @ondrejsika [email protected] sika.io
    Sign to ZEIT
    Just call `now`and confirm sign in from email.

    View Slide

  9. @ondrejsika [email protected] sika.io
    Zero Config Deployments
    Just call `now` from and your
    project will be deployed.

    View Slide

  10. @ondrejsika [email protected] 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.

    View Slide

  11. @ondrejsika [email protected] 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.

    View Slide

  12. @ondrejsika [email protected] sika.io
    Example Node Function
    module.exports = (req, res) => {
    res.send(`Hello from Node JS!`);
    };

    View Slide

  13. @ondrejsika [email protected] 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!")
    }

    View Slide

  14. @ondrejsika [email protected] 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())

    View Slide

  15. @ondrejsika [email protected] sika.io
    ZEIT Smart CDN
    - Static files are cached on 32 edge locations (multiple cloud providers)
    - Lambdas are in closest AWS region

    View Slide

  16. @ondrejsika [email protected] 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`

    View Slide

  17. @ondrejsika [email protected] 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 1.2.3.4`
    - `now dns add example.com @ MX mail.example.com 99.`

    View Slide

  18. @ondrejsika [email protected] 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

    View Slide

  19. @ondrejsika [email protected] 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 = "1.2.3.4"
    type = "A"
    }

    View Slide

  20. @ondrejsika [email protected] sika.io
    Example Static Deployment

    View Slide

  21. @ondrejsika [email protected] sika.io
    Example Next.js Deployment

    View Slide

  22. @ondrejsika [email protected] sika.io
    Example Lambda Deployment

    View Slide

  23. @ondrejsika [email protected] sika.io
    Deployment Configuration
    You can create file `now.json` to provide following configuration:
    - Routes
    - Environment Variables (for Lambdas & build)
    - Redirects
    - Headers
    - ...

    View Slide

  24. @ondrejsika [email protected] sika.io
    Example Deployment with Routes

    View Slide

  25. @ondrejsika [email protected] sika.io
    Now Dev
    You can run deployment in development mode `now dev` and ZEIT will
    automatically sync your changes.

    View Slide

  26. @ondrejsika [email protected] sika.io
    Github Integration
    If you enable Github integration every commit will be deployed and every
    push into master will be production deployment.

    View Slide

  27. @ondrejsika [email protected] sika.io
    ZEIT Pricing
    - Free for small & hobby projects
    - Unlimited deployments (Pro plan) for 20 USD / month
    See pricing at https://zeit.co/pricing

    View Slide

  28. @ondrejsika [email protected] sika.io
    DEMO TIME

    View Slide

  29. @ondrejsika [email protected] 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/

    View Slide

  30. @ondrejsika [email protected] sika.io
    sika.link/if20-zeit

    View Slide

  31. @ondrejsika [email protected] sika.io
    sika.link/if20-zeit

    View Slide

  32. @ondrejsika [email protected] sika.io
    Thank you & Questions
    Ondrej Sika
    email: [email protected]
    www: https://sika.io, https://ondrej-sika.cz
    twitter: @ondrejsika
    linkedin: /in/ondrejsika/
    Sources: https://sika.link/if20-zeit

    View Slide