<aside> 💬 Discussion on reddit

</aside>

Sept 05, 2021 Rahul Sharma

In this tutorial, we will create a fully dockerized django app locally (connected to a remote Cloud SQL postgres instance) and deploy it to Cloud Run with CI/CD, credentials management, and static file hosting.

articles.png

Introduction

I recently had to deploy a django app on GCP and there were quite a few options:

  1. Google Cloud Functions (~ AWS Lambda)
  2. Google App Engine (~ AWS Beanstalk)
  3. Google Compute Engine (~ AWS EC2)
  4. Google Cloud Run
  5. Google Kubernetes Engine (~ AWS EKS)

Coming from AWS, I found App Engine to be the closest to deploying an API service as it's similar to how Beanstalk works. I also considered Cloud Functions (similar to AWS Lambda) but my use case was slightly complex with the need of defining models, performing migrations, and so on.

GKE was another option but I wanted to focus on launching the app first before worrying about K8s artifacts. It finally came down to App Engine and Cloud Run.

App Engine

download.png

  1. Fully managed PaaS from GCP (launched in 2008), battle tested for deploying planet-scale applications
  2. Supports Python, node, and other popular runtimes
  3. Code is stored in a Cloud Storage bucket
  4. Auto scaling based on traffic
  5. Out-of-the-box firewall, traffic splitting, and other key features

Cloud Run

download (1).png

  1. New GCP offering (launched in 2019) that brings the best of both worlds - serverless and containers
  2. Supports any runtime/language/library
  3. Apps are deployed as containers that can scale up or down based on configuration
  4. Code is stored as images on GCR that can be ported to GKE
  5. Integrated logging, monitoring, and CI/CD

<aside> 💡 Although both have a lot of overlap in terms of features, it's the container aspect of writing and running applications that made me select Cloud Run in the end.

</aside>