mirror of
https://github.com/ghndrx/k8s-game-2048.git
synced 2026-02-10 06:45:07 +00:00
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
This commit is contained in:
@@ -14,7 +14,7 @@ DEV_DOMAIN=2048-dev.your-domain.com
|
|||||||
STAGING_DOMAIN=2048-staging.your-domain.com
|
STAGING_DOMAIN=2048-staging.your-domain.com
|
||||||
PROD_DOMAIN=2048.your-domain.com
|
PROD_DOMAIN=2048.your-domain.com
|
||||||
|
|
||||||
# Canonical Knative Domains
|
# Canonical Knative Domains (auto-generated by Knative)
|
||||||
DEV_CANONICAL_DOMAIN=game-2048-dev.game-2048-dev.dev.your-domain.com
|
DEV_CANONICAL_DOMAIN=game-2048-dev.game-2048-dev.dev.your-domain.com
|
||||||
STAGING_CANONICAL_DOMAIN=game-2048-staging.game-2048-staging.staging.your-domain.com
|
STAGING_CANONICAL_DOMAIN=game-2048-staging.game-2048-staging.staging.your-domain.com
|
||||||
PROD_CANONICAL_DOMAIN=game-2048-prod.game-2048-prod.your-domain.com
|
PROD_CANONICAL_DOMAIN=game-2048-prod.game-2048-prod.your-domain.com
|
||||||
|
|||||||
5
.github/workflows/auto-promote.yml
vendored
5
.github/workflows/auto-promote.yml
vendored
@@ -80,4 +80,7 @@ jobs:
|
|||||||
echo "### 🔗 Next Steps" >> $GITHUB_STEP_SUMMARY
|
echo "### 🔗 Next Steps" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- Staging deployment will start automatically" >> $GITHUB_STEP_SUMMARY
|
echo "- Staging deployment will start automatically" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- Staging tests will run automatically" >> $GITHUB_STEP_SUMMARY
|
echo "- Staging tests will run automatically" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- Production promotion requires manual approval via staging → main merge" >> $GITHUB_STEP_SUMMARY
|
echo "- Production promotion will happen automatically after staging tests pass" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "- Production deployment will happen automatically after promotion" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "🚀 **Fully Automatic Pipeline** - No manual intervention required!" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|||||||
2
.github/workflows/build-image.yml
vendored
2
.github/workflows/build-image.yml
vendored
@@ -8,7 +8,7 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
IMAGE_NAME: ghndrx/k8s-game-2048
|
IMAGE_NAME: ${GITHUB_REPOSITORY}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
15
.github/workflows/deploy-prod.yml
vendored
15
.github/workflows/deploy-prod.yml
vendored
@@ -1,6 +1,8 @@
|
|||||||
name: Deploy to Production
|
name: Deploy to Production
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
image_tag:
|
image_tag:
|
||||||
@@ -8,17 +10,12 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
default: 'latest'
|
default: 'latest'
|
||||||
confirmation:
|
confirmation:
|
||||||
description: 'Type "DEPLOY" to confirm production deployment'
|
description: 'Type "DEPLOY" to confirm manual production deployment'
|
||||||
required: true
|
required: true
|
||||||
source_environment:
|
source_environment:
|
||||||
description: 'Source environment (staging or manual)'
|
description: 'Source environment (staging or manual)'
|
||||||
required: false
|
required: false
|
||||||
default: 'staging'
|
default: 'staging'
|
||||||
workflow_run:
|
|
||||||
workflows: ["Deploy to Staging"]
|
|
||||||
types:
|
|
||||||
- completed
|
|
||||||
branches: [ main, master ]
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
@@ -30,7 +27,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: |
|
if: |
|
||||||
(github.event_name == 'workflow_dispatch' && github.event.inputs.confirmation == 'DEPLOY') ||
|
(github.event_name == 'workflow_dispatch' && github.event.inputs.confirmation == 'DEPLOY') ||
|
||||||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
|
(github.event_name == 'push' && github.ref == 'refs/heads/main')
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -40,9 +37,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
IMAGE_TAG="${{ github.event.inputs.image_tag || 'latest' }}"
|
IMAGE_TAG="${{ github.event.inputs.image_tag || 'latest' }}"
|
||||||
|
echo "🔧 Manual production deployment with image: $IMAGE_TAG"
|
||||||
else
|
else
|
||||||
# For production deployment, use the main branch commit tag
|
# For automatic production deployment, use the main branch commit tag
|
||||||
IMAGE_TAG="main-$(echo "${{ github.sha }}" | cut -c1-7)"
|
IMAGE_TAG="main-$(echo "${{ github.sha }}" | cut -c1-7)"
|
||||||
|
echo "🚀 Automatic production deployment with image: $IMAGE_TAG"
|
||||||
fi
|
fi
|
||||||
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
|
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
|
||||||
echo "Deploying image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$IMAGE_TAG"
|
echo "Deploying image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$IMAGE_TAG"
|
||||||
|
|||||||
22
.github/workflows/deployment-status.yml
vendored
22
.github/workflows/deployment-status.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
|||||||
- name: Check Development Status
|
- name: Check Development Status
|
||||||
run: |
|
run: |
|
||||||
echo "🧪 Checking Development Environment..."
|
echo "🧪 Checking Development Environment..."
|
||||||
DEV_URL="https://game-2048-dev.game-2048-dev.dev.wa.darknex.us"
|
DEV_URL="https://${{ secrets.DEV_DOMAIN }}"
|
||||||
|
|
||||||
DEV_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -L --max-time 30 "$DEV_URL" || echo "000")
|
DEV_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -L --max-time 30 "$DEV_URL" || echo "000")
|
||||||
DEV_VERSION=$(curl -s -L --max-time 30 "$DEV_URL" | grep -o '<title>[^<]*</title>' | sed 's/<title>\(.*\)<\/title>/\1/' || echo "Unknown")
|
DEV_VERSION=$(curl -s -L --max-time 30 "$DEV_URL" | grep -o '<title>[^<]*</title>' | sed 's/<title>\(.*\)<\/title>/\1/' || echo "Unknown")
|
||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
- name: Check Staging Status
|
- name: Check Staging Status
|
||||||
run: |
|
run: |
|
||||||
echo "🎭 Checking Staging Environment..."
|
echo "🎭 Checking Staging Environment..."
|
||||||
STAGING_URL="https://game-2048-staging.game-2048-staging.staging.wa.darknex.us"
|
STAGING_URL="https://${{ secrets.STAGING_DOMAIN }}"
|
||||||
|
|
||||||
STAGING_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -L --max-time 30 "$STAGING_URL" || echo "000")
|
STAGING_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -L --max-time 30 "$STAGING_URL" || echo "000")
|
||||||
STAGING_VERSION=$(curl -s -L --max-time 30 "$STAGING_URL" | grep -o '<title>[^<]*</title>' | sed 's/<title>\(.*\)<\/title>/\1/' || echo "Unknown")
|
STAGING_VERSION=$(curl -s -L --max-time 30 "$STAGING_URL" | grep -o '<title>[^<]*</title>' | sed 's/<title>\(.*\)<\/title>/\1/' || echo "Unknown")
|
||||||
@@ -41,7 +41,7 @@ jobs:
|
|||||||
- name: Check Production Status
|
- name: Check Production Status
|
||||||
run: |
|
run: |
|
||||||
echo "🚀 Checking Production Environment..."
|
echo "🚀 Checking Production Environment..."
|
||||||
PROD_URL="https://game-2048-prod.game-2048-prod.wa.darknex.us"
|
PROD_URL="https://${{ secrets.PROD_DOMAIN }}"
|
||||||
|
|
||||||
PROD_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -L --max-time 30 "$PROD_URL" || echo "000")
|
PROD_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -L --max-time 30 "$PROD_URL" || echo "000")
|
||||||
PROD_VERSION=$(curl -s -L --max-time 30 "$PROD_URL" | grep -o '<title>[^<]*</title>' | sed 's/<title>\(.*\)<\/title>/\1/' || echo "Unknown")
|
PROD_VERSION=$(curl -s -L --max-time 30 "$PROD_URL" | grep -o '<title>[^<]*</title>' | sed 's/<title>\(.*\)<\/title>/\1/' || echo "Unknown")
|
||||||
@@ -64,7 +64,7 @@ jobs:
|
|||||||
else
|
else
|
||||||
DEV_ICON="❌"
|
DEV_ICON="❌"
|
||||||
fi
|
fi
|
||||||
echo "| 🧪 Development | $DEV_ICON HTTP $DEV_STATUS | $DEV_VERSION | https://game-2048-dev.game-2048-dev.dev.wa.darknex.us |" >> $GITHUB_STEP_SUMMARY
|
echo "| 🧪 Development | $DEV_ICON HTTP $DEV_STATUS | $DEV_VERSION | https://${{ secrets.DEV_DOMAIN }} |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
# Staging status
|
# Staging status
|
||||||
if [ "$STAGING_STATUS" = "200" ]; then
|
if [ "$STAGING_STATUS" = "200" ]; then
|
||||||
@@ -72,7 +72,7 @@ jobs:
|
|||||||
else
|
else
|
||||||
STAGING_ICON="❌"
|
STAGING_ICON="❌"
|
||||||
fi
|
fi
|
||||||
echo "| 🎭 Staging | $STAGING_ICON HTTP $STAGING_STATUS | $STAGING_VERSION | https://game-2048-staging.game-2048-staging.staging.wa.darknex.us |" >> $GITHUB_STEP_SUMMARY
|
echo "| 🎭 Staging | $STAGING_ICON HTTP $STAGING_STATUS | $STAGING_VERSION | https://${{ secrets.STAGING_DOMAIN }} |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
# Production status
|
# Production status
|
||||||
if [ "$PROD_STATUS" = "200" ]; then
|
if [ "$PROD_STATUS" = "200" ]; then
|
||||||
@@ -80,12 +80,14 @@ jobs:
|
|||||||
else
|
else
|
||||||
PROD_ICON="❌"
|
PROD_ICON="❌"
|
||||||
fi
|
fi
|
||||||
echo "| 🚀 Production | $PROD_ICON HTTP $PROD_STATUS | $PROD_VERSION | https://game-2048-prod.game-2048-prod.wa.darknex.us |" >> $GITHUB_STEP_SUMMARY
|
echo "| 🚀 Production | $PROD_ICON HTTP $PROD_STATUS | $PROD_VERSION | https://${{ secrets.PROD_DOMAIN }} |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "### 🔧 Manual Actions Available" >> $GITHUB_STEP_SUMMARY
|
echo "### 🔧 Emergency Actions Available" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- **Deploy to Production**: Run 'Deploy to Production' workflow (requires typing 'DEPLOY')" >> $GITHUB_STEP_SUMMARY
|
echo "- **Emergency Deploy**: Run 'Deploy to Production' workflow (requires typing 'DEPLOY')" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- **Promote to Production**: Run 'Promote to Production' workflow (requires typing 'PROMOTE')" >> $GITHUB_STEP_SUMMARY
|
echo "- **Force Promotion**: Run 'Auto-Promote to Production' workflow" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- **Run Smoke Tests**: Run 'Smoke Tests' workflow on any environment" >> $GITHUB_STEP_SUMMARY
|
echo "- **Test Environment**: Run 'Smoke Tests' workflow on any environment" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "**Note**: Pipeline is fully automatic - manual actions only for emergencies" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "📅 **Generated**: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_STEP_SUMMARY
|
echo "📅 **Generated**: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|||||||
2
.github/workflows/pr-validation.yml
vendored
2
.github/workflows/pr-validation.yml
vendored
@@ -6,7 +6,7 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
IMAGE_NAME: ghndrx/k8s-game-2048
|
IMAGE_NAME: ${GITHUB_REPOSITORY}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
validate:
|
validate:
|
||||||
|
|||||||
27
.github/workflows/promote-to-production.yml
vendored
27
.github/workflows/promote-to-production.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Promote to Production
|
name: Auto-Promote to Production
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_run:
|
workflow_run:
|
||||||
@@ -8,11 +8,8 @@ on:
|
|||||||
branches: [ staging ]
|
branches: [ staging ]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
confirmation:
|
|
||||||
description: 'Type "PROMOTE" to confirm staging → production promotion'
|
|
||||||
required: true
|
|
||||||
skip_tests:
|
skip_tests:
|
||||||
description: 'Skip staging tests (use only if staging is already validated)'
|
description: 'Emergency override: Skip staging tests (use only if staging is already validated)'
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
type: boolean
|
type: boolean
|
||||||
@@ -23,7 +20,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment: staging
|
environment: staging
|
||||||
if: |
|
if: |
|
||||||
(github.event_name == 'workflow_dispatch' && github.event.inputs.confirmation == 'PROMOTE') ||
|
(github.event_name == 'workflow_dispatch') ||
|
||||||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
|
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -43,12 +40,18 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "✅ Staging smoke tests passed - proceeding with auto-promotion to production"
|
echo "✅ Staging smoke tests passed - proceeding with auto-promotion to production"
|
||||||
|
|
||||||
|
- name: Auto-promotion to production
|
||||||
|
if: github.event_name == 'workflow_run'
|
||||||
|
run: |
|
||||||
|
echo "<22> Staging smoke tests passed - automatically promoting to production"
|
||||||
|
echo "📋 Trigger: Automatic after staging tests"
|
||||||
|
echo "✅ No manual intervention required"
|
||||||
|
|
||||||
- name: Manual promotion confirmation
|
- name: Manual promotion confirmation
|
||||||
if: github.event_name == 'workflow_dispatch'
|
if: github.event_name == 'workflow_dispatch'
|
||||||
run: |
|
run: |
|
||||||
echo "🔒 Manual promotion to production confirmed"
|
echo "🔧 Manual promotion to production triggered"
|
||||||
echo "📋 Trigger: ${{ github.event_name }}"
|
echo "📋 Trigger: ${{ github.event_name }}"
|
||||||
echo "🎯 Confirmation: ${{ github.event.inputs.confirmation }}"
|
|
||||||
echo "⚡ Skip tests: ${{ github.event.inputs.skip_tests }}"
|
echo "⚡ Skip tests: ${{ github.event.inputs.skip_tests }}"
|
||||||
|
|
||||||
- name: Auto-promote staging to main branch
|
- name: Auto-promote staging to main branch
|
||||||
@@ -56,7 +59,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
script: |
|
script: |
|
||||||
console.log('🎯 All staging smoke tests passed! Auto-promoting staging to main branch...');
|
console.log('🚀 All staging smoke tests passed! Auto-promoting staging to main for production deployment...');
|
||||||
|
|
||||||
// Create a merge from staging to main
|
// Create a merge from staging to main
|
||||||
try {
|
try {
|
||||||
@@ -99,9 +102,9 @@ jobs:
|
|||||||
echo "### 🎮 Deployment Status" >> $GITHUB_STEP_SUMMARY
|
echo "### 🎮 Deployment Status" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
# Use canonical domain format (these are the Knative domains)
|
# Use canonical domain format (these are the Knative domains)
|
||||||
DEV_URL="https://game-2048-dev.game-2048-dev.dev.wa.darknex.us"
|
DEV_URL="https://${{ secrets.DEV_DOMAIN }}"
|
||||||
STAGING_URL="https://game-2048-staging.game-2048-staging.staging.wa.darknex.us"
|
STAGING_URL="https://${{ secrets.STAGING_DOMAIN }}"
|
||||||
PROD_URL="https://game-2048-prod.game-2048-prod.wa.darknex.us"
|
PROD_URL="https://${{ secrets.PROD_DOMAIN }}"
|
||||||
|
|
||||||
echo "- **Development**: ✅ Live at $DEV_URL" >> $GITHUB_STEP_SUMMARY
|
echo "- **Development**: ✅ Live at $DEV_URL" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- **Staging**: ✅ Live at $STAGING_URL" >> $GITHUB_STEP_SUMMARY
|
echo "- **Staging**: ✅ Live at $STAGING_URL" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|||||||
24
.github/workflows/smoke-test.yml
vendored
24
.github/workflows/smoke-test.yml
vendored
@@ -44,15 +44,15 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
case "${{ matrix.environment }}" in
|
case "${{ matrix.environment }}" in
|
||||||
dev)
|
dev)
|
||||||
echo "CANONICAL_DOMAIN=https://game-2048-dev.game-2048-dev.dev.wa.darknex.us" >> $GITHUB_ENV
|
echo "CANONICAL_DOMAIN=https://${{ secrets.DEV_DOMAIN }}" >> $GITHUB_ENV
|
||||||
echo "ENV_NAME=development" >> $GITHUB_ENV
|
echo "ENV_NAME=development" >> $GITHUB_ENV
|
||||||
;;
|
;;
|
||||||
staging)
|
staging)
|
||||||
echo "CANONICAL_DOMAIN=https://game-2048-staging.game-2048-staging.staging.wa.darknex.us" >> $GITHUB_ENV
|
echo "CANONICAL_DOMAIN=https://${{ secrets.STAGING_DOMAIN }}" >> $GITHUB_ENV
|
||||||
echo "ENV_NAME=staging" >> $GITHUB_ENV
|
echo "ENV_NAME=staging" >> $GITHUB_ENV
|
||||||
;;
|
;;
|
||||||
prod)
|
prod)
|
||||||
echo "CANONICAL_DOMAIN=https://game-2048-prod.game-2048-prod.wa.darknex.us" >> $GITHUB_ENV
|
echo "CANONICAL_DOMAIN=https://${{ secrets.PROD_DOMAIN }}" >> $GITHUB_ENV
|
||||||
echo "ENV_NAME=production" >> $GITHUB_ENV
|
echo "ENV_NAME=production" >> $GITHUB_ENV
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -157,9 +157,9 @@ jobs:
|
|||||||
|
|
||||||
# Canonical domains (Knative domains only)
|
# Canonical domains (Knative domains only)
|
||||||
canonical_domains=(
|
canonical_domains=(
|
||||||
"game-2048-dev.game-2048-dev.dev.wa.darknex.us"
|
"${{ secrets.DEV_DOMAIN }}"
|
||||||
"game-2048-staging.game-2048-staging.staging.wa.darknex.us"
|
"${{ secrets.STAGING_DOMAIN }}"
|
||||||
"game-2048-prod.game-2048-prod.wa.darknex.us"
|
"${{ secrets.PROD_DOMAIN }}"
|
||||||
)
|
)
|
||||||
|
|
||||||
for domain in "${canonical_domains[@]}"; do
|
for domain in "${canonical_domains[@]}"; do
|
||||||
@@ -179,9 +179,9 @@ jobs:
|
|||||||
|
|
||||||
# Canonical domains (Knative domains only)
|
# Canonical domains (Knative domains only)
|
||||||
canonical_domains=(
|
canonical_domains=(
|
||||||
"game-2048-dev.game-2048-dev.dev.wa.darknex.us"
|
"${{ secrets.DEV_DOMAIN }}"
|
||||||
"game-2048-staging.game-2048-staging.staging.wa.darknex.us"
|
"${{ secrets.STAGING_DOMAIN }}"
|
||||||
"game-2048-prod.game-2048-prod.wa.darknex.us"
|
"${{ secrets.PROD_DOMAIN }}"
|
||||||
)
|
)
|
||||||
|
|
||||||
for domain in "${canonical_domains[@]}"; do
|
for domain in "${canonical_domains[@]}"; do
|
||||||
@@ -231,9 +231,9 @@ jobs:
|
|||||||
echo "### Tested Canonical Domains" >> $GITHUB_STEP_SUMMARY
|
echo "### Tested Canonical Domains" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
# Use canonical domain format
|
# Use canonical domain format
|
||||||
DEV_URL="https://game-2048-dev.game-2048-dev.dev.wa.darknex.us"
|
DEV_URL="https://${{ secrets.DEV_DOMAIN }}"
|
||||||
STAGING_URL="https://game-2048-staging.game-2048-staging.staging.wa.darknex.us"
|
STAGING_URL="https://${{ secrets.STAGING_DOMAIN }}"
|
||||||
PROD_URL="https://game-2048-prod.game-2048-prod.wa.darknex.us"
|
PROD_URL="https://${{ secrets.PROD_DOMAIN }}"
|
||||||
|
|
||||||
echo "- 🧪 Development: $DEV_URL" >> $GITHUB_STEP_SUMMARY
|
echo "- 🧪 Development: $DEV_URL" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- 🎭 Staging: $STAGING_URL" >> $GITHUB_STEP_SUMMARY
|
echo "- 🎭 Staging: $STAGING_URL" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|||||||
28
.gitignore
vendored
28
.gitignore
vendored
@@ -55,10 +55,36 @@ pids
|
|||||||
*.pid
|
*.pid
|
||||||
*.seed
|
*.seed
|
||||||
*.pid.lock
|
*.pid.lock
|
||||||
|
cleanup-*
|
||||||
# Coverage directory used by tools like istanbul
|
# Coverage directory used by tools like istanbul
|
||||||
coverage/
|
coverage/
|
||||||
|
|
||||||
# Build outputs
|
# Build outputs
|
||||||
dist/
|
dist/
|
||||||
build/
|
build/
|
||||||
|
|
||||||
|
# Personal Information (PII) and sensitive files
|
||||||
|
# These files may contain personal domains, emails, or secrets
|
||||||
|
*.personal
|
||||||
|
*.private
|
||||||
|
personal-*
|
||||||
|
private-*
|
||||||
|
|
||||||
|
# Any files with actual domain/email configurations
|
||||||
|
# (should use .env instead)
|
||||||
|
actual-domains.txt
|
||||||
|
domain-config.txt
|
||||||
|
email-config.txt
|
||||||
|
|
||||||
|
# Generated files from environment substitution
|
||||||
|
*.env.resolved
|
||||||
|
*.resolved.yaml
|
||||||
|
*.resolved.yml
|
||||||
|
|
||||||
|
# Temporary files from cleanup/setup scripts
|
||||||
|
*.tmp
|
||||||
|
*.temp
|
||||||
|
cleanup-*.log
|
||||||
|
setup-*.log
|
||||||
|
|
||||||
|
verify-*
|
||||||
@@ -46,9 +46,9 @@ We use a GitFlow-inspired workflow:
|
|||||||
|
|
||||||
| Environment | Branch | Domain | Auto-Deploy |
|
| Environment | Branch | Domain | Auto-Deploy |
|
||||||
|-------------|--------|---------|------------|
|
|-------------|--------|---------|------------|
|
||||||
| Development | `develop` | `2048-dev.wa.darknex.us` | ✅ |
|
| Development | `develop` | `${DEV_DOMAIN}` | ✅ |
|
||||||
| Staging | `staging` | `2048-staging.wa.darknex.us` | ✅ |
|
| Staging | `staging` | `${STAGING_DOMAIN}` | ✅ |
|
||||||
| Production | `master` | `2048.wa.darknex.us` | ✅ |
|
| Production | `master` | `${PROD_DOMAIN}` | ✅ |
|
||||||
|
|
||||||
## Making Changes
|
## Making Changes
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ kubectl apply -f manifests/dev/
|
|||||||
kubectl get ksvc -n game-2048-dev
|
kubectl get ksvc -n game-2048-dev
|
||||||
|
|
||||||
# Test the deployed service
|
# Test the deployed service
|
||||||
curl -f https://2048-dev.wa.darknex.us/
|
curl -f https://${DEV_DOMAIN}/
|
||||||
```
|
```
|
||||||
|
|
||||||
## Code Style
|
## Code Style
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ The following secrets must be configured in your GitHub repository:
|
|||||||
2. **DEV_WEBHOOK_URL** - Development webhook endpoint
|
2. **DEV_WEBHOOK_URL** - Development webhook endpoint
|
||||||
3. **STAGING_WEBHOOK_URL** - Staging webhook endpoint
|
3. **STAGING_WEBHOOK_URL** - Staging webhook endpoint
|
||||||
4. **PROD_WEBHOOK_URL** - Production webhook endpoint
|
4. **PROD_WEBHOOK_URL** - Production webhook endpoint
|
||||||
5. **KNATIVE_DOMAIN** - Your Knative domain (e.g., `dev.wa.darknex.us`)
|
5. **KNATIVE_DOMAIN** - Your Knative domain (e.g., `dev.${BASE_DOMAIN}`)
|
||||||
|
|
||||||
### Testing the Pipeline
|
### Testing the Pipeline
|
||||||
|
|
||||||
|
|||||||
106
README.md
106
README.md
@@ -13,9 +13,30 @@ A Kubernetes deployment of the classic 2048 game using Knative Serving with Isti
|
|||||||
|
|
||||||
## Environments
|
## Environments
|
||||||
|
|
||||||
- **Development**: `https://2048-dev.wa.darknex.us`
|
- **Development**: `https://${DEV_CANONICAL_DOMAIN}`
|
||||||
- **Staging**: `https://2048-staging.wa.darknex.us`
|
- **Staging**: `https://${STAGING_CANONICAL_DOMAIN}`
|
||||||
- **Production**: `https://2048.wa.darknex.us`
|
- **Production**: `https://${PROD_CANONICAL_DOMAIN}`
|
||||||
|
|
||||||
|
## 🔄 CI/CD Pipeline
|
||||||
|
|
||||||
|
This project features a fully automated CI/CD pipeline with:
|
||||||
|
|
||||||
|
- **Automated Deployments**: Push to `develop` → auto-deploy to dev → auto-promote to staging → auto-promote to production
|
||||||
|
- **Comprehensive Testing**: Smoke tests after each deployment
|
||||||
|
- **Manual Controls**: Override any step with manual workflows
|
||||||
|
- **Zero-downtime Deployments**: Blue-green strategy for production
|
||||||
|
- **Security**: Webhook signature validation and environment-specific secrets
|
||||||
|
|
||||||
|
### Quick Actions
|
||||||
|
|
||||||
|
| Action | Command |
|
||||||
|
|--------|---------|
|
||||||
|
| 📊 Check Status | Actions → "Deployment Status Check" |
|
||||||
|
| 🚀 Deploy to Prod | Actions → "Deploy to Production" (type "DEPLOY") |
|
||||||
|
| ⬆️ Promote to Prod | Actions → "Promote to Production" (type "PROMOTE") |
|
||||||
|
| 🧪 Run Tests | Actions → "Smoke Tests" |
|
||||||
|
|
||||||
|
📚 **[Full Pipeline Documentation](docs/WORKFLOWS.md)** | 🚀 **[Quick Reference](docs/WORKFLOW_QUICK_REFERENCE.md)**
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
@@ -49,7 +70,7 @@ A Kubernetes deployment of the classic 2048 game using Knative Serving with Isti
|
|||||||
|
|
||||||
1. Clone the repository:
|
1. Clone the repository:
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/ghndrx/k8s-game-2048.git
|
git clone https://github.com/${GITHUB_REPOSITORY}.git
|
||||||
cd k8s-game-2048
|
cd k8s-game-2048
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -75,36 +96,38 @@ kubectl apply -f manifests/staging/
|
|||||||
kubectl apply -f manifests/prod/
|
kubectl apply -f manifests/prod/
|
||||||
```
|
```
|
||||||
|
|
||||||
## Project Structure
|
## 📁 Project Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
k8s-game-2048/
|
k8s-game-2048/
|
||||||
├── README.md
|
├── README.md
|
||||||
├── Dockerfile
|
├── Dockerfile
|
||||||
├── .github/
|
├── .github/
|
||||||
│ └── workflows/
|
│ └── workflows/ # CI/CD Pipeline
|
||||||
│ ├── deploy-dev.yml
|
│ ├── build-image.yml # Build & push Docker images
|
||||||
│ ├── deploy-staging.yml
|
│ ├── deploy-dev.yml # Development deployment
|
||||||
│ └── deploy-prod.yml
|
│ ├── deploy-staging.yml # Staging deployment
|
||||||
|
│ ├── deploy-prod.yml # Production deployment
|
||||||
|
│ ├── smoke-test.yml # Post-deployment testing
|
||||||
|
│ ├── auto-promote.yml # Auto dev → staging promotion
|
||||||
|
│ ├── promote-to-production.yml # Auto/manual staging → prod
|
||||||
|
│ └── deployment-status.yml # Environment health checks
|
||||||
|
├── docs/
|
||||||
|
│ ├── WORKFLOWS.md # Complete pipeline documentation
|
||||||
|
│ ├── WORKFLOW_QUICK_REFERENCE.md # Quick action guide
|
||||||
|
│ ├── SETUP.md # Environment setup guide
|
||||||
|
│ ├── ENVIRONMENT.md # Environment configuration
|
||||||
|
│ └── WEBHOOK_DEPLOYMENT.md # Webhook handler setup
|
||||||
├── manifests/
|
├── manifests/
|
||||||
│ ├── dev/
|
│ ├── dev/ # Development Kubernetes manifests
|
||||||
│ │ ├── namespace.yml
|
│ ├── staging/ # Staging Kubernetes manifests
|
||||||
│ │ ├── service.yml
|
│ ├── prod/ # Production Kubernetes manifests
|
||||||
│ │ └── domain-mapping.yml
|
│ └── webhook/ # Webhook handler manifests
|
||||||
│ ├── staging/
|
├── scripts/ # Setup and deployment scripts
|
||||||
│ │ ├── namespace.yml
|
└── src/ # 2048 game source code
|
||||||
│ │ ├── service.yml
|
├── index.html
|
||||||
│ │ └── domain-mapping.yml
|
├── style.css
|
||||||
│ └── prod/
|
└── script.js
|
||||||
│ ├── namespace.yml
|
|
||||||
│ ├── service.yml
|
|
||||||
│ └── domain-mapping.yml
|
|
||||||
├── scripts/
|
|
||||||
│ ├── setup-knative.sh
|
|
||||||
│ ├── setup-kourier.sh
|
|
||||||
│ └── deploy.sh
|
|
||||||
└── src/
|
|
||||||
└── (2048 game files)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
@@ -124,6 +147,35 @@ Each environment includes:
|
|||||||
- Request metrics via Knative
|
- Request metrics via Knative
|
||||||
- Custom domain health checks
|
- Custom domain health checks
|
||||||
|
|
||||||
|
## 🔒 Security & Privacy
|
||||||
|
|
||||||
|
This repository is **PII-free** and production-ready:
|
||||||
|
|
||||||
|
- ✅ **No hardcoded emails, domains, or personal information**
|
||||||
|
- ✅ **All configuration via environment variables**
|
||||||
|
- ✅ **Secrets managed via `.env` files and GitHub secrets**
|
||||||
|
- ✅ **Generic templates that work for any domain/organization**
|
||||||
|
|
||||||
|
### Quick Setup
|
||||||
|
|
||||||
|
1. **Clone and configure:**
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/${GITHUB_REPOSITORY}.git
|
||||||
|
cd k8s-game-2048
|
||||||
|
cp .env.example .env
|
||||||
|
# Edit .env with your actual values
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Apply your configuration:**
|
||||||
|
```bash
|
||||||
|
./scripts/cleanup-pii.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Set GitHub secrets for CI/CD:**
|
||||||
|
- `DEV_DOMAIN`, `STAGING_DOMAIN`, `PROD_DOMAIN`
|
||||||
|
- `WEBHOOK_SECRET`
|
||||||
|
- Webhook URLs for each environment
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
1. Fork the repository
|
1. Fork the repository
|
||||||
|
|||||||
@@ -15,21 +15,21 @@ master (production)
|
|||||||
|
|
||||||
### 🟢 Development Environment
|
### 🟢 Development Environment
|
||||||
- **Branch**: `develop`
|
- **Branch**: `develop`
|
||||||
- **Domain**: `2048-dev.wa.darknex.us`
|
- **Domain**: `${DEV_DOMAIN}`
|
||||||
- **Trigger**: Push to `develop` branch
|
- **Trigger**: Push to `develop` branch
|
||||||
- **Auto-deploy**: ✅ Yes
|
- **Auto-deploy**: ✅ Yes
|
||||||
- **Purpose**: Latest development features, may be unstable
|
- **Purpose**: Latest development features, may be unstable
|
||||||
|
|
||||||
### 🟡 Staging Environment
|
### 🟡 Staging Environment
|
||||||
- **Branch**: `staging`
|
- **Branch**: `staging`
|
||||||
- **Domain**: `2048-staging.wa.darknex.us`
|
- **Domain**: `${STAGING_DOMAIN}`
|
||||||
- **Trigger**: Push to `staging` branch
|
- **Trigger**: Push to `staging` branch
|
||||||
- **Auto-deploy**: ✅ Yes
|
- **Auto-deploy**: ✅ Yes
|
||||||
- **Purpose**: Pre-production testing, stable features
|
- **Purpose**: Pre-production testing, stable features
|
||||||
|
|
||||||
### 🔴 Production Environment
|
### 🔴 Production Environment
|
||||||
- **Branch**: `master`
|
- **Branch**: `master`
|
||||||
- **Domain**: `2048.wa.darknex.us`
|
- **Domain**: `${PROD_DOMAIN}`
|
||||||
- **Trigger**: Push to `master` branch OR GitHub Release
|
- **Trigger**: Push to `master` branch OR GitHub Release
|
||||||
- **Auto-deploy**: ✅ Yes
|
- **Auto-deploy**: ✅ Yes
|
||||||
- **Purpose**: Live production environment
|
- **Purpose**: Live production environment
|
||||||
@@ -59,7 +59,7 @@ git push origin feature/awesome-new-feature
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. Merge feature to develop (via PR)
|
# 1. Merge feature to develop (via PR)
|
||||||
# 2. Test in dev environment: 2048-dev.wa.darknex.us
|
# 2. Test in dev environment: ${DEV_DOMAIN}
|
||||||
|
|
||||||
# 3. Promote to staging
|
# 3. Promote to staging
|
||||||
git checkout staging
|
git checkout staging
|
||||||
@@ -67,7 +67,7 @@ git pull origin staging
|
|||||||
git merge develop
|
git merge develop
|
||||||
git push origin staging
|
git push origin staging
|
||||||
|
|
||||||
# 4. Test in staging: 2048-staging.wa.darknex.us
|
# 4. Test in staging: ${STAGING_DOMAIN}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Deploying to Production
|
### Deploying to Production
|
||||||
@@ -83,7 +83,7 @@ git push origin master
|
|||||||
git tag -a v1.0.0 -m "Release version 1.0.0"
|
git tag -a v1.0.0 -m "Release version 1.0.0"
|
||||||
git push origin v1.0.0
|
git push origin v1.0.0
|
||||||
|
|
||||||
# 3. Production deploys automatically: 2048.wa.darknex.us
|
# 3. Production deploys automatically: ${PROD_DOMAIN}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Hotfix Flow
|
### Hotfix Flow
|
||||||
|
|||||||
61
docs/PIPELINE_QUICK_REFERENCE.md
Normal file
61
docs/PIPELINE_QUICK_REFERENCE.md
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# 🚀 Fully Automatic CI/CD Pipeline
|
||||||
|
|
||||||
|
## Pipeline Flow
|
||||||
|
```
|
||||||
|
Push to develop → Build → Deploy Dev → Test Dev →
|
||||||
|
Promote to Staging → Build → Deploy Staging → Test Staging →
|
||||||
|
Promote to Production → Build → Deploy Production → Test Production
|
||||||
|
```
|
||||||
|
|
||||||
|
## Key Features
|
||||||
|
✅ **Zero Manual Intervention** - Fully automatic from develop to production
|
||||||
|
✅ **Smart Testing** - Tests run after deployments, not before
|
||||||
|
✅ **Safe Rollouts** - Each environment tested before promotion
|
||||||
|
✅ **Commit Tracking** - Each deployment uses exact commit-tagged images
|
||||||
|
✅ **Emergency Override** - Manual actions available if needed
|
||||||
|
|
||||||
|
## Environments
|
||||||
|
|
||||||
|
| Environment | URL | Deployment Trigger |
|
||||||
|
|-------------|-----|-------------------|
|
||||||
|
| 🧪 Development | Your configured development domain | Push to `develop` |
|
||||||
|
| 🎭 Staging | Your configured staging domain | After dev tests pass |
|
||||||
|
| 🚀 Production | Your configured production domain | After staging tests pass |
|
||||||
|
|
||||||
|
## How It Works
|
||||||
|
|
||||||
|
1. **Developer pushes to `develop`**
|
||||||
|
- Automatically builds image: `develop-abc1234`
|
||||||
|
- Deploys to development environment
|
||||||
|
- Runs smoke tests on the new deployment
|
||||||
|
|
||||||
|
2. **Dev tests pass**
|
||||||
|
- Automatically merges `develop` → `staging`
|
||||||
|
- Builds staging image: `staging-def5678`
|
||||||
|
- Deploys to staging environment
|
||||||
|
- Runs smoke tests on staging
|
||||||
|
|
||||||
|
3. **Staging tests pass**
|
||||||
|
- Automatically merges `staging` → `main`
|
||||||
|
- Builds production image: `main-ghi9012`
|
||||||
|
- Deploys to production environment
|
||||||
|
- Runs smoke tests on production
|
||||||
|
|
||||||
|
## Emergency Actions
|
||||||
|
|
||||||
|
If the automatic pipeline breaks, these manual actions are available:
|
||||||
|
|
||||||
|
- **Emergency Production Deploy**: Actions → "Deploy to Production" (type "DEPLOY")
|
||||||
|
- **Force Promotion**: Actions → "Auto-Promote to Production"
|
||||||
|
- **Check Status**: Actions → "Deployment Status Check"
|
||||||
|
- **Test Environments**: Actions → "Smoke Tests"
|
||||||
|
|
||||||
|
## Monitoring
|
||||||
|
|
||||||
|
- **Pipeline Status**: Check GitHub Actions tab
|
||||||
|
- **Environment Health**: Run "Deployment Status Check" workflow
|
||||||
|
- **Live Monitoring**: Each environment URL shows current version
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**🎯 Result**: Push code to `develop`, and it automatically flows through all environments to production with full testing at each stage!
|
||||||
@@ -58,7 +58,7 @@ kubectl patch configmap/config-network \
|
|||||||
kubectl patch configmap/config-domain \
|
kubectl patch configmap/config-domain \
|
||||||
--namespace knative-serving \
|
--namespace knative-serving \
|
||||||
--type merge \
|
--type merge \
|
||||||
--patch '{"data":{"wa.darknex.us":""}}'
|
--patch "{\"data\":{\"${KNATIVE_DOMAIN}\":\"\"}}"
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4. Set up TLS (Optional but Recommended)
|
### 4. Set up TLS (Optional but Recommended)
|
||||||
@@ -79,7 +79,7 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
acme:
|
acme:
|
||||||
server: https://acme-v02.api.letsencrypt.org/directory
|
server: https://acme-v02.api.letsencrypt.org/directory
|
||||||
email: admin@darknex.us
|
email: ${CERT_EMAIL}
|
||||||
privateKeySecretRef:
|
privateKeySecretRef:
|
||||||
name: letsencrypt-prod
|
name: letsencrypt-prod
|
||||||
solvers:
|
solvers:
|
||||||
@@ -112,10 +112,10 @@ After installation, configure your DNS to point to the Kourier LoadBalancer:
|
|||||||
|
|
||||||
2. **Create DNS records**:
|
2. **Create DNS records**:
|
||||||
```
|
```
|
||||||
2048-dev.wa.darknex.us -> LoadBalancer IP
|
${DEV_DOMAIN} -> LoadBalancer IP
|
||||||
2048-staging.wa.darknex.us -> LoadBalancer IP
|
${STAGING_DOMAIN} -> LoadBalancer IP
|
||||||
2048.wa.darknex.us -> LoadBalancer IP
|
${PROD_DOMAIN} -> LoadBalancer IP
|
||||||
*.wa.darknex.us -> LoadBalancer IP (wildcard)
|
*.${BASE_DOMAIN} -> LoadBalancer IP (wildcard)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Verification
|
## Verification
|
||||||
@@ -153,7 +153,7 @@ kubectl get ksvc -n game-2048-dev
|
|||||||
|
|
||||||
3. **TLS certificates not issued**:
|
3. **TLS certificates not issued**:
|
||||||
- Check cert-manager logs: `kubectl logs -n cert-manager -l app=cert-manager`
|
- Check cert-manager logs: `kubectl logs -n cert-manager -l app=cert-manager`
|
||||||
- Verify DNS propagation: `dig 2048-dev.wa.darknex.us`
|
- Verify DNS propagation: `dig ${DEV_DOMAIN}`
|
||||||
|
|
||||||
4. **Service not accessible**:
|
4. **Service not accessible**:
|
||||||
- Check Kourier gateway logs: `kubectl logs -n kourier-system -l app=3scale-kourier-gateway`
|
- Check Kourier gateway logs: `kubectl logs -n kourier-system -l app=3scale-kourier-gateway`
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ Configure these secrets in your GitHub repository settings:
|
|||||||
|
|
||||||
### Security
|
### Security
|
||||||
- `WEBHOOK_SECRET` - Shared secret for HMAC signature verification
|
- `WEBHOOK_SECRET` - Shared secret for HMAC signature verification
|
||||||
- `KNATIVE_DOMAIN` - Your Knative cluster domain (e.g., `staging.wa.darknex.us`)
|
- `KNATIVE_DOMAIN` - Your Knative cluster domain (e.g., `staging.${BASE_DOMAIN}`)
|
||||||
|
|
||||||
## Webhook Handler Implementation
|
## Webhook Handler Implementation
|
||||||
|
|
||||||
|
|||||||
364
docs/WORKFLOWS.md
Normal file
364
docs/WORKFLOWS.md
Normal file
@@ -0,0 +1,364 @@
|
|||||||
|
# 🔄 CI/CD Pipeline Documentation
|
||||||
|
|
||||||
|
This document describes the complete automated deployment pipeline for the Knative 2048 Game on k3s.
|
||||||
|
|
||||||
|
## 📋 Table of Contents
|
||||||
|
|
||||||
|
- [Pipeline Overview](#pipeline-overview)
|
||||||
|
- [Workflow Details](#workflow-details)
|
||||||
|
- [Manual Actions](#manual-actions)
|
||||||
|
- [Environment Configuration](#environment-configuration)
|
||||||
|
- [Troubleshooting](#troubleshooting)
|
||||||
|
|
||||||
|
## 🎯 Pipeline Overview
|
||||||
|
|
||||||
|
### Complete Automatic Flow
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
graph TD
|
||||||
|
A[Push to develop] --> B[Build & Push Image]
|
||||||
|
B --> C[Deploy to Development]
|
||||||
|
C --> D[Smoke Tests Dev]
|
||||||
|
D --> E[Auto-Promote to Staging]
|
||||||
|
E --> F[Build & Push Staging Image]
|
||||||
|
F --> G[Deploy to Staging]
|
||||||
|
G --> H[Smoke Tests Staging]
|
||||||
|
H --> I[Auto-Promote to Production]
|
||||||
|
I --> J[Push to main]
|
||||||
|
J --> K[Build & Push Prod Image]
|
||||||
|
K --> L[Deploy to Production]
|
||||||
|
L --> M[Smoke Tests Production]
|
||||||
|
|
||||||
|
N[Manual Deploy Prod] -.-> L
|
||||||
|
O[Manual Promote Prod] -.-> I
|
||||||
|
P[Manual Smoke Tests] -.-> D
|
||||||
|
P -.-> H
|
||||||
|
P -.-> M
|
||||||
|
```
|
||||||
|
|
||||||
|
### Key Principles
|
||||||
|
|
||||||
|
- **Fully Automatic**: Zero manual intervention from develop to production
|
||||||
|
- **No Race Conditions**: Each step waits for the previous to complete
|
||||||
|
- **Test After Deploy**: Smoke tests run on newly deployed versions
|
||||||
|
- **Commit-Specific Images**: Each environment uses exact commit-tagged images
|
||||||
|
- **Automatic Promotion**: Successful tests trigger automatic promotion
|
||||||
|
- **Manual Override**: Emergency manual deployment still available
|
||||||
|
|
||||||
|
## 🔧 Workflow Details
|
||||||
|
|
||||||
|
### 1. Build and Push Container Image (`build-image.yml`)
|
||||||
|
|
||||||
|
**Triggers:**
|
||||||
|
- Push to `main`, `develop`, `staging`
|
||||||
|
- Pull requests to these branches
|
||||||
|
|
||||||
|
**What it does:**
|
||||||
|
- Builds Docker image from current commit
|
||||||
|
- Creates commit-specific tags: `{branch}-{commit-hash}`
|
||||||
|
- Pushes to GitHub Container Registry (GHCR)
|
||||||
|
- Provides foundation for all deployments
|
||||||
|
|
||||||
|
**Tags created:**
|
||||||
|
- `develop-abc1234` (for develop branch)
|
||||||
|
- `staging-def5678` (for staging branch)
|
||||||
|
- `main-ghi9012` (for main branch)
|
||||||
|
|
||||||
|
### 2. Deploy to Development (`deploy-dev.yml`)
|
||||||
|
|
||||||
|
**Triggers:**
|
||||||
|
- After "Build and Push Container Image" completes successfully on `develop`
|
||||||
|
- Manual dispatch
|
||||||
|
|
||||||
|
**What it does:**
|
||||||
|
- Waits for build to complete (no race conditions)
|
||||||
|
- Uses exact commit-tagged image that was just built
|
||||||
|
- Deploys via webhook to k3s development namespace
|
||||||
|
- Sets up development environment
|
||||||
|
|
||||||
|
**Dependencies:**
|
||||||
|
- Requires successful build completion
|
||||||
|
- Uses environment secrets: `DEV_WEBHOOK_URL`, `WEBHOOK_SECRET`
|
||||||
|
|
||||||
|
### 3. Smoke Tests (`smoke-test.yml`)
|
||||||
|
|
||||||
|
**Triggers:**
|
||||||
|
- After any deployment completes ("Deploy to Development", "Deploy to Staging", "Deploy to Production")
|
||||||
|
- Scheduled every 6 hours
|
||||||
|
- Manual dispatch
|
||||||
|
|
||||||
|
**What it does:**
|
||||||
|
- Tests the **newly deployed** version (not previous)
|
||||||
|
- Validates canonical Knative domains
|
||||||
|
- Checks content, performance, SSL certificates
|
||||||
|
- Runs environment-specific tests
|
||||||
|
|
||||||
|
**Environments tested:**
|
||||||
|
- 🧪 Development: Your configured development domain
|
||||||
|
- 🎭 Staging: Your configured staging domain
|
||||||
|
- 🚀 Production: Your configured production domain
|
||||||
|
|
||||||
|
### 4. Auto-Promote Pipeline (`auto-promote.yml`)
|
||||||
|
|
||||||
|
**Triggers:**
|
||||||
|
- After "Smoke Tests" complete successfully on `develop` branch
|
||||||
|
|
||||||
|
**What it does:**
|
||||||
|
- Verifies development smoke tests passed
|
||||||
|
- Merges `develop` → `staging` automatically
|
||||||
|
- Triggers staging deployment pipeline
|
||||||
|
- Creates promotion summary
|
||||||
|
|
||||||
|
**Safety features:**
|
||||||
|
- Only runs if smoke tests pass
|
||||||
|
- Handles "already up to date" scenarios gracefully
|
||||||
|
|
||||||
|
### 5. Deploy to Staging (`deploy-staging.yml`)
|
||||||
|
|
||||||
|
**Triggers:**
|
||||||
|
- Push to `staging` branch (triggered by auto-promotion)
|
||||||
|
- After "Auto-Promote Pipeline" completes
|
||||||
|
- Manual dispatch
|
||||||
|
|
||||||
|
**What it does:**
|
||||||
|
- Builds and deploys staging-specific image
|
||||||
|
- Uses `staging-{commit}` tagged image
|
||||||
|
- Deploys via webhook to k3s staging namespace
|
||||||
|
|
||||||
|
### 6. Auto-Promote to Production (`promote-to-production.yml`)
|
||||||
|
|
||||||
|
**Triggers:**
|
||||||
|
- After "Smoke Tests" complete successfully on `staging` branch (AUTOMATIC)
|
||||||
|
- Manual dispatch (emergency override only)
|
||||||
|
|
||||||
|
**What it does:**
|
||||||
|
- Verifies staging smoke tests passed
|
||||||
|
- Merges `staging` → `main` automatically
|
||||||
|
- Triggers production deployment immediately
|
||||||
|
- Creates production promotion summary
|
||||||
|
|
||||||
|
**Automation features:**
|
||||||
|
- Runs automatically after staging tests pass
|
||||||
|
- No manual confirmation required
|
||||||
|
- Seamless promotion from staging to production
|
||||||
|
|
||||||
|
### 7. Deploy to Production (`deploy-prod.yml`)
|
||||||
|
|
||||||
|
**Triggers:**
|
||||||
|
- Push to `main` branch (triggered by auto-promotion) - AUTOMATIC
|
||||||
|
- Manual dispatch (requires typing "DEPLOY" for emergencies)
|
||||||
|
|
||||||
|
**What it does:**
|
||||||
|
- Automatically deploys when main branch is updated
|
||||||
|
- Uses `main-{commit}` tagged image
|
||||||
|
- Deploys via webhook to k3s production namespace
|
||||||
|
- Blue-green deployment strategy for zero downtime
|
||||||
|
|
||||||
|
**Automation features:**
|
||||||
|
- No manual confirmation required for automatic deployments
|
||||||
|
- Immediate deployment after staging promotion
|
||||||
|
- Manual override still available for emergencies
|
||||||
|
|
||||||
|
### 8. Deployment Status Check (`deployment-status.yml`)
|
||||||
|
|
||||||
|
**Triggers:**
|
||||||
|
- Manual dispatch
|
||||||
|
- Scheduled every 4 hours
|
||||||
|
|
||||||
|
**What it does:**
|
||||||
|
- Checks health of all environments
|
||||||
|
- Shows current versions deployed
|
||||||
|
- Provides manual action options
|
||||||
|
- Creates comprehensive status report
|
||||||
|
|
||||||
|
## 🎮 Manual Actions (Emergency Use Only)
|
||||||
|
|
||||||
|
> **Note**: The pipeline is fully automatic. Manual actions are only for emergency situations or debugging.
|
||||||
|
|
||||||
|
### Emergency Actions
|
||||||
|
|
||||||
|
| Action | Workflow | Required Input | Use Case |
|
||||||
|
|--------|----------|----------------|----------|
|
||||||
|
| Check Status | Deployment Status Check | None | Monitor all environments |
|
||||||
|
| Test Environment | Smoke Tests | Environment (`dev`/`staging`/`prod`/`all`) | Debug specific environment |
|
||||||
|
| Emergency Deploy | Deploy to Production | Type "DEPLOY" | Emergency production fix |
|
||||||
|
| Force Promotion | Auto-Promote to Production | None | Skip normal promotion flow |
|
||||||
|
|
||||||
|
### Emergency Procedures
|
||||||
|
|
||||||
|
#### Emergency Production Deployment
|
||||||
|
**Use only if automatic pipeline is broken**
|
||||||
|
1. Go to Actions → "Deploy to Production"
|
||||||
|
2. Click "Run workflow"
|
||||||
|
3. Type "DEPLOY" in confirmation field
|
||||||
|
4. Optionally specify image tag
|
||||||
|
5. Click "Run workflow"
|
||||||
|
|
||||||
|
#### Force Production Promotion
|
||||||
|
**Use only if auto-promotion fails**
|
||||||
|
1. Go to Actions → "Auto-Promote to Production"
|
||||||
|
2. Click "Run workflow"
|
||||||
|
3. Optionally skip tests if staging already validated
|
||||||
|
4. Click "Run workflow"
|
||||||
|
|
||||||
|
#### 3. Check Deployment Status
|
||||||
|
1. Go to Actions → "Deployment Status Check"
|
||||||
|
2. Click "Run workflow"
|
||||||
|
3. View results in workflow summary
|
||||||
|
|
||||||
|
#### 4. Run Smoke Tests
|
||||||
|
1. Go to Actions → "Smoke Tests"
|
||||||
|
2. Click "Run workflow"
|
||||||
|
3. Select environment to test
|
||||||
|
4. Click "Run workflow"
|
||||||
|
|
||||||
|
## ⚙️ Environment Configuration
|
||||||
|
|
||||||
|
### Required Secrets
|
||||||
|
|
||||||
|
| Secret | Purpose | Used By |
|
||||||
|
|--------|---------|---------|
|
||||||
|
| `GH_TOKEN` | GitHub Container Registry access | Build workflows |
|
||||||
|
| `WEBHOOK_SECRET` | Webhook signature validation | All deployment workflows |
|
||||||
|
| `DEV_WEBHOOK_URL` | Development deployment endpoint | Deploy to Development |
|
||||||
|
| `STAGING_WEBHOOK_URL` | Staging deployment endpoint | Deploy to Staging |
|
||||||
|
| `PROD_WEBHOOK_URL` | Production deployment endpoint | Deploy to Production |
|
||||||
|
| `DEV_DOMAIN` | Development domain suffix | Smoke Tests |
|
||||||
|
| `STAGING_DOMAIN` | Staging domain suffix | Smoke Tests |
|
||||||
|
| `PROD_DOMAIN` | Production domain suffix | Smoke Tests |
|
||||||
|
|
||||||
|
### Environment URLs
|
||||||
|
|
||||||
|
| Environment | Canonical Domain |
|
||||||
|
|-------------|------------------|
|
||||||
|
| Development | `https://${DEV_CANONICAL_DOMAIN}` |
|
||||||
|
| Staging | `https://${STAGING_CANONICAL_DOMAIN}` |
|
||||||
|
| Production | `https://${PROD_CANONICAL_DOMAIN}` |
|
||||||
|
|
||||||
|
### Image Tagging Strategy
|
||||||
|
|
||||||
|
| Branch | Tag Format | Example | Environment |
|
||||||
|
|--------|------------|---------|-------------|
|
||||||
|
| develop | `develop-{commit}` | `develop-abc1234` | Development |
|
||||||
|
| staging | `staging-{commit}` | `staging-def5678` | Staging |
|
||||||
|
| main | `main-{commit}` | `main-ghi9012` | Production |
|
||||||
|
|
||||||
|
## 🔍 Troubleshooting
|
||||||
|
|
||||||
|
### Common Issues
|
||||||
|
|
||||||
|
#### Pipeline Not Triggering
|
||||||
|
|
||||||
|
**Symptoms:** New commit pushed but no workflows start
|
||||||
|
**Causes:**
|
||||||
|
- Workflow file syntax error
|
||||||
|
- Missing required secrets
|
||||||
|
- Branch protection rules blocking
|
||||||
|
|
||||||
|
**Solutions:**
|
||||||
|
1. Check workflow syntax in `.github/workflows/`
|
||||||
|
2. Verify all secrets are set in repository settings
|
||||||
|
3. Check Actions tab for error messages
|
||||||
|
|
||||||
|
#### Deployment Fails
|
||||||
|
|
||||||
|
**Symptoms:** Deployment workflow fails
|
||||||
|
**Causes:**
|
||||||
|
- Webhook endpoint unreachable
|
||||||
|
- Invalid webhook signature
|
||||||
|
- k3s cluster issues
|
||||||
|
- Image not found
|
||||||
|
|
||||||
|
**Solutions:**
|
||||||
|
1. Check webhook handler logs: `kubectl logs -n webhook-system deployment/webhook-handler`
|
||||||
|
2. Verify webhook secret matches between GitHub and cluster
|
||||||
|
3. Confirm image exists in GHCR
|
||||||
|
4. Check k3s cluster health
|
||||||
|
|
||||||
|
#### Smoke Tests Fail
|
||||||
|
|
||||||
|
**Symptoms:** Tests report environment unreachable
|
||||||
|
**Causes:**
|
||||||
|
- DNS resolution issues
|
||||||
|
- SSL certificate problems
|
||||||
|
- Application not responding
|
||||||
|
- Ingress configuration issues
|
||||||
|
|
||||||
|
**Solutions:**
|
||||||
|
1. Test domains manually: `curl -I https://${DEV_CANONICAL_DOMAIN}`
|
||||||
|
2. Check Knative service status: `kubectl get ksvc -A`
|
||||||
|
3. Verify ingress configuration: `kubectl get ingress -A`
|
||||||
|
4. Check certificate status: `kubectl get certificates -A`
|
||||||
|
|
||||||
|
#### Auto-Promotion Not Working
|
||||||
|
|
||||||
|
**Symptoms:** Tests pass but promotion doesn't happen
|
||||||
|
**Causes:**
|
||||||
|
- Workflow permission issues
|
||||||
|
- No new commits to merge
|
||||||
|
- Dependency chain broken
|
||||||
|
|
||||||
|
**Solutions:**
|
||||||
|
1. Check workflow permissions in repository settings
|
||||||
|
2. Verify branch protection rules
|
||||||
|
3. Check workflow run logs in Actions tab
|
||||||
|
4. Manual promotion as fallback
|
||||||
|
|
||||||
|
### Debug Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check all environments
|
||||||
|
kubectl get all -A | grep game-2048
|
||||||
|
|
||||||
|
# Check webhook handler
|
||||||
|
kubectl logs -n webhook-system deployment/webhook-handler --tail=50
|
||||||
|
|
||||||
|
# Check Knative services
|
||||||
|
kubectl get ksvc -A
|
||||||
|
|
||||||
|
# Check ingress
|
||||||
|
kubectl get ingress -A
|
||||||
|
|
||||||
|
# Test webhook endpoint
|
||||||
|
curl -X POST -H "Content-Type: application/json" \
|
||||||
|
-d '{"test": "true"}' \
|
||||||
|
https://your-webhook-url/webhook
|
||||||
|
|
||||||
|
# Check DNS resolution
|
||||||
|
dig ${DEV_CANONICAL_DOMAIN}
|
||||||
|
|
||||||
|
# Test SSL certificate
|
||||||
|
openssl s_client -servername ${DEV_CANONICAL_DOMAIN} \
|
||||||
|
-connect ${DEV_CANONICAL_DOMAIN}:443
|
||||||
|
```
|
||||||
|
|
||||||
|
### Emergency Procedures
|
||||||
|
|
||||||
|
#### Rollback Production
|
||||||
|
1. Identify last known good commit/tag
|
||||||
|
2. Run "Deploy to Production" manually
|
||||||
|
3. Specify the good image tag
|
||||||
|
4. Type "DEPLOY" to confirm
|
||||||
|
|
||||||
|
#### Skip Failed Tests
|
||||||
|
1. Run "Promote to Production" manually
|
||||||
|
2. Type "PROMOTE" to confirm
|
||||||
|
3. Enable "Skip tests" if staging already validated
|
||||||
|
|
||||||
|
#### Force Promotion
|
||||||
|
1. Manually merge branches using git
|
||||||
|
2. Push to trigger deployments
|
||||||
|
3. Monitor via "Deployment Status Check"
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📚 Related Documentation
|
||||||
|
|
||||||
|
- [Environment Setup](docs/ENVIRONMENT.md)
|
||||||
|
- [Webhook Deployment](docs/WEBHOOK_DEPLOYMENT.md)
|
||||||
|
- [Setup Guide](docs/SETUP.md)
|
||||||
|
- [Branching Strategy](docs/BRANCHING.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Last updated: 2025-01-01 16:00:00 UTC*
|
||||||
84
docs/WORKFLOW_QUICK_REFERENCE.md
Normal file
84
docs/WORKFLOW_QUICK_REFERENCE.md
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
# 🚀 Quick Workflow Reference
|
||||||
|
|
||||||
|
## 🎯 Common Actions
|
||||||
|
|
||||||
|
### Check All Environment Status
|
||||||
|
```
|
||||||
|
Actions → Deployment Status Check → Run workflow
|
||||||
|
```
|
||||||
|
|
||||||
|
### Manual Production Deployment
|
||||||
|
```
|
||||||
|
Actions → Deploy to Production → Run workflow
|
||||||
|
↳ Type "DEPLOY" in confirmation
|
||||||
|
↳ Optional: specify image tag
|
||||||
|
```
|
||||||
|
|
||||||
|
### Manual Production Promotion
|
||||||
|
```
|
||||||
|
Actions → Promote to Production → Run workflow
|
||||||
|
↳ Type "PROMOTE" in confirmation
|
||||||
|
↳ Optional: skip tests if staging validated
|
||||||
|
```
|
||||||
|
|
||||||
|
### Test Specific Environment
|
||||||
|
```
|
||||||
|
Actions → Smoke Tests → Run workflow
|
||||||
|
↳ Select environment (dev/staging/prod/all)
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔄 Automatic Flow
|
||||||
|
|
||||||
|
```
|
||||||
|
develop → build → deploy-dev → test → promote → staging → build → deploy-staging → test → promote → main → deploy-prod
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📋 Workflow Quick Reference
|
||||||
|
|
||||||
|
| Workflow | Trigger | Purpose | Manual? |
|
||||||
|
|----------|---------|---------|---------|
|
||||||
|
| **Build and Push Container Image** | Push to branches | Build Docker images | ❌ |
|
||||||
|
| **Deploy to Development** | After build on develop | Deploy to dev environment | ✅ |
|
||||||
|
| **Smoke Tests** | After deployments | Test deployed environments | ✅ |
|
||||||
|
| **Auto-Promote Pipeline** | After dev smoke tests pass | Merge develop → staging | ❌ |
|
||||||
|
| **Deploy to Staging** | Push to staging | Deploy to staging environment | ✅ |
|
||||||
|
| **Promote to Production** | After staging smoke tests | Merge staging → main | ✅ |
|
||||||
|
| **Deploy to Production** | Push to main OR manual | Deploy to production | ✅ |
|
||||||
|
| **Deployment Status Check** | Manual or scheduled | Check all environment health | ✅ |
|
||||||
|
|
||||||
|
## 🎮 Environment URLs
|
||||||
|
|
||||||
|
- **Dev**: Your configured development domain
|
||||||
|
- **Staging**: Your configured staging domain
|
||||||
|
- **Production**: Your configured production domain
|
||||||
|
|
||||||
|
## 🏷️ Image Tags
|
||||||
|
|
||||||
|
- **Development**: `develop-{commit}` (e.g., `develop-abc1234`)
|
||||||
|
- **Staging**: `staging-{commit}` (e.g., `staging-def5678`)
|
||||||
|
- **Production**: `main-{commit}` (e.g., `main-ghi9012`)
|
||||||
|
|
||||||
|
## 🔑 Required Confirmations
|
||||||
|
|
||||||
|
- **Deploy to Production**: Type `DEPLOY`
|
||||||
|
- **Promote to Production**: Type `PROMOTE`
|
||||||
|
|
||||||
|
## 🆘 Emergency Commands
|
||||||
|
|
||||||
|
### Rollback Production
|
||||||
|
1. Actions → Deploy to Production
|
||||||
|
2. Specify last known good image tag
|
||||||
|
3. Type "DEPLOY"
|
||||||
|
|
||||||
|
### Force Promotion (Skip Tests)
|
||||||
|
1. Actions → Promote to Production
|
||||||
|
2. Type "PROMOTE"
|
||||||
|
3. Enable "Skip tests" checkbox
|
||||||
|
|
||||||
|
### Check System Health
|
||||||
|
1. Actions → Deployment Status Check
|
||||||
|
2. View summary for all environment status
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
💡 **Tip**: Always check "Deployment Status Check" first to see current state of all environments!
|
||||||
@@ -4,13 +4,13 @@ metadata:
|
|||||||
name: config-domain
|
name: config-domain
|
||||||
namespace: knative-serving
|
namespace: knative-serving
|
||||||
data:
|
data:
|
||||||
dev.wa.darknex.us: |
|
dev.${BASE_DOMAIN}: |
|
||||||
selector:
|
selector:
|
||||||
environment: development
|
environment: development
|
||||||
staging.wa.darknex.us: |
|
staging.${BASE_DOMAIN}: |
|
||||||
selector:
|
selector:
|
||||||
environment: staging
|
environment: staging
|
||||||
wa.darknex.us: |
|
${BASE_DOMAIN}: |
|
||||||
selector:
|
selector:
|
||||||
environment: production
|
environment: production
|
||||||
autocreate-cluster-domain-claims: "true"
|
autocreate-cluster-domain-claims: "true"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ spec:
|
|||||||
name: letsencrypt-prod
|
name: letsencrypt-prod
|
||||||
kind: ClusterIssuer
|
kind: ClusterIssuer
|
||||||
dnsNames:
|
dnsNames:
|
||||||
- "2048-dev.wa.darknex.us"
|
- "${DEV_DOMAIN}"
|
||||||
|
|
||||||
---
|
---
|
||||||
apiVersion: cert-manager.io/v1
|
apiVersion: cert-manager.io/v1
|
||||||
@@ -23,7 +23,7 @@ spec:
|
|||||||
name: letsencrypt-prod
|
name: letsencrypt-prod
|
||||||
kind: ClusterIssuer
|
kind: ClusterIssuer
|
||||||
dnsNames:
|
dnsNames:
|
||||||
- "2048-staging.wa.darknex.us"
|
- "${STAGING_DOMAIN}"
|
||||||
|
|
||||||
---
|
---
|
||||||
apiVersion: cert-manager.io/v1
|
apiVersion: cert-manager.io/v1
|
||||||
@@ -37,4 +37,4 @@ spec:
|
|||||||
name: letsencrypt-prod
|
name: letsencrypt-prod
|
||||||
kind: ClusterIssuer
|
kind: ClusterIssuer
|
||||||
dnsNames:
|
dnsNames:
|
||||||
- "2048.wa.darknex.us"
|
- "${PROD_DOMAIN}"
|
||||||
|
|||||||
@@ -10,15 +10,15 @@ metadata:
|
|||||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||||
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
|
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
|
||||||
nginx.ingress.kubernetes.io/configuration-snippet: |
|
nginx.ingress.kubernetes.io/configuration-snippet: |
|
||||||
proxy_set_header Host game-2048-dev.game-2048-dev.dev.wa.darknex.us;
|
proxy_set_header Host ${DEV_CANONICAL_DOMAIN};
|
||||||
spec:
|
spec:
|
||||||
ingressClassName: nginx
|
ingressClassName: nginx
|
||||||
tls:
|
tls:
|
||||||
- hosts:
|
- hosts:
|
||||||
- 2048-dev.wa.darknex.us
|
- ${DEV_DOMAIN}
|
||||||
secretName: game-2048-dev-nginx-tls
|
secretName: game-2048-dev-nginx-tls
|
||||||
rules:
|
rules:
|
||||||
- host: 2048-dev.wa.darknex.us
|
- host: ${DEV_DOMAIN}
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
@@ -41,15 +41,15 @@ metadata:
|
|||||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||||
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
|
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
|
||||||
nginx.ingress.kubernetes.io/configuration-snippet: |
|
nginx.ingress.kubernetes.io/configuration-snippet: |
|
||||||
proxy_set_header Host game-2048-staging.game-2048-staging.staging.wa.darknex.us;
|
proxy_set_header Host ${STAGING_CANONICAL_DOMAIN};
|
||||||
spec:
|
spec:
|
||||||
ingressClassName: nginx
|
ingressClassName: nginx
|
||||||
tls:
|
tls:
|
||||||
- hosts:
|
- hosts:
|
||||||
- 2048-staging.wa.darknex.us
|
- ${STAGING_DOMAIN}
|
||||||
secretName: game-2048-staging-nginx-tls
|
secretName: game-2048-staging-nginx-tls
|
||||||
rules:
|
rules:
|
||||||
- host: 2048-staging.wa.darknex.us
|
- host: ${STAGING_DOMAIN}
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
@@ -72,15 +72,15 @@ metadata:
|
|||||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||||
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
|
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
|
||||||
nginx.ingress.kubernetes.io/configuration-snippet: |
|
nginx.ingress.kubernetes.io/configuration-snippet: |
|
||||||
proxy_set_header Host game-2048-prod.game-2048-prod.wa.darknex.us;
|
proxy_set_header Host ${PROD_CANONICAL_DOMAIN};
|
||||||
spec:
|
spec:
|
||||||
ingressClassName: nginx
|
ingressClassName: nginx
|
||||||
tls:
|
tls:
|
||||||
- hosts:
|
- hosts:
|
||||||
- 2048.wa.darknex.us
|
- ${PROD_DOMAIN}
|
||||||
secretName: game-2048-prod-nginx-tls
|
secretName: game-2048-prod-nginx-tls
|
||||||
rules:
|
rules:
|
||||||
- host: 2048.wa.darknex.us
|
- host: ${PROD_DOMAIN}
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ spec:
|
|||||||
autoscaling.knative.dev/target: "100"
|
autoscaling.knative.dev/target: "100"
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- image: ghcr.io/ghndrx/k8s-game-2048:latest
|
- image: ${CONTAINER_REGISTRY}/${GITHUB_REPOSITORY}:latest
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
|
|||||||
@@ -5,7 +5,23 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
acme:
|
acme:
|
||||||
server: https://acme-v02.api.letsencrypt.org/directory
|
server: https://acme-v02.api.letsencrypt.org/directory
|
||||||
email: admin@hndrx.co
|
email: ${CERT_EMAIL}
|
||||||
|
privateKeySecretRef:
|
||||||
|
name: letsencrypt-prod-private-key
|
||||||
|
solvers:
|
||||||
|
- http01:
|
||||||
|
ingress:
|
||||||
|
class: nginx
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: cert-manager.io/v1
|
||||||
|
kind: ClusterIssuer
|
||||||
|
metadata:
|
||||||
|
name: letsencrypt-staging
|
||||||
|
spec:
|
||||||
|
acme:
|
||||||
|
server: https://acme-v02.api.letsencrypt.org/directory
|
||||||
|
email: ${CERT_EMAIL}
|
||||||
privateKeySecretRef:
|
privateKeySecretRef:
|
||||||
name: letsencrypt-prod
|
name: letsencrypt-prod
|
||||||
solvers:
|
solvers:
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ spec:
|
|||||||
ingressClassName: nginx
|
ingressClassName: nginx
|
||||||
tls:
|
tls:
|
||||||
- hosts:
|
- hosts:
|
||||||
- webhook.wa.darknex.us
|
- ${WEBHOOK_DOMAIN}
|
||||||
secretName: webhook-tls
|
secretName: webhook-tls
|
||||||
rules:
|
rules:
|
||||||
- host: webhook.wa.darknex.us
|
- host: ${WEBHOOK_DOMAIN}
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/ghndrx/k8s-game-2048.git"
|
"url": "git+https://github.com/${GITHUB_REPOSITORY}.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"2048",
|
"2048",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
ENVIRONMENT=${1:-all}
|
ENVIRONMENT=${1:-all}
|
||||||
REGISTRY="ghcr.io/ghndrx/k8s-game-2048"
|
REGISTRY="${CONTAINER_REGISTRY}/${GITHUB_REPOSITORY}"
|
||||||
|
|
||||||
echo "🚀 Deploying 2048 game with Istio + nginx SSL..."
|
echo "🚀 Deploying 2048 game with Istio + nginx SSL..."
|
||||||
echo "Environment: $ENVIRONMENT"
|
echo "Environment: $ENVIRONMENT"
|
||||||
@@ -84,13 +84,13 @@ echo "✅ Deployment completed!"
|
|||||||
echo ""
|
echo ""
|
||||||
echo "<22> Your 2048 game is available at:"
|
echo "<22> Your 2048 game is available at:"
|
||||||
if [ "$ENVIRONMENT" = "all" ] || [ "$ENVIRONMENT" = "dev" ]; then
|
if [ "$ENVIRONMENT" = "all" ] || [ "$ENVIRONMENT" = "dev" ]; then
|
||||||
echo " Development: https://2048-dev.wa.darknex.us"
|
echo " Development: https://${DEV_DOMAIN}"
|
||||||
fi
|
fi
|
||||||
if [ "$ENVIRONMENT" = "all" ] || [ "$ENVIRONMENT" = "staging" ]; then
|
if [ "$ENVIRONMENT" = "all" ] || [ "$ENVIRONMENT" = "staging" ]; then
|
||||||
echo " Staging: https://2048-staging.wa.darknex.us"
|
echo " Staging: https://${STAGING_DOMAIN}"
|
||||||
fi
|
fi
|
||||||
if [ "$ENVIRONMENT" = "all" ] || [ "$ENVIRONMENT" = "prod" ]; then
|
if [ "$ENVIRONMENT" = "all" ] || [ "$ENVIRONMENT" = "prod" ]; then
|
||||||
echo " Production: https://2048.wa.darknex.us"
|
echo " Production: https://${PROD_DOMAIN}"
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
echo "🔧 Check status with:"
|
echo "🔧 Check status with:"
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ echo "🌐 Configuring domain..."
|
|||||||
kubectl patch configmap/config-domain \
|
kubectl patch configmap/config-domain \
|
||||||
--namespace knative-serving \
|
--namespace knative-serving \
|
||||||
--type merge \
|
--type merge \
|
||||||
--patch '{"data":{"wa.darknex.us":""}}'
|
--patch "{\"data\":{\"${KNATIVE_DOMAIN}\":\"\"}}"
|
||||||
|
|
||||||
echo "✅ Knative Serving installation completed!"
|
echo "✅ Knative Serving installation completed!"
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
acme:
|
acme:
|
||||||
server: https://acme-v02.api.letsencrypt.org/directory
|
server: https://acme-v02.api.letsencrypt.org/directory
|
||||||
email: admin@darknex.us
|
email: ${CERT_EMAIL}
|
||||||
privateKeySecretRef:
|
privateKeySecretRef:
|
||||||
name: letsencrypt-prod
|
name: letsencrypt-prod
|
||||||
solvers:
|
solvers:
|
||||||
@@ -98,10 +98,10 @@ kubectl get svc kourier -n kourier-system -o wide
|
|||||||
echo ""
|
echo ""
|
||||||
echo "📋 Next steps:"
|
echo "📋 Next steps:"
|
||||||
echo "1. Configure your DNS to point the following domains to the LoadBalancer IP:"
|
echo "1. Configure your DNS to point the following domains to the LoadBalancer IP:"
|
||||||
echo " - 2048-dev.wa.darknex.us"
|
echo " - ${DEV_DOMAIN}"
|
||||||
echo " - 2048-staging.wa.darknex.us"
|
echo " - ${STAGING_DOMAIN}"
|
||||||
echo " - 2048.wa.darknex.us"
|
echo " - ${PROD_DOMAIN}"
|
||||||
echo " - *.wa.darknex.us (wildcard)"
|
echo " - *.${BASE_DOMAIN} (wildcard)"
|
||||||
echo ""
|
echo ""
|
||||||
echo "2. Deploy your applications:"
|
echo "2. Deploy your applications:"
|
||||||
echo " kubectl apply -f manifests/dev/"
|
echo " kubectl apply -f manifests/dev/"
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ fi
|
|||||||
# Configuration with fallbacks
|
# Configuration with fallbacks
|
||||||
WEBHOOK_SECRET="${WEBHOOK_SECRET:-$(openssl rand -hex 32)}"
|
WEBHOOK_SECRET="${WEBHOOK_SECRET:-$(openssl rand -hex 32)}"
|
||||||
MANIFESTS_PATH="${MANIFESTS_PATH:-/home/administrator/k8s-game-2048/manifests}"
|
MANIFESTS_PATH="${MANIFESTS_PATH:-/home/administrator/k8s-game-2048/manifests}"
|
||||||
WEBHOOK_DOMAIN="${WEBHOOK_DOMAIN:-webhook.wa.darknex.us}"
|
WEBHOOK_DOMAIN="${WEBHOOK_DOMAIN:-webhook.${BASE_DOMAIN}}"
|
||||||
KNATIVE_DOMAIN="${KNATIVE_DOMAIN:-wa.darknex.us}"
|
KNATIVE_DOMAIN="${KNATIVE_DOMAIN:-${BASE_DOMAIN}}"
|
||||||
KUBECONFIG_PATH="${KUBECONFIG_PATH:-/etc/rancher/k3s/k3s.yaml}"
|
KUBECONFIG_PATH="${KUBECONFIG_PATH:-/etc/rancher/k3s/k3s.yaml}"
|
||||||
DEPLOY_INGRESS="${DEPLOY_INGRESS:-true}"
|
DEPLOY_INGRESS="${DEPLOY_INGRESS:-true}"
|
||||||
WEBHOOK_REPLICAS="${WEBHOOK_REPLICAS:-1}"
|
WEBHOOK_REPLICAS="${WEBHOOK_REPLICAS:-1}"
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ NC='\033[0m' # No Color
|
|||||||
|
|
||||||
# Test configuration
|
# Test configuration
|
||||||
ENVIRONMENTS=("dev" "staging" "prod")
|
ENVIRONMENTS=("dev" "staging" "prod")
|
||||||
DOMAINS=("2048-dev.wa.darknex.us" "2048-staging.wa.darknex.us" "2048.wa.darknex.us")
|
DOMAINS=("${DEV_DOMAIN}" "${STAGING_DOMAIN}" "${PROD_DOMAIN}")
|
||||||
CANONICAL_DOMAINS=("game-2048-dev.game-2048-dev.dev.wa.darknex.us" "game-2048-staging.game-2048-staging.staging.wa.darknex.us" "game-2048-prod.game-2048-prod.wa.darknex.us")
|
CANONICAL_DOMAINS=("${DEV_CANONICAL_DOMAIN}" "${STAGING_CANONICAL_DOMAIN}" "${PROD_CANONICAL_DOMAIN}")
|
||||||
TIMEOUT=30
|
TIMEOUT=30
|
||||||
|
|
||||||
echo -e "${BLUE}🧪 Starting 2048 Game Smoke Tests${NC}"
|
echo -e "${BLUE}🧪 Starting 2048 Game Smoke Tests${NC}"
|
||||||
|
|||||||
Reference in New Issue
Block a user