#!/bin/bash # Site11 Pipeline K8s Deployment Script # ====================================== set -e echo "🚀 Site11 Pipeline K8s Deployment" echo "=================================" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Check if kubectl is available if ! command -v kubectl &> /dev/null; then echo -e "${RED}❌ kubectl is not installed${NC}" exit 1 fi # Check K8s cluster connection echo -n "Checking K8s cluster connection... " if kubectl cluster-info &> /dev/null; then echo -e "${GREEN}✓${NC}" else echo -e "${RED}✗ Cannot connect to K8s cluster${NC}" exit 1 fi # Step 1: Create namespace echo "" echo "1. Creating namespace..." kubectl apply -f namespace.yaml # Step 2: Create ConfigMap and Secrets echo "" echo "2. Creating ConfigMap and Secrets..." echo -e "${YELLOW}⚠️ Remember to update API keys in configmap.yaml${NC}" kubectl apply -f configmap.yaml # Step 3: Build and push Docker images echo "" echo "3. Building Docker images..." echo -e "${YELLOW}Note: This script assumes images are already built${NC}" echo "To build images, run from project root:" echo " docker-compose build pipeline-rss-collector" echo " docker-compose build pipeline-google-search" echo " docker-compose build pipeline-translator" echo " docker-compose build pipeline-ai-article-generator" echo " docker-compose build pipeline-image-generator" # Step 4: Tag and push images (if using local registry) echo "" echo "4. Tagging images for K8s..." services=("rss-collector" "google-search" "translator" "ai-article-generator" "image-generator") for service in "${services[@]}"; do echo "Tagging pipeline-$service..." docker tag site11_pipeline-$service:latest site11/pipeline-$service:latest done # Step 5: Deploy services echo "" echo "5. Deploying services to K8s..." for service in "${services[@]}"; do echo "Deploying $service..." kubectl apply -f $service.yaml done # Step 6: Check deployment status echo "" echo "6. Checking deployment status..." kubectl -n site11-pipeline get deployments echo "" echo "7. Waiting for pods to be ready..." kubectl -n site11-pipeline wait --for=condition=Ready pods --all --timeout=300s || true # Step 7: Show final status echo "" echo "✅ Deployment Complete!" echo "" echo "Current status:" kubectl -n site11-pipeline get pods echo "" echo "To view logs:" echo " kubectl -n site11-pipeline logs -f deployment/pipeline-translator" echo "" echo "To scale deployments:" echo " kubectl -n site11-pipeline scale deployment pipeline-translator --replicas=5" echo "" echo "To delete all resources:" echo " kubectl delete namespace site11-pipeline"