Slide 1

Slide 1 text

Scalable and Resilient Django with Kubernetes Harish Narayanan @copingbear https://harishnarayanan.org/writing/kubernetes-django/ https://github.com/hnarayanan/kubernetes-django

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

Platform as a Service to the rescue!

Slide 4

Slide 4 text

Platform as a Service to the rescue! … but they’re inflexible.

Slide 5

Slide 5 text

Traditional VMs to the rescue! ������� ��� ������� ��������� ��������� ������� ������ �������� ������������ ��� ������ ������ ���� Layout of a non-trivial Django application

Slide 6

Slide 6 text

Traditional VMs to the rescue! ������ ������ ������� ��� ������� ��������� ��������� ������� ������ �������� ������������ ��� ������ ������ ���� All pieces making up the app on a single machine

Slide 7

Slide 7 text

Traditional VMs to the rescue! �������� ������ ����������� ������ � ����������� ������ � ����������� ������ � ���� �������� ������� �������� ������������ ��� ������� ��������� ��� ��� ������� ��������� ��� ��� ������� ��������� ��� ��� ������ ������� ���� ���� ���� ���� ������ ������ Running many instances of the app, talking to a single database

Slide 8

Slide 8 text

… 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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

That’s the promise of containers and Kubernetes

Slide 11

Slide 11 text

A brief look at Docker containers docker build -t container:tag . docker push container:tag Docker Architecture A Dockerfile for Django (Gunicorn)

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

You control Kubernetes via an elegant REST API ���������� ������ ���������� ���� � ���������� ���� � ������ ��������� ��� ������ ��������� ������� ������� ���������� ������� ���� ������ ���������� ������ ���������� Simplified architecture of Kubernetes

Slide 15

Slide 15 text

• 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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

Questions? Harish Narayanan @copingbear https://harishnarayanan.org/writing/kubernetes-django/ https://github.com/hnarayanan/kubernetes-django