Deploying Python Web Apps on Google Cloud Kubernetes Engine with Terraform
Before you get started, you need to install environment binaries. In this example the first few steps illustrate how to setup and configure binaries on Mac OSX/Linux.
Stack used: Terraform, kubectl, YAML, Redis cluster, Python & Go Lang
Here what is needed before you get started.
- terraform executable
To use Terraform you will need to install it. HashiCorp distributes Terraform as a binary package. You can also install…
2. gcloud binaries
Installing Google Cloud SDK | Cloud SDK Documentation
This page contains instructions for choosing and maintaining a Cloud SDK installation. Cloud SDK runs on Linux, macOS…
Install and Set Up kubectl
The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use kubectl…
on mac using homebrew
$ brew install kubectl
Docker Desktop for Mac - Docker Hub
The fastest and easiest way to get started with Docker on Mac
4. Setup gcloud creds
5. It is time to write your declarative IAC code to define your GCP infrastructure provider.
6. Define your Kubernetes cluster tf declaration.
7. Initialize terraform:
8. Before apply dry run terraform with “plan” option
9. Apply myplan to continue
10. Set project name and get container authentication creds.
Deploying Redis cluster to GKE
11. Redis Master config:
12. Deploy redis master to GKE
13. Create Redis Master service
14. Redis Slave config:
Deploy slave pods and service
Deploying WebApp container to GKE
- Dockerfile (webApp)
2. Create docker tag, and push it to Google Cloud Registry (GCR).
3. WebApp deployment
pod declaration :
Testing Redis connection
Testing Python WebApp
Automate this into CI/CD pipelines or manually schedule
Check pod logs
Troubleshooting Kube service