190 lines
3.6 KiB
Markdown
190 lines
3.6 KiB
Markdown
# Kubernetes Deployment for Auction Monitor
|
|
|
|
## Quick Start
|
|
|
|
### 1. Build and Push Docker Image
|
|
|
|
```bash
|
|
# Build image
|
|
docker build -t your-registry/auction-monitor:latest .
|
|
|
|
# Push to registry
|
|
docker push your-registry/auction-monitor:latest
|
|
```
|
|
|
|
### 2. Update deployment.yaml
|
|
|
|
Edit `deployment.yaml` and replace:
|
|
- `image: auction-monitor:latest` with your image
|
|
- `auction-monitor.yourdomain.com` with your domain
|
|
|
|
### 3. Deploy to Kubernetes
|
|
|
|
```bash
|
|
# Apply all resources
|
|
kubectl apply -f k8s/deployment.yaml
|
|
|
|
# Or apply individually
|
|
kubectl apply -f k8s/namespace.yaml
|
|
kubectl apply -f k8s/configmap.yaml
|
|
kubectl apply -f k8s/secret.yaml
|
|
kubectl apply -f k8s/deployment.yaml
|
|
kubectl apply -f k8s/service.yaml
|
|
kubectl apply -f k8s/ingress.yaml
|
|
```
|
|
|
|
### 4. Verify Deployment
|
|
|
|
```bash
|
|
# Check pods
|
|
kubectl get pods -n auction-monitor
|
|
|
|
# Check services
|
|
kubectl get svc -n auction-monitor
|
|
|
|
# Check ingress
|
|
kubectl get ingress -n auction-monitor
|
|
|
|
# View logs
|
|
kubectl logs -f deployment/auction-monitor -n auction-monitor
|
|
```
|
|
|
|
### 5. Access Application
|
|
|
|
```bash
|
|
# Port forward for local access
|
|
kubectl port-forward svc/auction-monitor 8081:8081 -n auction-monitor
|
|
|
|
# Access API
|
|
curl http://localhost:8081/api/monitor/status
|
|
|
|
# Access health check
|
|
curl http://localhost:8081/health/live
|
|
```
|
|
|
|
## Configuration
|
|
|
|
### ConfigMap
|
|
|
|
Edit workflow schedules in `configMap`:
|
|
|
|
```yaml
|
|
data:
|
|
AUCTION_WORKFLOW_SCRAPER_IMPORT_CRON: "0 */30 * * * ?" # Every 30 min
|
|
AUCTION_WORKFLOW_IMAGE_PROCESSING_CRON: "0 0 * * * ?" # Every 1 hour
|
|
AUCTION_WORKFLOW_BID_MONITORING_CRON: "0 */15 * * * ?" # Every 15 min
|
|
AUCTION_WORKFLOW_CLOSING_ALERTS_CRON: "0 */5 * * * ?" # Every 5 min
|
|
```
|
|
|
|
### Secrets
|
|
|
|
Update notification configuration:
|
|
|
|
```bash
|
|
# Create secret
|
|
kubectl create secret generic auction-secrets \
|
|
--from-literal=notification-config='smtp:user@gmail.com:password:recipient@example.com' \
|
|
-n auction-monitor
|
|
|
|
# Or edit existing
|
|
kubectl edit secret auction-secrets -n auction-monitor
|
|
```
|
|
|
|
## Scaling
|
|
|
|
### Manual Scaling
|
|
|
|
```bash
|
|
# Scale to 3 replicas
|
|
kubectl scale deployment auction-monitor --replicas=3 -n auction-monitor
|
|
```
|
|
|
|
### Auto Scaling
|
|
|
|
HPA is configured in `deployment.yaml`:
|
|
|
|
```yaml
|
|
spec:
|
|
minReplicas: 1
|
|
maxReplicas: 3
|
|
metrics:
|
|
- type: Resource
|
|
resource:
|
|
name: cpu
|
|
target:
|
|
averageUtilization: 80
|
|
```
|
|
|
|
View HPA status:
|
|
|
|
```bash
|
|
kubectl get hpa -n auction-monitor
|
|
```
|
|
|
|
## Monitoring
|
|
|
|
### Health Checks
|
|
|
|
```bash
|
|
# Liveness
|
|
kubectl exec -it deployment/auction-monitor -n auction-monitor -- \
|
|
wget -qO- http://localhost:8081/health/live
|
|
|
|
# Readiness
|
|
kubectl exec -it deployment/auction-monitor -n auction-monitor -- \
|
|
wget -qO- http://localhost:8081/health/ready
|
|
```
|
|
|
|
### Logs
|
|
|
|
```bash
|
|
# Follow logs
|
|
kubectl logs -f deployment/auction-monitor -n auction-monitor
|
|
|
|
# Logs from all pods
|
|
kubectl logs -f -l app=auction-monitor -n auction-monitor
|
|
|
|
# Previous pod logs
|
|
kubectl logs deployment/auction-monitor --previous -n auction-monitor
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### Pod not starting
|
|
|
|
```bash
|
|
# Describe pod
|
|
kubectl describe pod -l app=auction-monitor -n auction-monitor
|
|
|
|
# Check events
|
|
kubectl get events -n auction-monitor --sort-by='.lastTimestamp'
|
|
```
|
|
|
|
### Database issues
|
|
|
|
```bash
|
|
# Check PVC
|
|
kubectl get pvc -n auction-monitor
|
|
|
|
# Check volume mount
|
|
kubectl exec -it deployment/auction-monitor -n auction-monitor -- ls -la /data
|
|
```
|
|
|
|
### Network issues
|
|
|
|
```bash
|
|
# Test service
|
|
kubectl run -it --rm debug --image=busybox --restart=Never -n auction-monitor -- \
|
|
wget -qO- http://auction-monitor:8081/health/live
|
|
```
|
|
|
|
## Cleanup
|
|
|
|
```bash
|
|
# Delete all resources
|
|
kubectl delete -f k8s/deployment.yaml
|
|
|
|
# Or delete namespace (removes everything)
|
|
kubectl delete namespace auction-monitor
|
|
```
|