Day 84-Project 5

2 min read

Cover Image for Day 84-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.

Steps

  1. Create a Netflix clone(in my case I created an HTML landing page which I have created)

    (GitHub link: https://github.com/sri766/netflix-clone-HTML.git)

  2. Build Dockerfile

     # Use a lightweight web server as a base image
     FROM nginx:alpine
    
     # Copy your HTML, CSS, and images folder to the web server's document root
     COPY index.html /usr/share/nginx/html
     COPY style.css /usr/share/nginx/html
     COPY images/ /usr/share/nginx/html/images/
    
     # Expose port 80 (default for HTTP) for web traffic
     EXPOSE 80
    
     # Start the web server when the container runs
     CMD ["nginx", "-g", "daemon off;"]
    
  3. Build Docker file

     docker build -t sri766/netflix-clone .
     docker run -d -p 8080:80 sri766/netflix-clone
    

  4. Minikube install- https://minikube.sigs.k8s.io/docs/start/

  5. Push to Docker hub

     docker push sri766/netflix-clone
    

  6. Create Deployment.yml file

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

  7. Create Service.yml file

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

  8. apply deployment and service

     kubectl apply -f deployment.yml
     kubectl apply -f service.yml
    

    you can check services, run kubectl get services

  9. Access to http://<minikube-ip>:<nodeport>

    you can get ip-address by running Minikube ip

    ans Nodeport is the port after the ":" in the ports listing in services

    Done!!๐Ÿ’•๐Ÿš€