A distributed voting application deployed on Kubernetes, demonstrating microservices architecture with multiple components working together to provide a complete voting solution.
This application consists of five main components:
- Voting App (3 replicas) - Frontend web application for casting votes
- Result App (3 replicas) - Web application for displaying voting results
- Redis - In-memory data store for temporary vote storage
- Database (PostgreSQL) - Persistent storage for final vote counts
- Worker - Background service that processes votes from Redis to PostgreSQL
- Replicas: 3 instances for high availability
- Purpose: Web interface where users can cast their votes
- Technology: Typically Python Flask or Node.js
- Service: ClusterIP service for internal communication
- LoadBalancer: External access for users
- Replicas: 3 instances for high availability
- Purpose: Web interface displaying real-time voting results
- Technology: Typically Node.js or similar
- Service: ClusterIP service for internal communication
- LoadBalancer: External access for viewing results
- Replicas: 1 instance
- Purpose: Temporary storage for incoming votes
- Service: ClusterIP service for internal communication only
- Storage: In-memory, ephemeral
- Replicas: 1 instance
- Purpose: Persistent storage for processed votes
- Service: ClusterIP service for internal communication only
- Storage: Persistent volume for data durability
- Replicas: 1 instance
- Purpose: Background processor that moves votes from Redis to PostgreSQL
- No Service: Internal processing component
# Deploy all application components
kubectl apply -f voting-app-deployment.yaml
kubectl apply -f result-app-deployment.yaml
kubectl apply -f redis-deployment.yaml
kubectl apply -f postgres-deployment.yaml
kubectl apply -f worker-deployment.yaml# Create internal services
kubectl apply -f voting-app-service.yaml
kubectl apply -f result-app-service.yaml
kubectl apply -f redis-service.yaml
kubectl apply -f postgres-service.yaml# Create external access services
kubectl apply -f voting-app-loadbalancer.yaml
kubectl apply -f result-app-loadbalancer.yamlvoting-app-service: Port 80 → voting app podsresult-app-service: Port 80 → result app podsredis-service: Port 6379 → Redis podpostgres-service: Port 5432 → PostgreSQL pod
voting-app-lb: External access to voting interfaceresult-app-lb: External access to results interface
- Vote Submission: Users access the voting app through LoadBalancer and submit votes
- Temporary Storage: Votes are stored in Redis for quick processing
- Vote Processing: Worker service reads votes from Redis
- Persistent Storage: Worker processes and stores votes in PostgreSQL
- Result Display: Result app reads from PostgreSQL to display current results
- Pod-to-Pod Communication: All internal communication uses ClusterIP services
- External Access: LoadBalancer services expose voting and result apps
- Service Discovery: Kubernetes DNS enables service name resolution
kubectl get pods
kubectl describe pod <pod-name>kubectl get services
kubectl describe service <service-name>kubectl logs <pod-name>
kubectl logs -f <pod-name> # Follow logs# Get external IPs
kubectl get services -o wide
# Port forward for local testing
kubectl port-forward service/voting-app-service 8080:80
kubectl port-forward service/result-app-service 8081:80kubectl scale deployment voting-app --replicas=5kubectl scale deployment result-app --replicas=5# Delete all resources
kubectl delete -f .
# Or delete by labels
kubectl delete all -l app=voting-app