Cloud Kubernetes

Deploy Auto Commerce on managed Kubernetes services for production-grade scalability and reliability.

Provider Options

DigitalOcean Kubernetes (Recommended)

  • Simple setup, affordable pricing
  • Good for small to medium workloads
  • Cost: $60-200/month

AWS EKS

  • Full AWS integration
  • Best for enterprises already on AWS
  • Cost: $150-500/month

Google GKE

  • Best Kubernetes experience
  • Autopilot option for hands-off management
  • Cost: $100-400/month

Prerequisites

  • Cloud provider account
  • kubectl CLI installed
  • Domain name for ingress
  • Container registry access (GitHub Container Registry recommended)

Step 1: Create Cluster

DigitalOcean

# Install doctl CLI
brew install doctl

# Authenticate
doctl auth init

# Create cluster
doctl kubernetes cluster create autocom-cluster \
  --region nyc1 \
  --node-pool "name=worker;size=s-2vcpu-4gb;count=3"

# Get kubeconfig
doctl kubernetes cluster kubeconfig save autocom-cluster

AWS EKS

# Install eksctl
brew install eksctl

# Create cluster
eksctl create cluster \
  --name autocom-cluster \
  --region us-east-1 \
  --nodes 3 \
  --node-type t3.medium

Step 2: Install Ingress Controller

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

# Wait for it to be ready
kubectl wait --namespace ingress-nginx \
  --for=condition=ready pod \
  --selector=app.kubernetes.io/component=controller \
  --timeout=120s

Step 3: Install cert-manager (for HTTPS)

kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.0/cert-manager.yaml

Step 4: Set Up Managed Database

Use a managed PostgreSQL service:

  • DigitalOcean: Managed Databases ($15/month)
  • AWS: RDS PostgreSQL ($30/month)
  • Neon: Serverless PostgreSQL (free tier available)

Step 5: Create Namespace and Secrets

# Create namespace
kubectl create namespace autocom

# Create secrets
kubectl create secret generic autocom-secrets \
  --namespace autocom \
  --from-literal=APP_KEY="base64:$(openssl rand -base64 32)" \
  --from-literal=DB_HOST="your-db-host" \
  --from-literal=DB_DATABASE="autocom" \
  --from-literal=DB_USERNAME="autocom" \
  --from-literal=DB_PASSWORD="your-password" \
  --from-literal=REDIS_PASSWORD=""

# Create registry credentials (if using private registry)
kubectl create secret docker-registry regcred \
  --namespace autocom \
  --docker-server=ghcr.io \
  --docker-username=YOUR_USERNAME \
  --docker-password=YOUR_GITHUB_TOKEN

Step 6: Deploy Services

Apply the Kubernetes manifests from the repository:

# Clone repository
git clone https://github.com/your-org/autocom.git
cd autocom

# Deploy all services
kubectl apply -f k8s/production/

Or deploy individually:

kubectl apply -f k8s/production/redis.yaml
kubectl apply -f k8s/production/api-deployment.yaml
kubectl apply -f k8s/production/frontend-deployment.yaml
kubectl apply -f k8s/production/horizon-deployment.yaml
kubectl apply -f k8s/production/ingress.yaml

Step 7: Run Migrations

API_POD=$(kubectl get pods -n autocom -l app=autocom-api -o jsonpath='{.items[0].metadata.name}')
kubectl exec -n autocom $API_POD -- php artisan migrate --force

Step 8: Configure DNS

Get the load balancer IP:

kubectl get svc -n ingress-nginx ingress-nginx-controller \
  -o jsonpath='{.status.loadBalancer.ingress[0].ip}'

Create DNS records pointing to this IP:

  • api.yourdomain.com
  • app.yourdomain.com

Verification

Check all pods are running:

kubectl get pods -n autocom

Test the API:

curl https://api.yourdomain.com/api/health

Scaling

Auto Commerce supports horizontal pod autoscaling:

# View current HPA status
kubectl get hpa -n autocom

# Manually scale API pods
kubectl scale deployment autocom-api --replicas=5 -n autocom

Monitoring

View logs:

kubectl logs -f deployment/autocom-api -n autocom

Check resource usage:

kubectl top pods -n autocom

CI/CD

For automated deployments, add this GitHub Actions workflow:

# .github/workflows/deploy.yaml
name: Deploy

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Build and push
        run: |
          docker build -t ghcr.io/${{ github.repository }}/api:${{ github.sha }} ./backend
          docker push ghcr.io/${{ github.repository }}/api:${{ github.sha }}

      - name: Deploy
        run: |
          kubectl set image deployment/autocom-api api=ghcr.io/${{ github.repository }}/api:${{ github.sha }} -n autocom

Next Steps