Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

@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.

Slide 4

Slide 4 text

@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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

@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)

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

@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.

Slide 11

Slide 11 text

@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.

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

@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!") }

Slide 14

Slide 14 text

@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())

Slide 15

Slide 15 text

@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

Slide 16

Slide 16 text

@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`

Slide 17

Slide 17 text

@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.`

Slide 18

Slide 18 text

@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

Slide 19

Slide 19 text

@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" }

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

@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 - ...

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

@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.

Slide 27

Slide 27 text

@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

Slide 28

Slide 28 text

@ondrejsika [email protected] sika.io DEMO TIME

Slide 29

Slide 29 text

@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/

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

@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