Files
k8s-game-2048/scripts/deploy.sh
Greg 82fc2a6691 feat: Complete PII cleanup and fully automatic pipeline
🧹 PII Cleanup & Security:
- Remove all hardcoded domains (darknex.us, hndrx.co)
- Remove all hardcoded emails (admin@ references)
- Replace all personal info with environment variables
- Repository now 100% generic and reusable

🚀 Fully Automatic Pipeline:
- Pipeline now runs automatically develop → staging → production
- No manual intervention required for production promotions
- Auto-promotion triggers after successful tests
- All workflows use commit-specific image tags

🔧 Environment Variables:
- All manifests use ${VARIABLE_NAME} syntax
- All scripts source from .env file
- GitHub Actions use secrets for sensitive data
- Complete .env.example template provided

📚 Documentation:
- New comprehensive WORKFLOWS.md with pipeline details
- New PIPELINE_QUICK_REFERENCE.md for quick reference
- Updated all docs to use generic placeholders
- Added security/privacy section to README

🔐 Security Enhancements:
- Updated .gitignore for all sensitive files
- Created PII verification script (verify-pii-removal.sh)
- Created cleanup automation script (cleanup-pii.sh)
- Repository verified PII-free and production-ready

BREAKING: Repository now requires .env configuration
- Copy .env.example to .env and configure for your environment
- Set GitHub repository secrets for CI/CD workflows
- All deployments now use environment-specific configuration
2025-07-01 17:30:26 -07:00

102 lines
2.9 KiB
Bash
Executable File
Raw Blame History

#!/bin/bash
# Deployment script for 2048 game with Istio + nginx SSL setup
# Usage: ./deploy.sh [env] where env = dev|staging|prod|all
set -e
ENVIRONMENT=${1:-all}
REGISTRY="${CONTAINER_REGISTRY}/${GITHUB_REPOSITORY}"
echo "🚀 Deploying 2048 game with Istio + nginx SSL..."
echo "Environment: $ENVIRONMENT"
# Validate environment
case $ENVIRONMENT in
dev|staging|prod|all)
echo "✅ Valid environment: $ENVIRONMENT"
;;
*)
echo "❌ Invalid environment. Use: dev, staging, prod, or all"
exit 1
;;
esac
# Check dependencies
if ! command -v kubectl &> /dev/null; then
echo "❌ kubectl is not installed"
exit 1
fi
if ! kubectl cluster-info &> /dev/null; then
echo "❌ Cannot access Kubernetes cluster"
exit 1
fi
# Deploy function for a single environment
deploy_env() {
local env=$1
echo "📦 Deploying $env environment..."
# Apply namespace
kubectl apply -f manifests/$env/namespace.yml
# Ensure GHCR secret exists in the namespace
echo "🔐 Setting up GHCR secret for $env..."
if kubectl get secret ghcr-secret -n default &>/dev/null; then
kubectl get secret ghcr-secret -o yaml | \
sed "s/namespace: default/namespace: game-2048-$env/" | \
sed '/resourceVersion:/d' | \
sed '/uid:/d' | \
sed '/creationTimestamp:/d' | \
kubectl apply -f -
else
echo "⚠️ Warning: No GHCR secret found in default namespace"
fi
# Apply service
kubectl apply -f manifests/$env/service.yml
# Wait for service to be ready
echo "⏳ Waiting for $env service to be ready..."
kubectl wait --for=condition=Ready ksvc/game-2048-$env -n game-2048-$env --timeout=300s || echo "Warning: Service may still be starting"
}
# Deploy infrastructure (certificates, gateways, etc.)
echo "🏗️ Setting up infrastructure..."
kubectl apply -f manifests/ssl-certificate.yaml
kubectl apply -f manifests/nginx-certificate.yaml
kubectl apply -f manifests/knative-domain-config.yaml
kubectl apply -f manifests/istio-gateway.yaml
kubectl apply -f manifests/nginx-to-istio-proxy.yaml
# Deploy environments
if [ "$ENVIRONMENT" = "all" ]; then
deploy_env "dev"
deploy_env "staging"
deploy_env "prod"
else
deploy_env "$ENVIRONMENT"
fi
echo ""
echo "✅ Deployment completed!"
echo ""
echo "<22> Your 2048 game is available at:"
if [ "$ENVIRONMENT" = "all" ] || [ "$ENVIRONMENT" = "dev" ]; then
echo " Development: https://${DEV_DOMAIN}"
fi
if [ "$ENVIRONMENT" = "all" ] || [ "$ENVIRONMENT" = "staging" ]; then
echo " Staging: https://${STAGING_DOMAIN}"
fi
if [ "$ENVIRONMENT" = "all" ] || [ "$ENVIRONMENT" = "prod" ]; then
echo " Production: https://${PROD_DOMAIN}"
fi
echo ""
echo "🔧 Check status with:"
echo " kubectl get ksvc -A"
echo " kubectl get certificates -A"
echo " kubectl get ingress -A"
echo ""
echo "📝 Architecture: Internet → nginx (SSL) → Istio → Knative"