Using Kubernetes to deploy Django in GCP
-
Upload
walter-liu -
Category
Software
-
view
753 -
download
3
Transcript of Using Kubernetes to deploy Django in GCP
![Page 1: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/1.jpg)
USING KUBERNETES TO DEPLOY DJANGO IN GCP
BY WALTER
![Page 2: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/2.jpg)
INTRODUCTION
ME
▸ FB: Walter Liu
▸
▸
▸ /
▸
![Page 3: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/3.jpg)
Based on a true story
No computer was harmed during the process.
![Page 4: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/4.jpg)
GAME GO PRODUCTION TOMORROW. LET’S INCREASE SIZE OF THE CLUSTER
REAL STORY
![Page 5: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/5.jpg)
ASIA-EAST1-C IS FULL.
REAL STORY
![Page 6: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/6.jpg)
WHAT? MY WHOLE CLUSTER IS IN ASIA-EAST1-C !!!
REAL STORY
![Page 7: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/7.jpg)
K8S + GCP COME TO RESCUE
![Page 8: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/8.jpg)
USING KUBERNETES
K8S + GCP
▸ Infrastructure as code
▸ Record cluster creation steps
▸ Automation scripts for daily jobs
▸ Note: Puppet/Chef/Ansible/Saltstack is not needed for current application
▸ GCP: easy K8S hosting and cluster is free under 5 VMs.
![Page 9: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/9.jpg)
USING KUBERNETES
USED K8S COMPONENTS
▸ POD
▸ Deployment
▸ Statefulset
▸ Secrets/ConfigMap
▸ Endpoints
▸ Service
▸ Ingress
![Page 10: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/10.jpg)
USING KUBERNETES
POD
▸ one POD could contain multiple containers.
▸ Nginx+uwsgi+django
▸ cloudsql-proxy
▸ twemproxy
▸ telegraf
▸ Share
▸ IP
▸ networking space
▸ shared volumes
![Page 11: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/11.jpg)
USING KUBERNETES
DEPLOYMENT
▸ POD template
▸ Desired state instead of changing property
▸ replicas: number of POD
▸ image: the container image
▸ the version of the application
▸ health check for auto-restart POD
![Page 12: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/12.jpg)
USING KUBERNETES
STATEFULSET
▸ Like deployment with static POD name
▸ prod-nimo-kvs-0
▸ prod-nimo-kvs-1
▸ Usage: Sharded service
▸ redis
▸ memcached
▸ Other usage: static volume
![Page 13: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/13.jpg)
USING KUBERNETES
SECRETES/CONFIGMAP
▸ Usage: environment variables for Django settings
▸ No git for secretes
![Page 14: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/14.jpg)
USING KUBERNETES
ENDPOINTS
▸ Usage: IPs of external resources
![Page 15: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/15.jpg)
USING KUBERNETESTEXT
SERVICE
▸ K8S Internal service
▸ External service
▸ TCP Load Balancer
▸ [optional] Firewall
▸ *Global Load Balancer
▸ with Ingress
![Page 16: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/16.jpg)
USING KUBERNETES
INGRESS
▸ Global Load Balancer
▸ No firewall ability
![Page 17: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/17.jpg)
Ingress
Service
Deployment/POD Statefulset/POD GCP Cloud SQL
Service Service/Endpoints
![Page 18: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/18.jpg)
USING KUBERNETES
K8S HAS NO CRONTAB
▸ Use celery
▸ Google App Engine
![Page 19: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/19.jpg)
USING KUBERNETES
K8S+GCP LOAD BALANCER
▸ GCP Global Load Balancer
▸ GCP TCP Load Balancer
▸ GCP Internal Load Balancer (1.7 beta support)
▸ K8S Internal Load Balancer
![Page 20: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/20.jpg)
USING KUBERNETES
CLUSTER CREATION STEPS
▸ kubectl create -f web_secretes.yaml
▸ kubectl apply -f cache_stateful_set.yaml
▸ ./titan_control deploy prod
▸ Like => kubectl apply -f prod_web_deploy.yaml
▸ kubectl apply -f service.yaml
▸ kubectl apply -f ingress.yaml
▸ gsutil mb -l asia gs://static.example.com
![Page 21: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/21.jpg)
NEW CLUSTER CREATED IN 30 MINUTES
REAL STORY
![Page 22: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/22.jpg)
OTHERS
TEMPLATING ▸ I use Python Jinjia to do K8S templating.
▸ Someone had suggested me HELM.
▸ Show Templating example.
![Page 23: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/23.jpg)
![Page 24: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/24.jpg)
WE ARE HIRING
▸
▸
▸ 8
▸ MIS/
▸ PHP
FB GCPUG + Walter Liu
![Page 25: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/25.jpg)
▸
![Page 26: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/26.jpg)
▸ PHP
▸ Docker
▸ Kubernetes
▸ Google Cloud
▸ git
▸ mix of Scrum/Kanban
▸ Trello/Slack
![Page 27: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/27.jpg)
PICAXXXX@GMAIL DOT COM
Walter Liu
![Page 28: Using Kubernetes to deploy Django in GCP](https://reader030.fdocuments.us/reader030/viewer/2022020314/5a6d52d17f8b9ac2418b5cbb/html5/thumbnails/28.jpg)
Q & A