Day 84 : Project 5 - Netflix Clone on Kubernetes

Day 84 : Project 5 - Netflix Clone on Kubernetes

ยท

3 min read

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.

Pre-requisites

  1. Create an EC2 instance with t2.medium configuration in the AWS management console.

  1. Install docker in the EC2 instance. Check the running status in the server.

  1. Install kubernetes in the EC2 instance along with kubectl utility in the server. You can follow my previous Kubernetes blog in the below link:-

    https://prathmeshh.hashnode.dev/day-31-launching-your-first-kubernetes-cluster-with-nginx-running

  2. Check the kubectl installation status in the server.

Project steps

  1. Get code from GitHub and clone in the EC2 instance.

  1. Build Docker Image: Once you have cloned the repository, navigate to the project directory and locate the Docker file. Ensure that the Dockerfile specifies the necessary dependencies and configurations for your Netflix Clone web application. Build the Docker image using the following command:
docker build -t chandreshpatle28/netflix-clone .
  1. Docker run:
docker run -d chandreshpatle28/netflix-clone

  1. Login to your docker hub and push the image using the below command
docker push prathmesh/netflix-clone:latest

  1. Verify and check whether the image is pushed or not.

  1. Now let's dive into the Kubernetes Deployment part.

      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: netflix-app
        labels:
          app: netflix-app
      spec:
        replicas: 2
        selector:
          matchLabels:
            app: netflix-app
        template:
          metadata:
            labels:
              app: netflix-app
          spec:
            containers:
              - name: netflix-app
                image: prathmeshdockerr/netflix-clone
                ports:
                  - containerPort: 80
    
     kubectl apply -f deployment.yml
    

  2. Now service part:

      apiVersion: v1
      kind: Service
      metadata:
        name: netflix-app
        labels:
          app: netflix-app
      spec:
        type: NodePort
        ports:
        - port: 80
          targetPort: 80
          nodePort: 30007
        selector:
          app: netflix-app
    
      kubectl apply -f service.yml
    

  3. Verify the Deployment:

      kubectl get deployment
      kubectl get pods
      kubectl get service netflix-app
    

  4. Access the Netflix Clone App:

    Check with the Public URL and we can now see the Netflix APP running on the server.

    Make sure you added Custom TCP Rule 30007 on the worker node in the security group.

    With the inbound rule added, the Netflix Clone app should now be accessible via <worker_node_external_ip>:30007 in your web browser.

Conclusion

Deploying a Netflix clone on Kubernetes showcases the power and flexibility of container orchestration. By following this project, youโ€™ve learned how to containerize a web application, deploy it on Kubernetes, and leverage Kubernetes tools for monitoring and management. This project not only highlights the technical benefits of using Kubernetes but also provides a solid foundation for deploying and managing containerized applications at scale. Whether you're a seasoned developer or a Kubernetes novice, this hands-on experience is invaluable for understanding the modern landscape of application deployment and management.

I'm confident that this article will prove to be valuable, helping you discover new insights and learn something enriching .

thank you : )

ย