This project demonstrates a simple client-server application built with Express, deployed in two different environments:
- Virtual Machines for a traditional setup.
- Kubernetes Cluster using Minikube for containerized deployment.
- Client: Deployed and served on a virtual machine.
- Server: Hosted on a second virtual machine.
- Networking: Configured both virtual machines to communicate over the same network, enabling the client to interact with the server.
-
Setup the Hypervisor:
- Used Boxes as the hypervisor to create and manage virtual machines.
- Downloaded the Fedora Workstation Live OS as the virtual machine operating system.
-
Configure Virtual Machines:
- Created two virtual machines running Fedora Workstation Live.
- Installed Node.js on each VM.
-
Network Configuration:
-
Application Deployment:
- Server: Started the server application on one virtual machine using.
- Client: Started the client application on the second virtual machine.
-
Testing:
- Accessed the client application in the second virtual machine.
- Verified successful communication by interacting with the client and confirming server responses.
- Client: Exposed via a NodePort service for external access.
- Server: Exposed via a ClusterIP service for internal communication.
- Networking: Leveraged Kubernetes' internal DNS for the client to communicate with the server.
-
Start Minikube:
minikube start
-
Network Configuration
-
Deploy Applications:
- Applied Kubernetes manifests for the client and server applications:
kubectl apply -f client.yaml kubectl apply -f express.yaml
- Applied Kubernetes manifests for the client and server applications:
-
Scale the Server Application:
- Scaled the server (
express-app
) to 5 replicas:kubectl scale deployment express-app --replicas=5
- Scaled the server (
-
Expose the Client Application:
- Exposed the client service and accessed it using Minikube’s service URL:
minikube service client-service --url
- Exposed the client service and accessed it using Minikube’s service URL:
-
Testing:
- Opened the provided URL in a browser to verify the client-server communication.
- Networking: Communication between client and server happens over a traditional network where both machines must be configured properly for communication.
- Deployment: The applications (client and server) are run directly on virtual machines without containerization.
- Scaling: Scaling is done manually, such as adding more VMs if necessary.
- Networking: Communication between services in Kubernetes is handled internally via Kubernetes services (ClusterIP for internal access, NodePort for external access).
- Deployment: Both client and server are deployed as Kubernetes deployments and managed using Kubernetes configurations.
- Scaling: Kubernetes allows easy scaling of applications by adjusting the replica count for deployments. Kubernetes handles service discovery and load balancing between replicas.
Advantages:
- Simple and straightforward to set up if you are already familiar with virtual machines.
- Full control over the environment and networking configuration.
Disadvantages:
- Requires manual configuration for network communication between virtual machines.
- Not as scalable or flexible as Kubernetes for managing multiple services or handling failures.
- using virtual machines makes it more challenging to share your project since others would need to replicate the environment by downloading the VM, installing Node.js, running
npm install
, and configuring the setup manually.
Advantages:
- Easier to scale and manage deployments with Kubernetes’ built-in features such as replicas and service discovery.
- Containerized applications make it easier to deploy and manage different environments (e.g., dev, staging, production).
- Minikube provides a local Kubernetes cluster, perfect for development and testing.
Disadvantages:
- Requires understanding of Kubernetes concepts (deployments, services, etc.).
- Overhead of running Minikube and Kubernetes locally.
Both approaches are valid for deploying client-server applications, but Minikube with Kubernetes offers a more scalable and flexible solution for production-like environments.