mirror of
https://github.com/ryankazokas/turbovault-app.git
synced 2026-04-16 21:02:52 +00:00
153 lines
2.8 KiB
Markdown
153 lines
2.8 KiB
Markdown
# Deployment Guide
|
|
|
|
Deploy TurboVault to Kubernetes.
|
|
|
|
## Prerequisites
|
|
|
|
- Kubernetes cluster
|
|
- kubectl configured
|
|
- PostgreSQL database (already set up)
|
|
|
|
## Quick Deploy
|
|
|
|
```bash
|
|
# 1. Build image (auto-builds via GitHub Actions)
|
|
git tag v1.0.0
|
|
git push origin v1.0.0
|
|
|
|
# 2. Configure secrets
|
|
cp k8s/secrets.yaml.example k8s/secrets.yaml
|
|
nano k8s/secrets.yaml
|
|
|
|
# 3. Deploy
|
|
./scripts/deploy-k8s.sh
|
|
```
|
|
|
|
## Configuration
|
|
|
|
### 1. Update Image
|
|
|
|
Edit `k8s/deployment.yaml` and `k8s/migrate-job.yaml`:
|
|
|
|
```yaml
|
|
image: ghcr.io/ryankazokas/turbovault-app:v1.0.0
|
|
```
|
|
|
|
### 2. Database Connection
|
|
|
|
Edit `k8s/configmap.yaml`:
|
|
|
|
```yaml
|
|
DATABASE_HOST: "your-postgres-host"
|
|
DATABASE_NAME: "turbovault_production"
|
|
DATABASE_USERNAME: "turbovault"
|
|
```
|
|
|
|
### 3. Secrets
|
|
|
|
Edit `k8s/secrets.yaml`:
|
|
|
|
```bash
|
|
# Generate Rails secret
|
|
rails secret
|
|
|
|
# Add to secrets.yaml:
|
|
SECRET_KEY_BASE: "output_from_rails_secret"
|
|
DATABASE_PASSWORD: "your_postgres_password"
|
|
|
|
# Optional (for IGDB):
|
|
IGDB_CLIENT_ID: "your_igdb_client_id"
|
|
IGDB_CLIENT_SECRET: "your_igdb_client_secret"
|
|
```
|
|
|
|
## Manual Deployment
|
|
|
|
```bash
|
|
kubectl apply -f k8s/namespace.yaml
|
|
kubectl apply -f k8s/configmap.yaml
|
|
kubectl apply -f k8s/secrets.yaml
|
|
kubectl apply -f k8s/migrate-job.yaml
|
|
kubectl wait --for=condition=complete --timeout=300s job/turbovault-migrate -n turbovault
|
|
kubectl apply -f k8s/deployment.yaml
|
|
kubectl apply -f k8s/service.yaml
|
|
kubectl apply -f k8s/ingress.yaml
|
|
```
|
|
|
|
## Update Deployment
|
|
|
|
```bash
|
|
# Build new version
|
|
git tag v1.1.0
|
|
git push origin v1.1.0
|
|
|
|
# Update deployment
|
|
kubectl set image deployment/turbovault \
|
|
turbovault=ghcr.io/ryankazokas/turbovault-app:v1.1.0 \
|
|
-n turbovault
|
|
|
|
# Watch rollout
|
|
kubectl rollout status deployment/turbovault -n turbovault
|
|
```
|
|
|
|
## SSL/TLS
|
|
|
|
Update `k8s/ingress.yaml` with your domain and TLS configuration.
|
|
|
|
For Let's Encrypt with cert-manager:
|
|
|
|
```yaml
|
|
metadata:
|
|
annotations:
|
|
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
|
spec:
|
|
tls:
|
|
- hosts:
|
|
- turbovault.yourdomain.com
|
|
secretName: turbovault-tls
|
|
```
|
|
|
|
## Scaling
|
|
|
|
```bash
|
|
# Scale replicas
|
|
kubectl scale deployment turbovault --replicas=3 -n turbovault
|
|
|
|
# Auto-scaling
|
|
kubectl autoscale deployment turbovault \
|
|
--cpu-percent=70 \
|
|
--min=2 \
|
|
--max=10 \
|
|
-n turbovault
|
|
```
|
|
|
|
## Monitoring
|
|
|
|
```bash
|
|
# Check status
|
|
kubectl get pods -n turbovault
|
|
|
|
# View logs
|
|
kubectl logs -f -l app=turbovault -n turbovault
|
|
|
|
# Check resources
|
|
kubectl top pods -n turbovault
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### View pod details
|
|
```bash
|
|
kubectl describe pod -l app=turbovault -n turbovault
|
|
```
|
|
|
|
### Test database connection
|
|
```bash
|
|
kubectl exec -it deployment/turbovault -n turbovault -- \
|
|
rails runner "puts ActiveRecord::Base.connection.execute('SELECT 1').first"
|
|
```
|
|
|
|
### View environment
|
|
```bash
|
|
kubectl exec -it deployment/turbovault -n turbovault -- env | grep DATABASE
|
|
```
|