1 of 77

Instant Deploys

Using

Pycon Pakistan 2019

Mashhood Rastgar

@mashhoodr

2 of 77

Hello!

I am Mashhood.

I lead the engineering team at Sastaticket.pk and am the lead conference organiser for Pycon Pakistan 2019. Also a Google Developer Expert.

2

3 of 77

What is serverless?

4 of 77

Let’s define the problem.

Managing infrastructure is hard!

Deployment is an important part of app development.

You can have a single huge deployment (and single huge failure)

Once in production, you need to scale.

Can be scaled vertically or horizontally.

5 of 77

Can we do better?

A developer is mainly focused on building the product. Managing devops becomes a distraction.

#pyconpk

6 of 77

Microservices?

Better, but not quite there.

7 of 77

But...

We are still dependant on managing servers

And this requires effort, resources and expertise.

8 of 77

Serverless of Present

9 of 77

What is FaaS?

10 of 77

Every provider supports it.

11 of 77

FaaS has issues

Starting from breaking your whole app down into functions, restricted environments and limits on execution environments.

#pyconpk

12 of 77

Google Cloud Run

13 of 77

Containers

14 of 77

Docker

15 of 77

What are containers?

How do I deploy them?

Goal: to isolate an application and its dependencies into a self-contained unit that can run anywhere.

Docker is the most common way of running building and running containers.

16 of 77

Virtual Machine

Containers

17 of 77

Kubernetes Overview

Helps with deploying your code

Google backed tool announced in 2014.�

It is an open-source container-orchestration system for automating application deployment, scaling, and management.

What if we did not have to manage Kubernetes?

18 of 77

Google Cloud Run

Cloud Run is a managed compute platform that automatically scales your stateless containers.

#pyconpk

19 of 77

Why Google Cloud Run?

  • Container to production in seconds
  • Natively serverless
  • Any language, any library, any binary
  • Process web traffic or asynchronous events
  • Integrated logging and monitoring�….

20 of 77

Let’s try it out!

21 of 77

22 of 77

23 of 77

24 of 77

25 of 77

26 of 77

Next up, create an image

27 of 77

28 of 77

Setup and deploy to GCP

29 of 77

30 of 77

31 of 77

Can I automate this?

32 of 77

Github Actions to rescue!

  • A beta service, which allows you to run scripts on different events
  • You can automate your CI/CD pipeline using it
  • Has predefined plugins to speed up the process
  • Is free (for the moment)

33 of 77

Configuring the Action

  • Need to add a YAML config file
  • We have 4 main steps:
    • Authenticate
    • Build the image
    • Upload the image
    • Deploy to Cloud Run
  • Tutorial: http://bit.ly/cloudrun-githubaction

34 of 77

35 of 77

36 of 77

37 of 77

38 of 77

39 of 77

Push to master...

40 of 77

41 of 77

42 of 77

Summary

  • Setup a simple Django API
  • Setup Docker for the project so its containerized
  • Setup gcloud cli to deploy the code
  • Deployed the code to Google Cloud Run
  • Automated code deployments using Github Actions

43 of 77

Thank You!

#pyconpk

Mashhood Rastgar

GDE Web / Angular

@mashhoodr

Slides: http://bit.ly/pyconpk19-gcloud-slides

Code: http://bit.ly/pyconpk19-gcloud-demo

44 of 77

45 of 77

46 of 77

47 of 77

Colors & Fonts

48 of 77

Google Sans 104px

Google Sans 64px

Google Sans 40px

Google Sans 30px

Color

#4285f4

#34a853

#fbbc05

#ea4335

Typography

#202124

#FFA65C

#D65BAD

#2254AF

#2DC4C0

#F8F9FA

#D2E3FC

#CEEAD6

#FEEFC3

#FAD2CF

49 of 77

Template Slides Below

50 of 77

Headline goes here.

Subhead goes here.

This is body copy and it goes a little like this and Lorem ipsum dolor sit amet, consectetur adipiscing elit. This is body copy and it goes a little like this and Lorem ipsum dolor sit amet, consectetur adipiscing elit.

51 of 77

protected void onTryUpdate(int reason) throws RetryException {

// Do some awesome stuff

int foo = 15;

publishArtwork(new Artwork.Builder()

.title(photo.name)

.imageUri(Uri.parse(photo.image_url))

.viewIntent(new Intent(Intent.ACTION_VIEW,

Uri.parse(“http://500px.com/photo/" + photo.id)))

.build());

scheduleUpdate(System.currentTimeMillis() + ROTATE_TIME_MILLIS);

}

52 of 77

Headline goes here.

Subhead goes here.

Chart Data Source Info

End

Step

Step

Step

53 of 77

This is a headline

This is body copy and it goes �a little like this and Lorem ipsum �dolor sit amet, consectetur.

#GDESummit2019

54 of 77

This is a headline

This is body copy and it goes �a little like this and Lorem ipsum �dolor sit amet, consectetur.

#GDESummit2019

55 of 77

This is a headline

This is body copy and it goes �a little like this and Lorem ipsum �dolor sit amet, consectetur.

#GDESummit2019

56 of 77

This is a headline

This is body copy and it goes �a little like this and Lorem ipsum �dolor sit amet, consectetur.

#GDESummit2019

Half screen photo slide if �text is necessary

57 of 77

58 of 77

Thank You!

GDE Summit 2019

Speaker Name

GDE New York

@twitterhandle

59 of 77

Graphics & Icons

60 of 77

Device Library

Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem

Proprietary + Confidential

Proprietary + Confidential

61 of 77

Device Library

Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem

Proprietary + Confidential

Proprietary + Confidential

62 of 77

Device Library

Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem

Proprietary + Confidential

Proprietary + Confidential

63 of 77

Logo Library

Logos can be scaled to any size

Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem

Proprietary + Confidential

Proprietary + Confidential

64 of 77

Logo Library

Logos can be scaled to any size

Proprietary + Confidential

Proprietary + Confidential

65 of 77

Shape Library

Text

Text

Text

Text

Text

Text

Text

Text

Text

Text

Text

Text

Lorem Ipsum

Lorem Ipsum

Lorem Ipsum

Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem

Proprietary + Confidential

Proprietary + Confidential

66 of 77

Shape Library

Text

Text

Text

Text

Text

Text

Text

Text

Text

Text

75%

25%

Proprietary + Confidential

Proprietary + Confidential

67 of 77

Shape Library

30%

60%

63,096

54,537

36,910

33,492

12,038

A

B

C

D

E

24% of women

55% of men

75%

25%

Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem

Proprietary + Confidential

Proprietary + Confidential

68 of 77

Shape Library

Text

Text

Text

Proprietary + Confidential

Proprietary + Confidential

69 of 77

Charts & Maps

70 of 77

Icon Library

Modify color of the country by clicking on the icon and select fill from the menu

Proprietary + Confidential

Proprietary + Confidential

71 of 77

Icon Library

Modify color of the area by clicking on the icon and select fill from the menu

Lorem Ipsum

Lorem Ipsum

Lorem Ipsum

Lorem Ipsum

Proprietary + Confidential

Proprietary + Confidential

72 of 77

Icon Library

Modify color of the country by clicking on the icon and select fill from the menu

Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem

Proprietary + Confidential

Proprietary + Confidential

73 of 77

Icon Library

Modify color of the state by clicking on the icon and select fill from the menu

Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem

Proprietary + Confidential

Proprietary + Confidential

74 of 77

Icon Library

  • Modify color of the icon by clicking on the icon and select fill from the menu
  • Icons can be scaled to any size

Accessibility

Expand

Late

Credit card

Extension

Thumb Up

Remove

Verified

Q&A

Finance

Android

Turn in

Trash

Actions

Download

History

Store

List

Wallet

Announcement

Backup

Document

Favorite 1

Open

Home

Print

Swap

Account

Ratio

Tag

Server

Favorite 2

Grade/rate

Lock

Language

Receipt

Add shopping

Chart

Bug

Event

Find Page

Page view

Basket

Time

Work

Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem

Proprietary + Confidential

Proprietary + Confidential

75 of 77

Icon Library

  • Modify color of the icon by clicking on the icon and select fill from the menu
  • Icons can be scaled to any size

Alarm

Assessment

Sync

Exit App

Movie

Visibility

Trolley

Open

Location

Settings

Assignment

Check

Explore

Thumb Down

Today

Perm Media

People

search

Airplane

Signal

Photo

Play 1

Block

Send

Smartphone

Style

Walk

Bluetooth

WiFi

Upload

Play 2

Email

Laptop

iPhone

Controls

Bike

Pie Chart

Money

Attachment

Video

Business

Chromebook

Security

Notification

Bus

Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem

Proprietary + Confidential

Proprietary + Confidential

76 of 77

Icon Library

  • Modify color of the icon by clicking on the icon and select fill from the menu
  • Icons can be scaled to any size

Developer

Write

Cloud

Audio

Key

Desktop Mac

Watch

Person

Car

Devices

Quote

Folder

Web Page

Archive

Desktop PC

Flag

World

Boat

Software

Emotion

Mic

Call

Cut

headphones

Camera

Education

Train

Weather

Link

Movie

Chart

Paste

Keyboard

TV

MMS

Subway

Hotel

Laundry

Location History

Layers

Offer

Map

Bar

Pizza

Web

Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem

Proprietary + Confidential

Proprietary + Confidential

77 of 77

Icon Library

  • Modify color of the icon by clicking on the icon and select fill from the menu
  • Icons can be scaled to any size

Cafe

Theatre

Gaming

Florist

Restaurant

Gas

Delivery

Hospital

Taxi

Print

Radio

Stream

Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem

Proprietary + Confidential

Proprietary + Confidential