This project demonstrates a simple Node.js application built with Express.js, containerized using Docker, and deployed on a Kubernetes cluster. The application runs locally on a Minikube cluster and can be extended to run on cloud-based Kubernetes environments.
- Node.js application built with Express.js.
- Dockerized for consistent deployment.
- Deployed in Kubernetes using Minikube for local testing .
- Scalable to cloud-based Kubernetes clusters.
.
├── app.js # Your Node.js application entry point
├── package.json # Node.js dependencies and scripts
├── Dockerfile # Docker configuration for the Node.js app
├── deployment.yaml # Kubernetes Deployment and Service definition
└── README.md # Project documentationTo set up and run the project, ensure you have the following:
- Node.js installed (version 20 or later).
- Docker installed and running.
- Kubernetes cluster (local or cloud-based, e.g., Minikube or GKE).
- kubectl CLI tool installed and configured.
First, clone the project repository:
git clone <repository_url>
cd <project_directory>Install the required dependencies by running:
npm installBefore deploying to Kubernetes, build and optionally push the Docker image to DockerHub:
docker build -t <your_dockerhub_username>/nodejs-app .(Optional) Push the image to DockerHub:
docker push <your_dockerhub_username>/nodejs-appApply the Kubernetes deployment and service configuration using kubectl:
kubectl apply -f deployment.yamlThis will create a Kubernetes deployment with 3 replicas and expose the service via a LoadBalancer on port 80.
If you're using Minikube, access the service by running:
minikube service node-k8s-app-serviceThis will open the application in your browser.
For cloud-based Kubernetes clusters, note the external IP of the LoadBalancer by running:
kubectl get servicesThen, navigate to the external IP address in your browser.
To clean up the Kubernetes resources, run:
kubectl delete -f deployment.yaml