Skip to content
Home » How to deploy a Django application to a k3s cluster — Part 1, Planning and Investigation

How to deploy a Django application to a k3s cluster — Part 1, Planning and Investigation

Last year, I was re-platforming AceIelts from VPC to AWS Cloud powered Docker Swarm instance.

Stack Update Moving AceIelts.Pro to AWS

Before the end of 2021, I made a decision, to re-platform it to Oracle Cloud powered K8s cluster.

Before the plan, the history of AceIelts Tech Stacks

SectionOriginalAce Ielts Tech Stack in 2020Ace Ielts Tech Stack in 2021Description
ComputeVPS with 1g RamAWS EC2 t3a + 2g RamK8s cluster (26GB Ram in total)6 CPU Cores, about 200GB Storage
Data BaseMongoDB + PostgreSQLPostgreSQLPostgreSQLNo changes, a db backup and restore
PlatformVPSAWSOCI Oracl Cloud
Cost$5/month$8~10/monthFor now $0/monthThe OCI always free tier resources were used for building the K8s cluster
Deploysshdocker composedocker + k8s deployment/service/ingress configThrough private docker registry
Learning CurveEasy, but a lot of boring steps to do for every single deploymentEasy, simple CLI commands + GUI dashboard, CaproverVery DifficultK8s has a very steep learning curve, but it does offer very good flexibility and cloud native scalability
Tech stacks upgrade of Aceielts.pro in 2021

The original assuming of the cost for the tech stack in 2020 would be $8~10/month, actually it was about $14/month.

Part 1, Plan to re-platform AceIelts/Django Application

Why do you need to do another re-platform?

  • Learning K8s and Oracle Cloud, new technology is born everyday, from linux instance => docker => docker swarm => Kubernetes,
  • I can, yeah, this is another reason
  • Saving money, OCI always free resources are powerful enough for a k3s cluster, $14 dollars, it is like 2 or 3 coffees.
  • Easier for deployment, caprover is good enough, but k8s deployment seems easier, through k8s apply -f ...

How to deploy a Django Application(aceielts.pro) to K8s Cluster?

Prepare:

  • k8s cluster
  • docker image
  • docker registry (you might need a private registry if your application is not an open source app)
  • SSL Certificate, you need to config cert manager for managing it
  • domain name, in this case it is https://aceielts.pro

Issues during the re-platform

  • Ace Ielts container so big, this is an old problem, I didn’t pay a lot of attention for optimizing the container/image building for AceIelts.
  • Understand network/ingress/load balancing of K8s, this is the difficult part of k8s, it took me quite a while to understand the differences between NodePort, ClusterIP and LoadBalancer in k8s.

References

To be continued

  1. Backup all config and db data
  2. We need to prepare all resources above, each step might be time consuming
  3. Deploy the app
  4. Build a dashboard to monitor it.

Leave a Reply