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 Agenda - Serverless Introduction - What is

    ZEIT - Setup ZEIT - Deployments - Examples - Static Website - Next.js Website - Go API (lambdas) - Pricing
  2. @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.
  3. @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
  4. @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)
  5. @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.
  6. @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.
  7. @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!") }
  8. @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())
  9. @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
  10. @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`
  11. @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.`
  12. @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
  13. @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" }
  14. @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 - ...
  15. @ondrejsika [email protected] sika.io Now Dev You can run deployment in

    development mode `now dev` and ZEIT will automatically sync your changes.
  16. @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.
  17. @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
  18. @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/
  19. @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