Spaces:
Paused
Paused
File size: 4,744 Bytes
ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
#!/bin/bash
set -e
# Colors and formatting
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
MAGENTA='\033[0;35m'
BOLD='\033[1m'
RESET='\033[0m'
# Yuga Planner Helm Deployment Script
echo -e "${BOLD}β Yuga Planner - Helm Deployment${RESET}"
echo -e "${CYAN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${RESET}"
# Check if we're in the correct directory (project root)
if [ ! -d "deploy/helm" ] && [ ! -f "deploy/helm/Chart.yaml" ]; then
echo -e "${RED}β Error: Helm chart not found${RESET}"
echo -e "${YELLOW}π‘ Please ensure deploy/helm/Chart.yaml exists${RESET}"
exit 1
fi
# Get the script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Source the credential loading script
echo -e "${BLUE}π Loading credential management...${RESET}"
source "${SCRIPT_DIR}/load-credentials.sh"
# Check and load credentials
if ! check_credentials; then
exit 1
fi
# Check dependencies
echo -e "${BLUE}π§ Checking dependencies...${RESET}"
if ! command -v helm &> /dev/null; then
echo -e "${RED}β Error: helm is required but not installed${RESET}"
echo -e "${YELLOW}π‘ Install from: ${CYAN}https://helm.sh/docs/intro/install/${RESET}"
exit 1
fi
if ! command -v kubectl &> /dev/null; then
echo -e "${RED}β Error: kubectl is required but not installed${RESET}"
echo -e "${YELLOW}π‘ Install from: ${CYAN}https://kubernetes.io/docs/tasks/tools/${RESET}"
exit 1
fi
echo -e "${GREEN}β
All dependencies found${RESET}"
# Configuration
RELEASE_NAME="${HELM_RELEASE_NAME:-yuga-planner}"
CURRENT_NAMESPACE=$(kubectl config view --minify --output 'jsonpath={..namespace}' 2>/dev/null || echo "default")
NAMESPACE="${HELM_NAMESPACE:-$CURRENT_NAMESPACE}"
CHART_PATH="${HELM_CHART_PATH:-deploy/helm}"
echo ""
echo -e "${BOLD}π¦ Deployment Configuration:${RESET}"
echo -e " Release: ${MAGENTA}$RELEASE_NAME${RESET}"
echo -e " Namespace: ${MAGENTA}$NAMESPACE${RESET}"
echo -e " Chart: ${MAGENTA}$CHART_PATH${RESET}"
# Create namespace if it doesn't exist
if ! kubectl get namespace "$NAMESPACE" &> /dev/null; then
echo -e "${CYAN}ποΈ Creating namespace: ${MAGENTA}$NAMESPACE${RESET}"
kubectl create namespace "$NAMESPACE"
fi
# Prepare Helm values with environment variables
echo -e "${BLUE}π§ Preparing deployment values...${RESET}"
HELM_VALUES=""
HELM_VALUES="$HELM_VALUES --set secrets.nebiusApiKey=$NEBIUS_API_KEY"
HELM_VALUES="$HELM_VALUES --set secrets.nebiusModel=$NEBIUS_MODEL"
HELM_VALUES="$HELM_VALUES --set secrets.modalTokenId=$MODAL_TOKEN_ID"
HELM_VALUES="$HELM_VALUES --set secrets.modalTokenSecret=$MODAL_TOKEN_SECRET"
HELM_VALUES="$HELM_VALUES --set secrets.hfModel=$HF_MODEL"
HELM_VALUES="$HELM_VALUES --set secrets.hfToken=$HF_TOKEN"
# Add optional environment variables if set
if [ ! -z "$IMAGE_TAG" ]; then
HELM_VALUES="$HELM_VALUES --set image.tag=$IMAGE_TAG"
echo -e " Using custom image tag: ${YELLOW}$IMAGE_TAG${RESET}"
fi
if [ ! -z "$REPLICAS" ]; then
HELM_VALUES="$HELM_VALUES --set deployment.replicas=$REPLICAS"
echo -e " Using custom replica count: ${YELLOW}$REPLICAS${RESET}"
fi
# Deploy with Helm
echo ""
if helm list -n "$NAMESPACE" | grep -q "^$RELEASE_NAME"; then
echo -e "${CYAN}π Upgrading existing Helm release...${RESET}"
helm upgrade "$RELEASE_NAME" "$CHART_PATH" \
--namespace "$NAMESPACE" \
$HELM_VALUES \
--timeout 300s \
--wait
else
echo -e "${CYAN}π Installing new Helm release...${RESET}"
helm install "$RELEASE_NAME" "$CHART_PATH" \
--namespace "$NAMESPACE" \
$HELM_VALUES \
--timeout 300s \
--wait
fi
echo ""
echo -e "${GREEN}β
Deployment complete!${RESET}"
echo -e "${CYAN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${RESET}"
echo -e "${BOLD}π Release Information:${RESET}"
helm status "$RELEASE_NAME" -n "$NAMESPACE" --no-hooks
echo ""
echo -e "${BOLD}π Useful Commands:${RESET}"
echo -e " Check pods: ${GREEN}kubectl get pods -l app.kubernetes.io/instance=$RELEASE_NAME -n $NAMESPACE${RESET}"
echo -e " View logs: ${GREEN}kubectl logs -l app.kubernetes.io/instance=$RELEASE_NAME -n $NAMESPACE -f${RESET}"
echo -e " Port forward: ${GREEN}kubectl port-forward svc/$RELEASE_NAME 8080:80 -n $NAMESPACE${RESET}"
echo -e " Uninstall: ${RED}helm uninstall $RELEASE_NAME -n $NAMESPACE${RESET}"
|