6de2455917
- Added GLOBAL_MARKETS_TITLE to all translation files - Updated footer with 12 markets (4 active + 8 upcoming) - Translated market section to: zh-cn, zh-tw, ja, ko, th, vi, id, ms, hi - Built and deployed to production - CloudFront invalidation: I3RTMXVFDJXWLG3SYX208OP1CC
159 lines
4.9 KiB
Bash
Executable File
159 lines
4.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Deploy VIMS to AWS EKS
|
|
# Uses Kubernetes manifests for deployment
|
|
|
|
set -e
|
|
|
|
REGION="eu-north-1"
|
|
CLUSTER_NAME="landvex-prod"
|
|
NAMESPACE="vims"
|
|
PROJECT="vims"
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
echo -e "${GREEN}🚀 VIMS EKS Deployment${NC}"
|
|
echo "======================"
|
|
echo "Region: ${REGION}"
|
|
echo "Cluster: ${CLUSTER_NAME}"
|
|
echo "Namespace: ${NAMESPACE}"
|
|
echo ""
|
|
|
|
# Check prerequisites
|
|
echo -e "${YELLOW}Checking prerequisites...${NC}"
|
|
|
|
if ! command -v kubectl &> /dev/null; then
|
|
echo -e "${RED}kubectl not found. Please install kubectl.${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v aws &> /dev/null; then
|
|
echo -e "${RED}AWS CLI not found. Please install AWS CLI.${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
# Update kubeconfig
|
|
echo -e "${YELLOW}Updating kubeconfig...${NC}"
|
|
aws eks update-kubeconfig \
|
|
--region ${REGION} \
|
|
--name ${CLUSTER_NAME} \
|
|
--alias ${CLUSTER_NAME}
|
|
|
|
# Verify cluster connection
|
|
echo -e "${YELLOW}Verifying cluster connection...${NC}"
|
|
kubectl cluster-info
|
|
|
|
# Create namespace if not exists
|
|
echo -e "${YELLOW}Creating namespace...${NC}"
|
|
kubectl create namespace ${NAMESPACE} --dry-run=client -o yaml | kubectl apply -f -
|
|
|
|
# Build and push Docker image
|
|
echo -e "${YELLOW}Building Docker image...${NC}"
|
|
|
|
# Get ECR login token
|
|
ECR_URI=$(aws sts get-caller-identity --query Account --output text).dkr.ecr.${REGION}.amazonaws.com
|
|
REPO_URI=${ECR_URI}/${PROJECT}
|
|
|
|
# Login to ECR
|
|
echo -e "${YELLOW}Logging in to ECR...${NC}"
|
|
aws ecr get-login-password --region ${REGION} | \
|
|
docker login --username AWS --password-stdin ${ECR_URI}
|
|
|
|
# Create ECR repository if not exists
|
|
echo -e "${YELLOW}Creating ECR repository...${NC}"
|
|
aws ecr describe-repositories --repository-names ${PROJECT} --region ${REGION} 2>/dev/null || \
|
|
aws ecr create-repository --repository-name ${PROJECT} --region ${REGION}
|
|
|
|
# Build image
|
|
docker build -t ${PROJECT}:latest .
|
|
docker tag ${PROJECT}:latest ${REPO_URI}:latest
|
|
|
|
# Push image
|
|
echo -e "${YELLOW}Pushing image to ECR...${NC}"
|
|
docker push ${REPO_URI}:latest
|
|
|
|
echo -e "${GREEN}✓ Image pushed to ${REPO_URI}:latest${NC}"
|
|
|
|
# Update Kubernetes manifests with correct image
|
|
echo -e "${YELLOW}Updating Kubernetes manifests...${NC}"
|
|
sed -i "s|image:.*vims.*|image: ${REPO_URI}:latest|g" k8s/vims-api.yaml
|
|
sed -i "s|image:.*vims.*|image: ${REPO_URI}:latest|g" k8s/vims-worker.yaml
|
|
|
|
# Apply Kubernetes manifests
|
|
echo -e "${YELLOW}Applying Kubernetes manifests...${NC}"
|
|
|
|
echo -e "${BLUE} → Namespace${NC}"
|
|
kubectl apply -f k8s/namespace.yaml
|
|
|
|
echo -e "${BLUE} → ConfigMap${NC}"
|
|
kubectl apply -f k8s/configmap.yaml -n ${NAMESPACE}
|
|
|
|
echo -e "${BLUE} → Secrets${NC}"
|
|
# Create secrets from environment variables or generate new ones
|
|
kubectl create secret generic vims-secrets \
|
|
--from-literal=db-password=${DB_PASSWORD:-$(openssl rand -base64 32)} \
|
|
--from-literal=jwt-secret=${JWT_SECRET:-$(openssl rand -base64 32)} \
|
|
--from-literal=aws-access-key=${AWS_ACCESS_KEY_ID} \
|
|
--from-literal=aws-secret-key=${AWS_SECRET_ACCESS_KEY} \
|
|
-n ${NAMESPACE} \
|
|
--dry-run=client -o yaml | kubectl apply -f -
|
|
|
|
echo -e "${BLUE} → PostgreSQL${NC}"
|
|
kubectl apply -f k8s/postgres.yaml -n ${NAMESPACE}
|
|
|
|
echo -e "${BLUE} → Redis${NC}"
|
|
kubectl apply -f k8s/redis.yaml -n ${NAMESPACE}
|
|
|
|
echo -e "${BLUE} → VIMS API${NC}"
|
|
kubectl apply -f k8s/vims-api.yaml -n ${NAMESPACE}
|
|
|
|
echo -e "${BLUE} → VIMS Worker${NC}"
|
|
kubectl apply -f k8s/vims-worker.yaml -n ${NAMESPACE}
|
|
|
|
echo -e "${BLUE} → Ingress${NC}"
|
|
kubectl apply -f k8s/ingress.yaml -n ${NAMESPACE}
|
|
|
|
# Wait for deployments
|
|
echo -e "${YELLOW}Waiting for deployments...${NC}"
|
|
kubectl wait --for=condition=available --timeout=300s deployment/vims-api -n ${NAMESPACE}
|
|
kubectl wait --for=condition=available --timeout=300s deployment/vims-worker -n ${NAMESPACE}
|
|
|
|
# Verify deployment
|
|
echo -e "${YELLOW}Verifying deployment...${NC}"
|
|
kubectl get pods -n ${NAMESPACE}
|
|
kubectl get services -n ${NAMESPACE}
|
|
kubectl get ingress -n ${NAMESPACE}
|
|
|
|
# Get ingress URL
|
|
echo ""
|
|
echo -e "${GREEN}🎉 VIMS deployed to EKS!${NC}"
|
|
echo ""
|
|
echo -e "${BLUE}Deployment Status:${NC}"
|
|
kubectl get deployments -n ${NAMESPACE}
|
|
|
|
echo ""
|
|
echo -e "${BLUE}Service URLs:${NC}"
|
|
INGRESS_HOST=$(kubectl get ingress vims-ingress -n ${NAMESPACE} -o jsonpath='{.spec.rules[0].host}' 2>/dev/null || echo "Not configured")
|
|
if [ "${INGRESS_HOST}" != "Not configured" ]; then
|
|
echo " API: https://${INGRESS_HOST}/api/v1"
|
|
echo " Health: https://${INGRESS_HOST}/health"
|
|
else
|
|
echo " Ingress not configured. Use kubectl port-forward:"
|
|
echo " kubectl port-forward svc/vims-api 3450:3450 -n ${NAMESPACE}"
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${BLUE}Useful commands:${NC}"
|
|
echo " View logs: kubectl logs -f deployment/vims-api -n ${NAMESPACE}"
|
|
echo " Scale API: kubectl scale deployment vims-api --replicas=3 -n ${NAMESPACE}"
|
|
echo " Shell: kubectl exec -it deployment/vims-api -n ${NAMESPACE} -- /bin/sh"
|
|
echo " Delete: kubectl delete namespace ${NAMESPACE}"
|
|
|
|
echo ""
|
|
echo -e "${GREEN}✅ Deployment complete!${NC}"
|