Files
auctiora/k8s/README.md
2025-12-03 19:03:03 +01:00

3.6 KiB

Kubernetes Deployment for Auction Monitor

Quick Start

1. Build and Push Docker Image

# 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

# 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

# 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

# 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:

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:

# 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

# Scale to 3 replicas
kubectl scale deployment auction-monitor --replicas=3 -n auction-monitor

Auto Scaling

HPA is configured in deployment.yaml:

spec:
  minReplicas: 1
  maxReplicas: 3
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        averageUtilization: 80

View HPA status:

kubectl get hpa -n auction-monitor

Monitoring

Health Checks

# 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

# 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

# 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

# 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

# Test service
kubectl run -it --rm debug --image=busybox --restart=Never -n auction-monitor -- \
  wget -qO- http://auction-monitor:8081/health/live

Cleanup

# Delete all resources
kubectl delete -f k8s/deployment.yaml

# Or delete namespace (removes everything)
kubectl delete namespace auction-monitor