Share
Embed
Scalable and Resilient Django with Kubernetes
A brief introduction to containers and Kubernetes, and how they can help you deploy your Django application in a scalable and resilient fashion.
Harish Narayanan
March 15, 2016
Transcript
17 slides
-
Scalable and Resilient Django with Kubernetes Harish Narayanan @copingbear https://harishnarayanan.org/writing/kubernetes-django/
https://github.com/hnarayanan/kubernetes-django -
Traditional VMs to the rescue! ������� ��� ������� ��������� ���������
������� ������ �������� ������������ ��� ������ ������ ���� Layout of a non-trivial Django application -
Traditional VMs to the rescue! ������ ������ ������� ��� �������
��������� ��������� ������� ������ �������� ������������ ��� ������ ������ ���� All pieces making up the app on a single machine -
Traditional VMs to the rescue! �������� ������ ����������� ������ �
����������� ������ � ����������� ������ � ���� �������� ������� �������� ������������ ��� ������� ��������� ��� ��� ������� ��������� ��� ��� ������� ��������� ��� ��� ������ ������� ���� ���� ���� ���� ������ ������ Running many instances of the app, talking to a single database -
… but they have their own problems too • It’s
annoying to provision, setup and keep up-to-date one server for each component • You generally have poor resource utilisation because you’re setup to handle peak load • There is poor resource isolation if multiple components share a server -
What if we could shift our attention from managing servers
to simply running the pieces of our app? ���� � ���� � ���� � ������� �������� ������������ ��� ������� ��������� ��� ��� ������� ��������� ��� ��� ������� ��������� ��� ���������� ���� ���� �������� ���� ���� ���� ���� ������� �������� ������� ������� ������� ���� The application running on an abstract collection of resources -
A brief look at Docker containers docker build -t container:tag
. docker push container:tag Docker Architecture A Dockerfile for Django (Gunicorn) -
Now we just need to ensure that the containers are
running and talking to one another ���� � ���� � ���� � ������� �������� ������������ ��� ������� ��������� ��� ��� ������� ��������� ��� ��� ������� ��������� ��� ���������� ���� ���� �������� ���� ���� ���� ���� ������� �������� ������� ������� ������� ���� The application running on an abstract collection of resources -
This is exactly what Kubernetes does! • Kubernetes is an
open-source system for managing clusters and deploying “containerised” applications • Project spearheaded by Google, and written in Go • http://kubernetes.io https://github.com/kubernetes/kubernetes -
You control Kubernetes via an elegant REST API ���������� ������
���������� ���� � ���������� ���� � ������ ��������� ��� ������ ��������� ������� ������� ���������� ������� ���� ������ ���������� ������ ���������� Simplified architecture of Kubernetes -
• Building and publishing of Docker containers • Provisioning of
a Kubernetes cluster and monitoring it • Deploying our app and database (pods, labels, replication controllers, services) • Resilience to failure • Scaling and rolling updates • Not seen today: Secrets, Persistent Volumes and Claims, Static Assets to CDN (but are/will be in demo repo!) Demo: Deploying our app with this new toolset, and things we could see along the way -
Some closing thoughts • Philosophical shift from managing servers to
running services ideally • Setup of a Kubernetes cluster is non-trivial and the experience is heavily dependent on the capabilities of the underlying provider (GCP, AWS, Others) • Do play around to gauge if complexity is worth it • Try 1.2 (any day now!) for improved feature set, e.g. easier Secrets and Horizontal Auto-Scaling