Member-only story
How to Deploy a Django Application With Kubernetes
Deploy a scalable Django app into a Kubernetes cluster

In this tutorial, we’ll deploy a containerized Django application with Kubernetes (K8s).
Django is a Python-based free and open-source web framework that follows the model–template–views architectural pattern.
Kubernetes, also known as K8s, is an open-source system for automating the deployment, scaling, and management of containerized applications.
Step 1 — Containerize our Application with Docker
Let’s create a new Django application:
$django-admin startproject djangokubernetesproject
Navigate to the djangokubernetesproject
directory:
$cd djangokubernetesproject
After that, we need to create a new Dockerfile
which Docker will use to build our container image:
$vim Dockerfile
Dockerfile:
FROM ubuntu:20.04RUN apt-get update && apt-get install -y tzdata && apt install -y python3.8 python3-pipRUN apt install python3-dev libpq-dev nginx -yRUN pip install django gunicorn psycopg2