Add base kubernetes support final
This commit is contained in:
152
skaffold-dev.sh
Executable file
152
skaffold-dev.sh
Executable file
@@ -0,0 +1,152 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Bakery IA Skaffold Development Script
|
||||
# Quick setup script for Skaffold development workflow
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 Starting Bakery IA Development Environment with Skaffold"
|
||||
echo "=========================================================="
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Function to print colored output
|
||||
print_status() {
|
||||
echo -e "${BLUE}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
print_success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Check prerequisites
|
||||
check_prerequisites() {
|
||||
print_status "Checking prerequisites..."
|
||||
|
||||
local missing_tools=()
|
||||
|
||||
if ! command -v skaffold &> /dev/null; then
|
||||
missing_tools+=("skaffold")
|
||||
fi
|
||||
|
||||
if ! command -v kubectl &> /dev/null; then
|
||||
missing_tools+=("kubectl")
|
||||
fi
|
||||
|
||||
if ! command -v colima &> /dev/null; then
|
||||
missing_tools+=("colima")
|
||||
fi
|
||||
|
||||
if ! command -v kind &> /dev/null; then
|
||||
missing_tools+=("kind")
|
||||
fi
|
||||
|
||||
if [ ${#missing_tools[@]} -ne 0 ]; then
|
||||
print_error "Missing required tools: ${missing_tools[*]}"
|
||||
print_error "Install with: brew install ${missing_tools[*]}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if Colima is running
|
||||
if ! colima status --profile k8s-local &> /dev/null; then
|
||||
print_warning "Colima is not running. Starting it now..."
|
||||
colima start --cpu 4 --memory 8 --disk 50 --runtime docker --profile k8s-local
|
||||
fi
|
||||
|
||||
# Check if Kind cluster exists
|
||||
if ! kind get clusters | grep -q "bakery-ia-local"; then
|
||||
print_warning "Kind cluster not found. Creating it now..."
|
||||
kind create cluster --name bakery-ia-local
|
||||
fi
|
||||
|
||||
# Verify cluster is accessible
|
||||
if ! kubectl cluster-info &> /dev/null; then
|
||||
print_error "Cannot connect to Kubernetes cluster"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_success "Prerequisites check passed"
|
||||
}
|
||||
|
||||
# Setup development environment
|
||||
setup_dev_environment() {
|
||||
print_status "Setting up development environment..."
|
||||
|
||||
# Check if NGINX Ingress is installed
|
||||
if ! kubectl get namespace ingress-nginx &> /dev/null; then
|
||||
print_status "Installing NGINX Ingress Controller..."
|
||||
kubectl apply -f https://kind.sigs.k8s.io/examples/ingress/deploy-ingress-nginx.yaml
|
||||
kubectl wait --namespace ingress-nginx \
|
||||
--for=condition=ready pod \
|
||||
--selector=app.kubernetes.io/component=controller \
|
||||
--timeout=300s
|
||||
fi
|
||||
|
||||
print_success "Development environment ready"
|
||||
}
|
||||
|
||||
# Start Skaffold development mode
|
||||
start_skaffold_dev() {
|
||||
print_status "Starting Skaffold development mode..."
|
||||
|
||||
print_warning "Starting continuous development mode with Skaffold..."
|
||||
print_warning "This will:"
|
||||
echo " - Build all Docker images automatically"
|
||||
echo " - Deploy to your Kind cluster"
|
||||
echo " - Watch for file changes and auto-rebuild"
|
||||
echo " - Stream logs from all services"
|
||||
echo ""
|
||||
print_warning "Press Ctrl+C to stop and clean up"
|
||||
echo ""
|
||||
|
||||
# Start Skaffold in development mode
|
||||
skaffold dev --profile=dev
|
||||
}
|
||||
|
||||
# Display information
|
||||
display_info() {
|
||||
print_success "🎉 Skaffold development environment ready!"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Add hosts entries (if not done already):"
|
||||
echo " sudo tee -a /etc/hosts << EOF"
|
||||
echo " 127.0.0.1 bakery-ia.local"
|
||||
echo " 127.0.0.1 api.bakery-ia.local"
|
||||
echo " 127.0.0.1 monitoring.bakery-ia.local"
|
||||
echo " EOF"
|
||||
echo ""
|
||||
echo " 2. Access your application:"
|
||||
echo " 🌐 Frontend: http://bakery-ia.local"
|
||||
echo " 🔗 API: http://api.bakery-ia.local"
|
||||
echo ""
|
||||
echo " 3. For HTTPS support, run: ./setup-https.sh"
|
||||
echo ""
|
||||
echo "Useful commands:"
|
||||
echo " 📋 Check pods: kubectl get pods -n bakery-ia"
|
||||
echo " 📝 View logs: kubectl logs -f deployment/<service-name> -n bakery-ia"
|
||||
echo " 🧹 Clean up: skaffold delete"
|
||||
}
|
||||
|
||||
# Main execution
|
||||
main() {
|
||||
check_prerequisites
|
||||
setup_dev_environment
|
||||
display_info
|
||||
start_skaffold_dev
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user