File size: 2,480 Bytes
bab1185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

# QCrypt RNG Deployment Script
# Automates the deployment of QCrypt RNG to Kubernetes

set -e  # Exit on any error

echo "πŸš€ Starting QCrypt RNG deployment..."

# Check if kubectl is installed
if ! command -v kubectl &> /dev/null; then
    echo "❌ kubectl is not installed. Please install kubectl first."
    exit 1
fi

# Check if Docker is installed
if ! command -v docker &> /dev/null; then
    echo "❌ Docker is not installed. Please install Docker first."
    exit 1
fi

# Build the Docker image
echo "🐳 Building Docker image..."
docker build -t qcrypt-rng:latest .

# Create namespace
echo "🌐 Creating namespace..."
kubectl apply -f k8s/namespace.yaml

# Create secrets
echo "πŸ”’ Creating secrets..."
kubectl apply -f k8s/secrets.yaml

# Deploy PostgreSQL
echo "🐘 Deploying PostgreSQL..."
kubectl apply -f k8s/postgres-pvc.yaml
kubectl apply -f k8s/postgres-deployment.yaml

# Deploy Redis
echo ".Redis Deploying Redis..."
kubectl apply -f k8s/redis-deployment.yaml

# Wait for databases to be ready
echo "⏳ Waiting for databases to be ready..."
kubectl wait --for=condition=ready pod -l app=postgres -n qcrypt-rng --timeout=120s
kubectl wait --for=condition=ready pod -l app=redis -n qcrypt-rng --timeout=120s

# Deploy API
echo "πŸ“‘ Deploying API..."
kubectl apply -f k8s/api-deployment.yaml

# Deploy Dashboard
echo "πŸ“Š Deploying Dashboard..."
kubectl apply -f k8s/dashboard-deployment.yaml

# Wait for deployments to be ready
echo "⏳ Waiting for deployments to be ready..."
kubectl wait --for=condition=ready pod -l app=qcrypt-api -n qcrypt-rng --timeout=180s
kubectl wait --for=condition=ready pod -l app=qcrypt-dashboard -n qcrypt-rng --timeout=180s

# Get external IPs
echo "πŸ” Getting service endpoints..."
API_IP=$(kubectl get svc qcrypt-api-service -n qcrypt-rng -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
DASHBOARD_IP=$(kubectl get svc qcrypt-dashboard-service -n qcrypt-rng -o jsonpath='{.status.loadBalancer.ingress[0].ip}')

echo ""
echo "πŸŽ‰ QCrypt RNG deployment completed successfully!"
echo ""
echo "πŸ”— API Endpoint: http://$API_IP"
echo "πŸ”— Dashboard: http://$DASHBOARD_IP"
echo ""
echo "πŸ“ Next steps:"
echo "   1. Configure your DNS to point to the external IPs"
echo "   2. Set up SSL certificates for HTTPS"
echo "   3. Configure API keys for production use"
echo "   4. Set up monitoring and alerting"
echo ""

# Show deployment status
echo "πŸ“‹ Deployment status:"
kubectl get pods -n qcrypt-rng