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

How to deploy your Python Web App on Google Clo...

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. Google's Platform as a Service Runs on Google's Infrastructure Has

    support for multiple runtimes No Ops Has Standard and Flexible Environments
  2. 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
  3. 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>/
  4. 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:
  5. 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/
  6. Google Kubernetes Engine Google Kubernetes Engine Managed, production-ready environment for

    deploying containerized applications Easily get up and running with Kubernetes in no time
  7. 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.
  8. 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
  9. Pods Basic building blocks of Kubernetes. A pod is a

    collection of containers, storage and options dictating how the pod should run.
  10. 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.
  11. 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.
  12. 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.
  13. 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.
  14. 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.
  15. 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’
  16. 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.
  17. Event-driven serverless computing The simplest way to run your code

    in the cloud What are What are cloud cloud functions? functions?
  18. 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?
  19. 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?
  20. 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?
  21. How they work How they work Responds to events Cloud

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

    Triggers Cloud Pub/Sub Triggers Firebase Triggers