Files
bakery-ia/scripts/tag-and-push-images.sh
Claude 23b8523b36 Add comprehensive Kubernetes migration guide from local to production
This commit adds complete documentation and tooling for migrating from
local development (Kind/Colima on macOS) to production deployment
(MicroK8s on Ubuntu VPS at Clouding.io).

Documentation added:
- K8S-MIGRATION-GUIDE.md: Comprehensive step-by-step migration guide
  covering all phases from VPS setup to post-deployment operations
- MIGRATION-CHECKLIST.md: Quick reference checklist for migration tasks
- MIGRATION-SUMMARY.md: High-level overview and key changes summary

Configuration updates:
- Added storage-patch.yaml for MicroK8s storage class compatibility
  (changes from 'standard' to 'microk8s-hostpath')
- Updated prod/kustomization.yaml to include storage patch

Helper scripts:
- deploy-production.sh: Interactive deployment script with validation
- tag-and-push-images.sh: Automated image tagging and registry push
- backup-databases.sh: Database backup script for production

Key differences addressed:
- Ingress: MicroK8s addon vs custom NGINX
- Storage: MicroK8s hostpath vs Kind standard storage
- Registry: Container registry configuration for production
- SSL: Let's Encrypt production certificates
- Domains: Real domain configuration vs localhost
- Resources: Production-grade resource limits and scaling

The migration guide covers:
- VPS setup and MicroK8s installation
- Configuration adaptations required
- Container registry setup options
- SSL certificate configuration
- Monitoring and backup setup
- Troubleshooting common issues
- Security hardening checklist
- Rollback procedures

All existing Kubernetes manifests remain unchanged and compatible.
2026-01-02 14:57:09 +00:00

155 lines
3.8 KiB
Bash
Executable File

#!/bin/bash
# Script to tag and push all Bakery IA images to a container registry
# Usage: ./tag-and-push-images.sh [REGISTRY_PREFIX] [TAG]
# Example: ./tag-and-push-images.sh myuser/bakery v1.0.0
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Configuration
REGISTRY_PREFIX="${1:-}"
TAG="${2:-latest}"
if [ -z "$REGISTRY_PREFIX" ]; then
echo -e "${RED}Error: Registry prefix required${NC}"
echo "Usage: $0 REGISTRY_PREFIX [TAG]"
echo ""
echo "Examples:"
echo " Docker Hub: $0 myusername/bakery v1.0.0"
echo " GitHub: $0 ghcr.io/myorg/bakery v1.0.0"
echo " MicroK8s: $0 YOUR_VPS_IP:32000/bakery v1.0.0"
exit 1
fi
# List of all services
SERVICES=(
"gateway"
"dashboard"
"auth-service"
"tenant-service"
"training-service"
"forecasting-service"
"sales-service"
"external-service"
"notification-service"
"inventory-service"
"recipes-service"
"suppliers-service"
"pos-service"
"orders-service"
"production-service"
"procurement-service"
"orchestrator-service"
"alert-processor"
"ai-insights-service"
"demo-session-service"
"distribution-service"
)
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}Bakery IA - Image Tagging and Push${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
echo "Registry: $REGISTRY_PREFIX"
echo "Tag: $TAG"
echo ""
# Function to tag image
tag_image() {
local service=$1
local local_name="bakery/${service}"
local remote_name="${REGISTRY_PREFIX}-${service}:${TAG}"
echo -e "${YELLOW}Tagging ${local_name} -> ${remote_name}${NC}"
if docker tag "$local_name" "$remote_name"; then
echo -e "${GREEN}✓ Tagged $service${NC}"
return 0
else
echo -e "${RED}✗ Failed to tag $service${NC}"
return 1
fi
}
# Function to push image
push_image() {
local service=$1
local remote_name="${REGISTRY_PREFIX}-${service}:${TAG}"
echo -e "${YELLOW}Pushing ${remote_name}${NC}"
if docker push "$remote_name"; then
echo -e "${GREEN}✓ Pushed $service${NC}"
return 0
else
echo -e "${RED}✗ Failed to push $service${NC}"
return 1
fi
}
# Check if user is logged in to registry
echo -e "${YELLOW}Checking registry authentication...${NC}"
if ! docker info > /dev/null 2>&1; then
echo -e "${RED}Error: Docker daemon not running${NC}"
exit 1
fi
echo -e "${GREEN}✓ Docker is running${NC}"
echo ""
# Ask for confirmation
echo -e "${YELLOW}This will tag and push ${#SERVICES[@]} images.${NC}"
read -p "Continue? (yes/no): " confirm
if [ "$confirm" != "yes" ]; then
echo "Cancelled."
exit 0
fi
echo ""
echo -e "${GREEN}Starting image tagging and push...${NC}"
echo ""
# Track success/failure
SUCCESS_COUNT=0
FAILED_SERVICES=()
# Tag and push all images
for service in "${SERVICES[@]}"; do
if tag_image "$service" && push_image "$service"; then
((SUCCESS_COUNT++))
else
FAILED_SERVICES+=("$service")
fi
echo ""
done
# Summary
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}Summary${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
echo "Successfully pushed: $SUCCESS_COUNT/${#SERVICES[@]}"
if [ ${#FAILED_SERVICES[@]} -gt 0 ]; then
echo -e "${RED}Failed services:${NC}"
for service in "${FAILED_SERVICES[@]}"; do
echo -e "${RED} - $service${NC}"
done
exit 1
else
echo -e "${GREEN}All images pushed successfully!${NC}"
echo ""
echo "Next steps:"
echo "1. Update image names in infrastructure/kubernetes/overlays/prod/kustomization.yaml"
echo "2. Deploy to production: kubectl apply -k infrastructure/kubernetes/overlays/prod"
fi
echo ""