proxy-detection/KUBERNETES.md

1.9 KiB

Kubernetes Deployment

Quick Start

Prerequisites

  • Kubernetes cluster running
  • kubectl configured to access your cluster
  • Docker registry access (for GitLab CI)

Deploy to Kubernetes

Option 1: Use deployment script

# Linux/Mac
chmod +x deploy.sh
./deploy.sh

# Windows
deploy.bat

Option 2: Manual deployment

# 1. Create secret for API key
kubectl apply -f k8s-secret.yaml

# 2. Deploy application
kubectl apply -f k8s-deployment.yaml

# 3. Optional: Deploy ingress for external access
kubectl apply -f k8s-ingress.yaml

Test the deployment

# Port forward to test locally
kubectl port-forward service/proxy-detection-service 8080:80

# Test health endpoint (no auth required)
curl http://localhost:8080/health

# Test main endpoint (requires API key)
curl -H "X-API-Key: bd406bf53ddc6abe1d9de5907830a955" http://localhost:8080/

Configuration

Update API Key

  1. Generate base64 encoded API key:
    echo -n "your-new-api-key" | base64
    
  2. Update k8s-secret.yaml with the new value
  3. Apply changes:
    kubectl apply -f k8s-secret.yaml
    kubectl rollout restart deployment/proxy-detection-api
    

Update Image

Update image in k8s-deployment.yaml or use kubectl:

kubectl set image deployment/proxy-detection-api proxy-detection-api=your-registry/proxy-detection-api:new-tag

GitLab CI/CD

The .gitlab-ci-simple.yml provides:

  • Build stage: Builds and pushes Docker image to GitLab registry
  • Deploy stage: Updates Kubernetes deployment (manual trigger)

Replace .gitlab-ci.yml with .gitlab-ci-simple.yml for the minimal pipeline.

Resources

The deployment is configured with minimal resources:

  • Requests: 64Mi RAM, 50m CPU
  • Limits: 128Mi RAM, 100m CPU
  • Replicas: 2 (for basic high availability)

Adjust these values in k8s-deployment.yaml based on your needs.