Skip to content

Steam Game RecSys Deployment Guide

Overview

This guide provides detailed instructions on how to deploy the Steam Game Recommendation System on a local Kubernetes cluster (Docker Desktop).

Prerequisites

Required Software

  • Docker Desktop (with Kubernetes enabled)
  • kubectl CLI tool
  • Git

Environment Verification

# Check Docker
docker --version

# Check Kubernetes
kubectl version --client

# Check cluster connection
kubectl cluster-info

# Verify nodes
kubectl get nodes

Expected output:

NAME             STATUS   ROLES           AGE   VERSION
docker-desktop   Ready    control-plane   30d   v1.28.2

Project Structure

SteamGameRecSys/
├── backend/                 # FastAPI backend
│   ├── app/
│   │   ├── main.py         # API entry point
│   │   ├── database.py     # MongoDB connection
│   │   └── models.py       # Data models
│   ├── Dockerfile
│   └── requirements.txt
├── frontend/                # React frontend
│   ├── src/
│   ├── Dockerfile
│   └── package.json
├── k8s/                     # Kubernetes configurations
│   ├── mongodb-persistent.yaml
│   └── backend-docker-desktop.yaml
└── docker-compose.hybrid.yml

Deployment Steps

Step 1: Clone Project

cd d:\ESIEE\E4\OpsDev\DEVOPS
# Project is already in SteamGameRecSys/ directory

Step 2: Deploy MongoDB

2.1 Create Namespace (Optional)

kubectl create namespace steam-recsys

Or use default namespace:

kubectl config set-context --current --namespace=default

2.2 Deploy MongoDB with PersistentVolume

kubectl apply -f SteamGameRecSys/k8s/mongodb-persistent.yaml

This configuration includes: - PersistentVolume (10Gi) - PersistentVolumeClaim - MongoDB Deployment - MongoDB Service - Secret (username/password)

2.3 Verify MongoDB Deployment

# Check PV and PVC
kubectl get pv
kubectl get pvc

# Check Pod
kubectl get pods -l app=mongodb

# Check Service
kubectl get svc mongodb

# View logs
kubectl logs -l app=mongodb

Wait for MongoDB Pod status to become Running.

2.4 Test MongoDB Connection

# Enter MongoDB Pod
kubectl exec -it $(kubectl get pod -l app=mongodb -o jsonpath='{.items[0].metadata.name}') -- mongosh

# In mongosh
use steamgamerec
show collections
exit

Step 3: Build Docker Images

3.1 Build Backend Image

cd SteamGameRecSys/backend

# Build image
docker build -t steam-recsys-backend:latest .

# Verify image
docker images | grep steam-recsys-backend

3.2 Build Frontend Image

cd ../frontend

# Build image
docker build -t steam-recsys-frontend:latest .

# Verify image
docker images | grep steam-recsys-frontend

Step 4: Deploy Backend

4.1 Apply Backend Configuration

cd ..
kubectl apply -f k8s/backend-docker-desktop.yaml

This configuration includes: - Backend Deployment - Backend Service (NodePort) - Environment variables (MongoDB connection)

4.2 Verify Backend Deployment

# Check Pod
kubectl get pods -l app=steam-recsys-backend

# Check Service
kubectl get svc steam-recsys-backend

# View logs
kubectl logs -l app=steam-recsys-backend

4.3 Test Backend API

# Get NodePort
kubectl get svc steam-recsys-backend -o jsonpath='{.spec.ports[0].nodePort}'

# Test API (replace PORT)
curl http://localhost:<PORT>/health

# Or access API docs
# http://localhost:<PORT>/docs

Step 5: Deploy Frontend (Optional)

If you have frontend Kubernetes configuration:

kubectl apply -f k8s/frontend-deployment.yaml

Or run locally with Docker:

cd frontend
docker run -d -p 3000:80 \
  -e REACT_APP_API_URL=http://localhost:<BACKEND_PORT> \
  steam-recsys-frontend:latest

Access: http://localhost:3000

Step 6: Import Game Data

6.1 Use Quick Import Script

cd backend

# Create virtual environment
python -m venv venv
venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Run quick import (500 records)
python quick_import.py

6.2 Or Import from Steam API

# Full import (takes time)
python import_steam_games.py

6.3 Verify Data

# Enter MongoDB
kubectl exec -it $(kubectl get pod -l app=mongodb -o jsonpath='{.items[0].metadata.name}') -- mongosh

# Query data
use steamgamerec
db.games.countDocuments()
db.games.findOne()
exit

Configuration Management

MongoDB Credentials

Default credentials (in Secret of mongodb-persistent.yaml):

username: admin (base64: YWRtaW4=)
password: password123 (base64: cGFzc3dvcmQxMjM=)

Production Recommendations: 1. Generate strong password 2. Update Secret 3. Redeploy MongoDB

# Generate base64 encoding
echo -n 'your-password' | base64

# Update Secret
kubectl edit secret mongodb-secret

Backend Configuration

Environment variables (in backend deployment):

env:
  - name: MONGODB_URL
    value: "mongodb://admin:password123@mongodb:27017/"
  - name: DATABASE_NAME
    value: "steamgamerec"

Redeploy after modifications:

kubectl apply -f k8s/backend-docker-desktop.yaml
kubectl rollout restart deployment steam-recsys-backend

Operations

View Logs

# MongoDB logs
kubectl logs -f -l app=mongodb

# Backend logs
kubectl logs -f -l app=steam-recsys-backend

# All pods
kubectl logs -f --all-containers --selector=app=steam-recsys-backend

Scale Replicas

# Scale backend
kubectl scale deployment steam-recsys-backend --replicas=3

# Verify
kubectl get pods -l app=steam-recsys-backend

Update Application

# Rebuild image
docker build -t steam-recsys-backend:v2 backend/

# Update deployment
kubectl set image deployment/steam-recsys-backend \
  backend=steam-recsys-backend:v2

# Or rolling restart
kubectl rollout restart deployment steam-recsys-backend

# Check status
kubectl rollout status deployment steam-recsys-backend

Rollback

# View history
kubectl rollout history deployment steam-recsys-backend

# Rollback to previous version
kubectl rollout undo deployment steam-recsys-backend

# Rollback to specific version
kubectl rollout undo deployment steam-recsys-backend --to-revision=2

Data Backup

Backup MongoDB Data

# Enter MongoDB Pod
kubectl exec -it $(kubectl get pod -l app=mongodb -o jsonpath='{.items[0].metadata.name}') -- bash

# Execute backup inside Pod
mongodump --uri="mongodb://admin:password123@localhost:27017" \
  --db=steamgamerec \
  --out=/data/backup/$(date +%Y%m%d-%H%M%S)

exit

# Copy backup to local
kubectl cp \
  $(kubectl get pod -l app=mongodb -o jsonpath='{.items[0].metadata.name}'):/data/backup \
  ./mongodb-backup

Restore Data

# Copy backup to Pod
kubectl cp ./mongodb-backup/<timestamp> \
  $(kubectl get pod -l app=mongodb -o jsonpath='{.items[0].metadata.name}'):/tmp/restore

# Enter Pod
kubectl exec -it $(kubectl get pod -l app=mongodb -o jsonpath='{.items[0].metadata.name}') -- bash

# Restore data
mongorestore --uri="mongodb://admin:password123@localhost:27017" \
  --db=steamgamerec \
  /tmp/restore/steamgamerec

exit

Monitoring and Debugging

Resource Usage

# View resource usage
kubectl top nodes
kubectl top pods

# View detailed information
kubectl describe pod <pod-name>
kubectl describe svc <service-name>

Debug Pod

# Enter Pod shell
kubectl exec -it <pod-name> -- bash

# Port forwarding
kubectl port-forward svc/steam-recsys-backend 8000:8000

# Access http://localhost:8000

Common Issues

Pod Startup Failure

# View events
kubectl get events --sort-by='.lastTimestamp'

# View Pod details
kubectl describe pod <pod-name>

# View logs
kubectl logs <pod-name>

Image Pull Failure

If using local images, ensure imagePullPolicy: Never or IfNotPresent.

MongoDB Connection Failure

# Verify Service DNS
kubectl run -it --rm debug --image=busybox --restart=Never -- nslookup mongodb

# Test connection
kubectl run -it --rm debug --image=mongo:7 --restart=Never -- \
  mongosh mongodb://admin:password123@mongodb:27017/

Cleanup

Delete All Resources

# Delete backend
kubectl delete -f SteamGameRecSys/k8s/backend-docker-desktop.yaml

# Delete MongoDB
kubectl delete -f SteamGameRecSys/k8s/mongodb-persistent.yaml

# Delete PV (if needed)
kubectl get pv
kubectl delete pv <pv-name>

# Delete namespace (if created)
kubectl delete namespace steam-recsys

Delete Docker Images

docker rmi steam-recsys-backend:latest
docker rmi steam-recsys-frontend:latest

Production Deployment Considerations

Security

  • Use strong passwords
  • Enable TLS/SSL
  • Configure Network Policies
  • Manage sensitive information with Secrets
  • Limit RBAC permissions

High Availability

  • MongoDB replica sets
  • Multiple Backend replicas
  • Load balancing
  • Health checks

Monitoring

  • Integrate Prometheus
  • Configure Grafana dashboards
  • Set up alert rules
  • Log aggregation (ELK/EFK)

Performance Optimization

  • Enable MongoDB indexes
  • Configure resource limits
  • Use caching (Redis)
  • CDN for static assets
  • [[SteamGameRecSys/README|Project Overview]]
  • [[SteamGameRecSys/architecture|Architecture Design]]
  • [[td3/README|Kubernetes Basics]]

Reference Resources


After deployment complete, your Steam Game RecSys should be accessible via: - Backend API: http://localhost:/docs - Frontend: http://localhost:3000 (if deployed) - MongoDB: Internal access mongodb:27017