Athena โ€” mahmoud-consultancy/archive/old-docs/K8S_LOCAL_QUICKSTART.md

Local Kubernetes Deployment - Quick Start Guide

GloryLabs Recruitment Platform (InterimPlaza) Deploy Frontend + Backend + Database locally via Helm


Prerequisites

Required Tools

# Check if installed
docker --version          # Docker Desktop 4.0+
kubectl version --client  # Kubernetes CLI
helm version             # Helm 3.0+
minikube version         # OR kind, k3s, Docker Desktop K8s

Install Missing Tools (macOS)

# Docker Desktop (includes Kubernetes)
brew install --cask docker

# Helm
brew install helm

# Minikube (alternative to Docker Desktop K8s)
brew install minikube

# Start Minikube
minikube start --cpus=4 --memory=8192

๐Ÿš€ Quick Start (5 minutes)

Step 1: Build Docker Images

cd /Users/sarkout/projects/prive/mahmoud-consultancy

# Build backend
cd backend
./mvnw clean package -DskipTests
docker build -t recruitment-backend:local .

# Build frontend
cd ../frontend/recruitment-portal
npm run build
docker build -t recruitment-frontend:local .

cd ../..

Step 2: Deploy with Helm

# Add Bitnami repo for PostgreSQL and Redis
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update

# Install the platform
helm install glorylabs ./helm/recruitment-platform \
  -f ./helm/recruitment-platform/values-local.yaml \
  --create-namespace \
  --namespace glorylabs-local

# Wait for pods to be ready
kubectl wait --for=condition=ready pod \
  --all \
  --namespace glorylabs-local \
  --timeout=300s

Step 3: Access the Application

# Port forward frontend
kubectl port-forward -n glorylabs-local \
  svc/glorylabs-recruitment-platform-frontend 4200:80 &

# Port forward backend
kubectl port-forward -n glorylabs-local \
  svc/glorylabs-recruitment-platform-backend 8090:8080 &

# Open in browser
open http://localhost:4200

Done! Frontend on http://localhost:4200, Backend API on http://localhost:8090


๐Ÿ“‹ Detailed Instructions

Check Deployment Status

# View all resources
kubectl get all -n glorylabs-local

# Check pods
kubectl get pods -n glorylabs-local

# View logs
kubectl logs -n glorylabs-local -l app.kubernetes.io/component=backend
kubectl logs -n glorylabs-local -l app.kubernetes.io/component=frontend

# Describe pod for troubleshooting
kubectl describe pod -n glorylabs-local <pod-name>

Access Services

Option 1: Port Forwarding (Recommended for Local)

# Frontend
kubectl port-forward -n glorylabs-local svc/glorylabs-recruitment-platform-frontend 4200:80

# Backend
kubectl port-forward -n glorylabs-local svc/glorylabs-recruitment-platform-backend 8090:8080

# PostgreSQL (if needed)
kubectl port-forward -n glorylabs-local svc/glorylabs-postgresql 5432:5432

# Redis (if needed)
kubectl port-forward -n glorylabs-local svc/glorylabs-redis-master 6379:6379

Option 2: Ingress (Advanced)

# Install Nginx Ingress Controller
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/cloud/deploy.yaml

# Add to /etc/hosts
echo "127.0.0.1 recruitment.local" | sudo tee -a /etc/hosts

# Access via domain
open http://recruitment.local

๐Ÿ”ง Configuration

Update Configuration

# Edit values
vim helm/recruitment-platform/values-local.yaml

# Upgrade deployment
helm upgrade glorylabs ./helm/recruitment-platform \
  -f ./helm/recruitment-platform/values-local.yaml \
  -n glorylabs-local

Hot Reload (Development)

# Backend hot reload with Maven
kubectl exec -it -n glorylabs-local <backend-pod> -- /bin/bash
./mvnw spring-boot:run

# Frontend hot reload
# Mount local src/ directory (see values-local.yaml hotReload config)

๐Ÿ› ๏ธ Useful Commands

Restart Services

# Restart backend
kubectl rollout restart deployment/glorylabs-recruitment-platform-backend -n glorylabs-local

# Restart frontend
kubectl rollout restart deployment/glorylabs-recruitment-platform-frontend -n glorylabs-local

View Logs

# Stream backend logs
kubectl logs -f -n glorylabs-local -l app.kubernetes.io/component=backend

# Stream frontend logs
kubectl logs -f -n glorylabs-local -l app.kubernetes.io/component=frontend

# View all logs
stern -n glorylabs-local glorylabs  # (requires stern: brew install stern)

Debug Database

# Connect to PostgreSQL
kubectl exec -it -n glorylabs-local svc/glorylabs-postgresql -- psql -U recruitment -d recruitment_local

# List databases
\l

# Connect to database
\c recruitment_local

# List tables
\dt

# Query jobs
SELECT COUNT(*) FROM jobs;

๐Ÿงน Cleanup

Uninstall

# Delete Helm release
helm uninstall glorylabs -n glorylabs-local

# Delete namespace
kubectl delete namespace glorylabs-local

Full Reset

# Delete everything
helm uninstall glorylabs -n glorylabs-local
kubectl delete namespace glorylabs-local

# If using Minikube
minikube stop
minikube delete

โš™๏ธ Customization

Change Ports

Edit helm/recruitment-platform/values-local.yaml:

localDev:
  portForward:
    backend: 8090    # Change backend port
    frontend: 4210   # Change frontend port

Enable Features

config:
  backend:
    firecrawl:
      enabled: true
      apiKey: "your-api-key"

    email:
      enabled: true
      host: smtp.sendgrid.net

๐Ÿ› Troubleshooting

Pods Not Starting

# Check pod status
kubectl get pods -n glorylabs-local

# Describe pod
kubectl describe pod -n glorylabs-local <pod-name>

# Check events
kubectl get events -n glorylabs-local --sort-by='.lastTimestamp'

Image Pull Errors

# For local images, ensure they exist
docker images | grep recruitment

# Rebuild if needed
docker build -t recruitment-backend:local ./backend
docker build -t recruitment-frontend:local ./frontend/recruitment-portal

# For Minikube, load images
minikube image load recruitment-backend:local
minikube image load recruitment-frontend:local

Database Connection Issues

# Check PostgreSQL is running
kubectl get pods -n glorylabs-local | grep postgresql

# Check connection from backend pod
kubectl exec -it -n glorylabs-local <backend-pod> -- \
  psql -h glorylabs-postgresql -U recruitment -d recruitment_local

โœ… Verification Checklist

After deployment, verify:

  • [ ] All pods are running: kubectl get pods -n glorylabs-local
  • [ ] Frontend accessible: http://localhost:4200
  • [ ] Backend health check: http://localhost:8090/actuator/health
  • [ ] Swagger docs: http://localhost:8090/swagger-ui/index.html
  • [ ] Can register a user
  • [ ] Can login
  • [ ] Can browse jobs
  • [ ] Can create CV
  • [ ] Database has data: kubectl exec -it -n glorylabs-local svc/glorylabs-postgresql -- psql -U recruitment -d recruitment_local -c "SELECT COUNT(*) FROM users;"

๐Ÿ“Š Resource Usage

Expected Resources (Local)

  • Backend: 512MB RAM, 100m CPU
  • Frontend: 128MB RAM, 50m CPU
  • PostgreSQL: 256MB RAM
  • Redis: 128MB RAM
  • Total: ~1GB RAM, 200m CPU

Minimum System: 4GB RAM, 2 CPUs Recommended: 8GB RAM, 4 CPUs


๐Ÿš€ Production Deployment

For production deployment, use:

helm install glorylabs ./helm/recruitment-platform \
  -f ./helm/recruitment-platform/values.yaml \
  --namespace glorylabs-prod \
  --create-namespace

See helm/recruitment-platform/values.yaml for production configuration.


Questions? See full documentation: [[docs/interimplaza/README]]

ยฉ 2025 GloryLabs - Part of Mahmoud Consultancy B.V.

Reacties

Nog geen reacties