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

How to deploy your Python Web App on Google Cloud Platform by James Mwai

Pycon ZA
October 11, 2018

How to deploy your Python Web App on Google Cloud Platform by James Mwai

The goal of this talk is to give a basic understanding of how you can configure and deploy your Python web app on various Google Cloud Platform services.

We will start by demonstrating how to setup and deploy a Python web app on both Standard and Flexible Google App Engine platforms. After that, we will show how to provision a Linux VM on Google Cloud to run a python web app. We will then explore how to package our Python web app into a docker image and deploy the same on Google Kubernetes Engine (GKE). Finally, we will explore Google Cloud Functions and how to write a serverless app in Python.

The audience for this talk is generally Python web developers and devops engineers.

Pycon ZA

October 11, 2018
Tweet

More Decks by Pycon ZA

Other Decks in Programming

Transcript

  1. Deploying your web Deploying your web app to Google Cloud

    app to Google Cloud
  2. About Me About Me Co-Founder/CTO Skygarden Co-Founder/CTO Skygarden Google Developer

    Expert for Cloud. Google Developer Expert for Cloud.
  3. App Engine Standard App Engine Flex Google Kubernetes Engine Google

    Cloud Functions Agenda
  4. Title Text Title Text

  5. Google's Platform as a Service

  6. Google's Platform as a Service Runs on Google's Infrastructure

  7. Google's Platform as a Service Runs on Google's Infrastructure Has

    support for multiple runtimes
  8. Google's Platform as a Service Runs on Google's Infrastructure Has

    support for multiple runtimes No Ops
  9. Google's Platform as a Service Runs on Google's Infrastructure Has

    support for multiple runtimes No Ops Has Standard and Flexible Environments
  10. Built-in Services Built-in Services Blob Storage

  11. Built-in Services Built-in Services Blob Storage Data Storage

  12. Built-in Services Built-in Services Blob Storage Data Storage Task Queueing

  13. Built-in Services Built-in Services Blob Storage Data Storage Task Queueing

    Pub/Sub
  14. Built-in Services Built-in Services Blob Storage Data Storage Task Queueing

    Pub/Sub Email
  15. Built-in Services Built-in Services Blob Storage Data Storage Task Queueing

    Pub/Sub Email Image manipulation
  16. Built-in Services Built-in Services Blob Storage Data Storage Task Queueing

    Pub/Sub Email Image manipulation Caching
  17. Built-in Services Built-in Services Blob Storage Data Storage Task Queueing

    Pub/Sub Email Image manipulation Caching
  18. Standard Standard Flexible Flexible

  19. Standard Standard - Specified runtimes; Java, Python, Go, Nodejs, PHP

    - No SSH debugging - Maximum request time 60 seconds - Cannot write to local disk - No background process - Can scale to 0 instances Flex Flex - Packages your app in Docker - Supports SSH debugging - Maximum request time 60 Minutes - You can write to local disk - Supports background process - Cannot scale to zero. Minimum 1 instance
  20. Project Structure Project Structure dispatch.yaml service3a.yaml service3b.yaml source files… service3/

    service2.yaml source files… service2/ service1.yaml source files… service1/ <application root>/
  21. service.yaml service.yaml service: my-service runtime: python35 api_version: 1 instance_class: F2

    automatic_scaling: target_cpu_utilization: 0.65 min_instances: 5 max_instances: 100 min_pending_latency: 30ms # default max_pending_latency: automatic max_concurrent_requests: 50 handlers:
  22. Cloud SDK Cloud SDK The main tool for interacting with

    Google Cloud Platform gcloud Tool - Auth, Config, Deploy gsutil Tool - Storage bq Tool - Big Query kubectl Tool - Kubernetes https://cloud.google.com/sdk/
  23. Demo Demo

  24. GKE GKE

  25. Google Kubernetes Engine Google Kubernetes Engine Managed, production-ready environment for

    deploying containerized applications
  26. Google Kubernetes Engine Google Kubernetes Engine Managed, production-ready environment for

    deploying containerized applications Easily get up and running with Kubernetes in no time
  27. Google Kubernetes Engine Google Kubernetes Engine Managed, production-ready environment for

    deploying containerized applications Easily get up and running with Kubernetes in no time No need to install, manage, and operate your own Kubernetes clusters.
  28. Google Kubernetes Engine Google Kubernetes Engine Managed, production-ready environment for

    deploying containerized applications Easily get up and running with Kubernetes in no time No need to install, manage, and operate your own Kubernetes clusters. Scale effortlessly to thousands of machines
  29. Concepts Concepts

  30. Docker Docker

  31. Container Registry Container Registry

  32. Kubernetes Kubernetes

  33. Kubernetes Cluster

  34. Pods Basic building blocks of Kubernetes.

  35. Pods Basic building blocks of Kubernetes. A pod is a

    collection of containers, storage and options dictating how the pod should run.
  36. Pods Basic building blocks of Kubernetes. A pod is a

    collection of containers, storage and options dictating how the pod should run. Pods are mortal and are expected to die in order to rebalance the cluster or to upgrade them.
  37. Pods Basic building blocks of Kubernetes. A pod is a

    collection of containers, storage and options dictating how the pod should run. Pods are mortal and are expected to die in order to rebalance the cluster or to upgrade them. Each pod has a unique IP in the cluster and can listen on any ports required for your application.
  38. Deployment Deployment A Deployment is a copy of a replica

    set and pods.
  39. Deployment Deployment A Deployment is a copy of a replica

    set and pods. If a deployment changes, the cluster will automatically create a new replica set with the new version and will automatically live to upgrade your pods.
  40. Deployment Deployment A Deployment is a copy of a replica

    set and pods. If a deployment changes, the cluster will automatically create a new replica set with the new version and will automatically live to upgrade your pods. A deployment can also be rolled back to a previous version if there is an error.
  41. Services Services Services enable discoverability of your pods from within

    and outside your cluster
  42. Services Services Services enable discoverability of your pods from within

    and outside your cluster A service uses a combination of labels and selectors to match the pods that it’s responsible for and then will balance over the to.
  43. Services Services Services enable discoverability of your pods from within

    and outside your cluster A service uses a combination of labels and selectors to match the pods that it’s responsible for and then will balance over the to. Services can load balance inside a cluster using a service of type ‘ClusterIP’ or expose it to the outside world using a ‘NodePort’
  44. Services Services Services enable discoverability of your pods from within

    and outside your cluster A service uses a combination of labels and selectors to match the pods that it’s responsible for and then will balance over the to. Services can load balance inside a cluster using a service of type ‘ClusterIP’ or expose it to the outside world using a ‘NodePort’ Creating a service automatically creates a DNS entry, which allows for service discovery inside the cluster.
  45. Demo Demo

  46. Cloud Functions Cloud Functions

  47. Event-driven serverless computing What are What are cloud cloud functions?

    functions?
  48. Event-driven serverless computing The simplest way to run your code

    in the cloud What are What are cloud cloud functions? functions?
  49. Event-driven serverless computing The simplest way to run your code

    in the cloud Automatically scales, highly available and fault tolerant What are What are cloud cloud functions? functions?
  50. Event-driven serverless computing The simplest way to run your code

    in the cloud Automatically scales, highly available and fault tolerant No servers to provision, manage, patch or update What are What are cloud cloud functions? functions?
  51. Event-driven serverless computing The simplest way to run your code

    in the cloud Automatically scales, highly available and fault tolerant No servers to provision, manage, patch or update Pay only while your code runs What are What are cloud cloud functions? functions?
  52. How they work How they work Responds to events Cloud

    Services Emit events Writes back Invokes other services Other APIs Cloud Functions
  53. Example Use cases Example Use cases HTTP Triggers Cloud Storage

    Triggers Cloud Pub/Sub Triggers Firebase Triggers
  54. Python3.7 Node.js 6 Node.js 8 Support Support

  55. Demo Demo

  56. @jmwai @jmwai