A demonstration project showcasing Kubernetes deployment of a Node.js Express application with configuration management and security best practices.
This project serves as a practical example of deploying a Node.js application on Kubernetes, incorporating various Kubernetes resources and best practices.
- Express.js REST API
- Docker containerization
- Kubernetes deployments with:
- Pod scaling (3 replicas)
- Resource management
- Environment configuration via ConfigMap
- Secret management
- Load balancer service
- Security considerations
- Node.js 20.x
- Docker
- Kubernetes cluster (local or cloud-based)
- kubectl CLI tool
├── app/
│ └── app.js # Express application
├── Dockerfile # Container image definition
├── hello-config.yaml # ConfigMap definition
├── hello-deployment.yaml # Deployment configuration
├── hello-pod.yaml # Pod configuration
├── hello-secret.yaml # Secrets definition
├── hello-service.yaml # Service configuration
└── package.json # Node.js dependencies
-
Build the Docker image:
docker build -t hello-k8s:v1 . -
Apply Kubernetes configurations:
kubectl apply -f hello-config.yaml kubectl apply -f hello-secret.yaml kubectl apply -f hello-deployment.yaml kubectl apply -f hello-service.yaml
-
Access the application:
kubectl get service hello-service
Use the external IP address provided by the LoadBalancer to access the application.
- The application message can be modified via the ConfigMap (
hello-config.yaml) - API key can be updated in the Secret configuration (
hello-secret.yaml) - Resource limits and scaling can be adjusted in the Deployment configuration
ISC