Day 84 - Deploying a Netflix Clone on Kubernetes for High Availability and Scalability 🚀📊

Day 84 - Deploying a Netflix Clone on Kubernetes for High Availability and Scalability 🚀📊

Project-5

\=========

Project Description

The project involves deploying a Netflix clone web application on a Kubernetes cluster, a popular container orchestration platform that simplifies the deployment and management of containerized applications. The project will require creating Docker images of the web application and its dependencies and deploying them onto the Kubernetes cluster using Kubernetes manifests. The Kubernetes cluster will provide benefits such as high availability, scalability, and automatic failover of the application. Additionally, the project will utilize Kubernetes tools such as Kubernetes Dashboard and kubectl to monitor and manage the deployed application. Overall, the project aims to demonstrate the power and benefits of Kubernetes for deploying and managing containerized applications at scale. 🚀

Welcome to Day 84 of the #90DaysOfDevOps challenge! Today, we'll deploy a Netflix clone web application on a Kubernetes cluster. This hands-on project will help you understand the power of container orchestration with Kubernetes. Let's dive in! 🌊

Pre-requisites 🛠️

  1. Install Docker: Follow the Official Docker Documentation to install Docker on your operating system. 🐳

  2. Install Kubernetes and Kubectl: You can install Kubernetes and kubectl using Minikube or follow the steps from my previous Kubernetes blog or the official Minikube documentation. ☸️

     sudo apt update
     sudo apt install apt-transport-https curl
     sudo snap install kubectl --classic
     curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
     sudo install minikube-linux-amd64 /usr/local/bin/minikube
     sudo apt-get install docker.io
     minikube start --vm-driver=docker
     sudo usermod -aG docker $USER
     sudo chown $USER /var/run/docker.sock
     minikube status
     minikube start
    

Project Steps 📋

  1. API Key Configuration: If the Netflix Clone web application requires an API key to fetch data, follow the instructions in the README.md file of the GitHub repository to configure the API key while creating the Docker container. 🔑

  2. Clone the Netflix Clone Repository: Navigate to the directory where you want to clone the Netflix Clone repository from GitHub. Use the following command📂:

     git clone https://github.com/crazy-man22/netflix-clone-react-typescript.git
    
  3. Build Docker Image: Once you've cloned the repository, navigate to the project directory and locate the Dockerfile. Ensure that the Dockerfile specifies the necessary dependencies and configurations for your Netflix Clone web application. Build the Docker image using the command🛠️:

     docker build --build-arg TMDB_V3_API_KEY=your_api_key_here -t netflix-clone .
    
  4. Push Docker Image to DockerHub: To push the Docker image to DockerHub, you need to have a DockerHub account and repository set up. Tag the image with your DockerHub username and repository name, and then push it using the following commands🌐:

     docker tag netflix-clone:latest your_dockerhub_username/netflix-clone:latest
     docker push your_dockerhub_username/netflix-clone:latest
    
  5. Create Kubernetes Deployment: Create a Kubernetes Deployment manifest file (deployment.yaml) that describes the desired state of the Netflix Clone application. Here is an example:

     apiVersion: apps/v1
     kind: Deployment
     metadata:
       name: netflix-clone-deployment
     spec:
       replicas: 3
       selector:
         matchLabels:
           app: netflix-clone-app
       template:
         metadata:
           labels:
             app: netflix-clone-app
         spec:
           containers:
             - name: netflix-clone-container
               image: your_dockerhub_username/netflix-clone:latest
               ports:
                 - containerPort: 80
    

    Apply the deployment using the command📜:

     kubectl apply -f deployment.yaml
    
  6. Verify Deployment and Pods: Ensure the deployment and pods are successfully created with the following commands✅:

     kubectl get deployments
     kubectl get pods
    

  7. Create Kubernetes Service: Create a Kubernetes Service manifest file (service.yaml) to expose the Netflix Clone application to the outside world. The service will use a LoadBalancer type. Here's an example:

     apiVersion: v1
     kind: Service
     metadata:
       name: netflix-clone-service
     spec:
       type: LoadBalancer
       selector:
         app: netflix-clone-app
       ports:
         - protocol: TCP
           port: 80
           targetPort: 80
           nodePort: 30080
    

    Apply the service using the command🌍:

     kubectl apply -f service.yaml
    
  8. Verify the Service: Check if the service has been successfully created👀:

     kubectl get svc
    

  9. Testing Website Accessibility: Use the curl command to check if the application is accessible. Open a terminal and run:

     minikube service netflix-clone-service --url
    

    Copy the provided URL and use the curl command to query the app 🌐:

     curl -L http://<your-minikube-service-ip-address>:30080
    

  10. Access the Netflix Clone Web Application: Create a bridge between Minikube and your machine using the tunnel command:

    kubectl get svc
    minikube tunnel
    

    Open a second terminal to check the status of the service again. Use the External IP address and the port to access your app. You should now see the Netflix Clone web application running on the Kubernetes cluster. 🎉


Congratulations on completing Day 84 of the #90DaysOfDevOps Challenge! 🎊 Today, we successfully deployed a Netflix clone web application on a Kubernetes cluster, leveraging the power of container orchestration to simplify our deployment process. Kubernetes' high availability, scalability, and automatic failover ensure our application is robust and resilient. Tomorrow, we'll continue our #90DaysOfDevOps challenge with a new exciting project. Stay tuned! 🚀

Did you find this article valuable?

Support Nilkanth Mistry by becoming a sponsor. Any amount is appreciated!