Initial commit
This commit is contained in:
93
shfiles/check-k8s-status.sh
Normal file
93
shfiles/check-k8s-status.sh
Normal file
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "=========================================="
|
||||
echo "🔍 KUBERNETES DEPLOYMENT STATUS"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
echo "📦 1. PODS STATUS (All Namespaces)"
|
||||
echo "-----------------------------------"
|
||||
kubectl get pods -A -o wide
|
||||
echo ""
|
||||
|
||||
echo "📦 2. NATS-BACKEND NAMESPACE - PODS"
|
||||
echo "-----------------------------------"
|
||||
kubectl get pods -n nats-backend -o wide
|
||||
echo ""
|
||||
|
||||
echo "🌐 3. SERVICES & LOAD BALANCER"
|
||||
echo "-----------------------------------"
|
||||
kubectl get svc -n nats-backend -o wide
|
||||
echo ""
|
||||
|
||||
echo "⚖️ 4. LOAD BALANCER DETAILS"
|
||||
echo "-----------------------------------"
|
||||
kubectl get svc fastapi-lb -n nats-backend -o yaml | grep -A 10 "spec:"
|
||||
echo ""
|
||||
|
||||
echo "🚀 5. K3S KUBERNETES LOAD BALANCER PODS (klipper-lb)"
|
||||
echo "-----------------------------------"
|
||||
kubectl get pods -n kube-system -l "svccontroller.k3s.cattle.io/svcname=fastapi-lb" -o wide
|
||||
echo ""
|
||||
|
||||
echo "📊 6. DEPLOYMENTS & REPLICAS"
|
||||
echo "-----------------------------------"
|
||||
kubectl get deployments -n nats-backend -o wide
|
||||
echo ""
|
||||
|
||||
echo "📈 7. HORIZONTAL POD AUTOSCALER (HPA)"
|
||||
echo "-----------------------------------"
|
||||
kubectl get hpa -n nats-backend
|
||||
echo ""
|
||||
|
||||
echo "🔗 8. ENDPOINTS (Service Backends)"
|
||||
echo "-----------------------------------"
|
||||
kubectl get endpoints -n nats-backend
|
||||
echo ""
|
||||
|
||||
echo "🌍 9. INGRESS/GATEWAY STATUS"
|
||||
echo "-----------------------------------"
|
||||
kubectl get gateway -A 2>/dev/null || echo "No Gateway API resources found"
|
||||
kubectl get ingress -A 2>/dev/null || echo "No Ingress resources found"
|
||||
echo ""
|
||||
|
||||
echo "📋 10. RECENT EVENTS (Last 20)"
|
||||
echo "-----------------------------------"
|
||||
kubectl get events -n nats-backend --sort-by='.lastTimestamp' | tail -20
|
||||
echo ""
|
||||
|
||||
echo "💾 11. RESOURCE USAGE (CPU/Memory)"
|
||||
echo "-----------------------------------"
|
||||
kubectl top pods -n nats-backend 2>/dev/null || echo "Metrics server not available"
|
||||
kubectl top nodes 2>/dev/null || echo "Metrics server not available"
|
||||
echo ""
|
||||
|
||||
echo "🔍 12. FASTAPI POD LOGS (Last 30 lines)"
|
||||
echo "-----------------------------------"
|
||||
kubectl logs -n nats-backend -l app=fastapi-backend --tail=30 2>/dev/null || echo "No FastAPI pods found"
|
||||
echo ""
|
||||
|
||||
echo "🔍 13. WORKER POD LOGS (Last 30 lines)"
|
||||
echo "-----------------------------------"
|
||||
kubectl logs -n nats-backend -l app=nats-worker --tail=30 2>/dev/null || echo "No worker pods found"
|
||||
echo ""
|
||||
|
||||
echo "🌐 14. NETWORK FLOW CHECK"
|
||||
echo "-----------------------------------"
|
||||
echo "Load Balancer External IP/Port:"
|
||||
kubectl get svc fastapi-lb -n nats-backend -o jsonpath='{.status.loadBalancer.ingress[0].ip}:{.spec.ports[0].port}' 2>/dev/null || echo "Checking NodePort..."
|
||||
kubectl get svc fastapi-lb -n nats-backend -o jsonpath='NodePort: {.spec.ports[0].nodePort}' 2>/dev/null
|
||||
echo ""
|
||||
echo "FastAPI Service ClusterIP:"
|
||||
kubectl get svc fastapi-backend -n nats-backend -o jsonpath='{.spec.clusterIP}:{.spec.ports[0].port}' 2>/dev/null
|
||||
echo ""
|
||||
|
||||
echo "✅ 15. HEALTH CHECK"
|
||||
echo "-----------------------------------"
|
||||
kubectl run health-check --rm -i --restart=Never --image=curlimages/curl -- curl -s http://fastapi-backend.nats-backend:8000/health 2>/dev/null || echo "Health check failed"
|
||||
echo ""
|
||||
|
||||
echo "=========================================="
|
||||
echo "✅ Status Check Complete!"
|
||||
echo "=========================================="
|
||||
|
||||
19
shfiles/deploy-alaska.sh
Normal file
19
shfiles/deploy-alaska.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
# Deploy updated "alaska" stack to Kubernetes
|
||||
# Usage: ./deploy-alaska.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
NAMESPACE="alaska"
|
||||
|
||||
echo "🚀 Deploying Alaska Stack (Application & Gateway)..."
|
||||
kubectl apply -f manifests/alaska/alaska.yaml
|
||||
|
||||
echo "📊 Deploying Kubernetes Dashboard & Proxy..."
|
||||
kubectl apply -f manifests/alaska/k8s-dashboard.yaml
|
||||
|
||||
echo ""
|
||||
echo "✅ Alaska deployment applied."
|
||||
echo "📋 Current status:"
|
||||
echo " kubectl get all -n ${NAMESPACE}"
|
||||
kubectl get all -n "${NAMESPACE}" || true
|
||||
16
shfiles/deploy-core-stack.sh
Normal file
16
shfiles/deploy-core-stack.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
# Deploy "core" stack to Kubernetes
|
||||
# Usage: ./deploy-core-stack.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
NAMESPACE="core"
|
||||
|
||||
echo "🚀 Deploying Core Stack..."
|
||||
kubectl apply -k manifests/core
|
||||
|
||||
echo ""
|
||||
echo "✅ Core stack deployment applied."
|
||||
echo "📋 Current status:"
|
||||
echo " kubectl get all -n ${NAMESPACE}"
|
||||
kubectl get all -n "${NAMESPACE}"
|
||||
24
shfiles/deploy-nearle-stack.sh
Normal file
24
shfiles/deploy-nearle-stack.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# Deploy "nearle" stack to Kubernetes
|
||||
# Usage: ./deploy-nearle-stack.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
NAMESPACE="nearle"
|
||||
|
||||
echo "🔎 Ensuring namespace '${NAMESPACE}' exists..."
|
||||
kubectl apply -f manifests/nearle/nearle-namespace.yaml
|
||||
|
||||
|
||||
|
||||
echo "🚀 Deploying Services..."
|
||||
kubectl apply -f manifests/nearle/nearle-jupiter.yaml
|
||||
kubectl apply -f manifests/nearle/nearle-titan.yaml
|
||||
kubectl apply -f manifests/nearle/nearle-fiesta.yaml
|
||||
kubectl apply -f manifests/nearle/nearle-ariane.yaml
|
||||
|
||||
echo ""
|
||||
echo "✅ Nearle stack deployment applied."
|
||||
echo "📋 Current status:"
|
||||
echo " kubectl get all -n ${NAMESPACE}"
|
||||
|
||||
47
shfiles/deploy-queue-proxy.sh
Normal file
47
shfiles/deploy-queue-proxy.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
# Deploy queue.workolik.com proxy with CORS support
|
||||
|
||||
echo "🚀 Deploying Queue API Proxy with CORS..."
|
||||
|
||||
# 1. Start the proxy service
|
||||
echo "📦 Starting queue-api-proxy..."
|
||||
docker compose up -d queue-api-proxy
|
||||
|
||||
# 2. Wait a moment for it to start
|
||||
sleep 2
|
||||
|
||||
# 3. Check if it's running
|
||||
if docker ps | grep -q queue-api-proxy; then
|
||||
echo "✅ queue-api-proxy is running"
|
||||
else
|
||||
echo "❌ queue-api-proxy failed to start"
|
||||
docker logs queue-api-proxy
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 4. Test the proxy directly (bypassing Traefik)
|
||||
echo ""
|
||||
echo "🧪 Testing proxy directly..."
|
||||
curl -X OPTIONS http://localhost:8202/live/api/v1/deliveries/createdeliveries \
|
||||
-H 'Origin: https://console.nearlexpress.com' \
|
||||
-H 'Access-Control-Request-Method: POST' \
|
||||
-v 2>&1 | grep -E "access-control-allow-origin|HTTP/" | head -5
|
||||
|
||||
# 5. Test via Traefik (if accessible)
|
||||
echo ""
|
||||
echo "🧪 Testing via Traefik (HTTPS)..."
|
||||
echo " Run this command to test:"
|
||||
echo " curl -X OPTIONS https://queue.workolik.com/live/api/v1/deliveries/createdeliveries \\"
|
||||
echo " -H 'Origin: https://console.nearlexpress.com' \\"
|
||||
echo " -H 'Access-Control-Request-Method: POST' \\"
|
||||
echo " -v"
|
||||
|
||||
echo ""
|
||||
echo "✅ Deployment complete!"
|
||||
echo ""
|
||||
echo "📋 If queue.workolik.com was previously routed elsewhere, you may need to:"
|
||||
echo " 1. Remove the old router configuration"
|
||||
echo " 2. Or ensure this new router takes precedence"
|
||||
echo ""
|
||||
echo "💡 The proxy adds CORS headers and forwards to Kubernetes LoadBalancer (port 8201)"
|
||||
|
||||
68
shfiles/deploy.sh
Normal file
68
shfiles/deploy.sh
Normal file
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
# Kubernetes Deployment Script for 3-Node Cluster
|
||||
# Usage: ./deploy.sh
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 Deploying to Kubernetes (3-Node Cluster)..."
|
||||
|
||||
# Check if kubectl is available
|
||||
if ! command -v kubectl &> /dev/null; then
|
||||
echo "❌ kubectl not found. Please install kubectl first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check cluster connection
|
||||
echo "📡 Checking Kubernetes cluster connection..."
|
||||
kubectl cluster-info || {
|
||||
echo "❌ Cannot connect to Kubernetes cluster. Please configure kubectl."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check node count
|
||||
NODE_COUNT=$(kubectl get nodes --no-headers | wc -l)
|
||||
echo "📊 Cluster has $NODE_COUNT node(s)"
|
||||
|
||||
# Apply namespace
|
||||
echo "📦 Creating namespace..."
|
||||
kubectl apply -f manifests/namespace.yaml
|
||||
|
||||
# Apply secrets
|
||||
echo "🔐 Creating secrets..."
|
||||
kubectl apply -f manifests/secrets.yaml
|
||||
|
||||
# Apply FastAPI
|
||||
echo "🐍 Deploying FastAPI backend..."
|
||||
kubectl apply -f manifests/fastapi-deployment.yaml
|
||||
kubectl apply -f manifests/fastapi-service.yaml
|
||||
kubectl apply -f manifests/fastapi-hpa.yaml
|
||||
|
||||
# Apply Workers
|
||||
echo "👷 Deploying NATS workers..."
|
||||
kubectl apply -f manifests/worker-deployment.yaml
|
||||
kubectl apply -f manifests/worker-hpa.yaml
|
||||
|
||||
# Apply Gateway (optional - only if Gateway API is installed)
|
||||
read -p "Deploy Gateway API? (requires Gateway API controller) [y/N] " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "🚪 Deploying Gateway API..."
|
||||
kubectl apply -f manifests/gateway.yaml
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✅ Deployment complete!"
|
||||
echo ""
|
||||
echo "📋 Check status:"
|
||||
echo " kubectl get pods -n nats-backend -o wide"
|
||||
echo " kubectl get nodes"
|
||||
echo " kubectl get hpa -n nats-backend"
|
||||
echo ""
|
||||
echo "📊 View pod distribution across nodes:"
|
||||
echo " kubectl get pods -n nats-backend -o wide | grep -E 'NAME|fastapi|worker'"
|
||||
echo ""
|
||||
echo "📝 View logs:"
|
||||
echo " kubectl logs -f deployment/fastapi-backend -n nats-backend"
|
||||
echo " kubectl logs -f deployment/nats-worker -n nats-backend"
|
||||
echo ""
|
||||
|
||||
27
shfiles/setup-jetstream.sh
Normal file
27
shfiles/setup-jetstream.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
# Setup JetStream stream and consumer for NATS
|
||||
|
||||
echo "🚀 Setting up NATS JetStream..."
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# Check if Python is available
|
||||
if ! command -v python3 &> /dev/null; then
|
||||
echo "❌ Python3 not found. Please install Python3."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if nats-py is installed
|
||||
if ! python3 -c "import nats" 2>/dev/null; then
|
||||
echo "📦 Installing nats-py..."
|
||||
pip3 install nats-py
|
||||
fi
|
||||
|
||||
# Set environment variables
|
||||
export NATS_URL="nats://nats.workolik.com:4222"
|
||||
export NATS_USER="admin"
|
||||
export NATS_PASSWORD="package@321#"
|
||||
|
||||
# Run the setup script
|
||||
python3 scripts/setup_jetstream.py
|
||||
|
||||
Reference in New Issue
Block a user