Day 84 of 90 Days of DevOps Challenge: Deploying a Netflix Clone Web Application on Kubernetes
Table of contents
As the world moves towards microservices and containerization, Docker Swarm provides a straightforward platform for orchestrating and managing containerized applications. In this blog post, we will explore how to deploy a Netflix clone web application using Docker Swarm, demonstrating its capabilities for high availability, scalability, and simplicity.
Project Overview
This project aims to deploy a Netflix clone web application on a Docker Swarm cluster. We will create Docker images for the web application and its dependencies, then deploy these images using Docker Swarm services. With Swarm’s built-in features, we can ensure the application remains highly available and scalable as demand increases.
Key Components
- Docker Swarm
Docker Swarm is Docker’s native clustering and orchestration tool. Its features include:
Automatic Scaling: Automatically adjusts the number of containers based on desired replicas.
Load Balancing: Distributes traffic across containers.
Self-Healing: Automatically restarts containers when they fail.
- Docker
Docker is a platform for developing, shipping, and running applications in containers. For this project, we will create Docker images of the Netflix clone web application.
- Docker Swarm Manager
In Docker Swarm, the manager node coordinates the cluster, while worker nodes run the containerized applications.
Implementation Steps
Step 1: Set Up Your Docker Swarm Environment
Provision Nodes: Go to your AWS portal (or preferred cloud provider) and create three instances:
Swarm-manager
Swarm-worker1
Swarm-worker2
Configure Security: For each instance, update inbound rules to allow:
Custom TCP — 2377 — Anywhere IPv4 (for Swarm management traffic)
Custom TCP — 8001 — Anywhere IPv4 (for accessing the web app)
Step 2: Install Docker
Install Docker with the Docker engine on all three nodes. Follow Docker’s installation instructions if needed.
Step 3: Initialize Docker Swarm
On the Swarm Manager Node: Initialize Docker Swarm by running:
sudo docker swarm init
This will create an empty Swarm and generate a command with a join token.
On Worker Nodes: Paste and run the join command to add them as workers in the Swarm cluster.
Step 4: Verify the Swarm Cluster
On the manager node, check the status of all nodes in the Swarm by running:
docker node ls
Step 6: Deploy the Application Using Docker Swarm
On the manager node, create a Swarm service to deploy the Netflix clone:
sudo docker service create --name django-app-service --replicas 3 --publish 8001:8001 trainwithshubham/react-django-app:latest
This command deploys three replicas and exposes the application on port 8001.
Step 7: Verify the Deployment
Check Service Status: Run the following command to confirm the service is up:
sudo docker service ls
View Running Containers: Confirm that containers are running on all nodes:
sudo docker ps
Step 8: Access the Application
Retrieve Node IP: Access the application by using the IP address of any node, followed by port 8001:
http://<any-node-ip>:8001
Conclusion
Deploying a Netflix clone web application on Docker Swarm showcases the power and flexibility of Docker's orchestration capabilities. By leveraging Docker Swarm’s features like high availability, scalability, and simplicity, you can manage containerized applications efficiently. This project provides practical insight into deploying applications using Docker Swarm in a production-ready environment.