Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scalable and Resilient Django with Kubernetes

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
Tweet

More Decks by Harish Narayanan

Other Decks in Technology

Transcript

  1. Traditional VMs to the rescue! ������� ��� ������� ��������� ���������

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

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

    ����������� ������ � ����������� ������ � ���� �������� ������� �������� ������������ ��� ������� ��������� ��� ��� ������� ��������� ��� ��� ������� ��������� ��� ��� ������ ������� ���� ���� ���� ���� ������ ������ Running many instances of the app, talking to a single database
  4. … 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
  5. 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
  6. A brief look at Docker containers docker build -t container:tag

    . docker push container:tag Docker Architecture A Dockerfile for Django (Gunicorn)
  7. 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
  8. 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
  9. You control Kubernetes via an elegant REST API ���������� ������

    ���������� ���� � ���������� ���� � ������ ��������� ��� ������ ��������� ������� ������� ���������� ������� ���� ������ ���������� ������ ���������� Simplified architecture of Kubernetes
  10. • 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
  11. 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