-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-minikube.ps1
More file actions
68 lines (55 loc) · 2.43 KB
/
deploy-minikube.ps1
File metadata and controls
68 lines (55 loc) · 2.43 KB
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
#!/usr/bin/env pwsh
param(
[string]$ImageTag = "latest"
)
Write-Host "Starting Minikube deployment process..." -ForegroundColor Green
Write-Host "Using image tag: $ImageTag" -ForegroundColor Cyan
# Start Minikube if not running
Write-Host "Starting Minikube..." -ForegroundColor Yellow
$minikubeStatus = minikube status
if ($LASTEXITCODE -ne 0) {
Write-Host "Starting Minikube cluster..." -ForegroundColor Yellow
minikube start
} else {
Write-Host "Minikube is already running" -ForegroundColor Green
}
# Set docker env to use minikube's docker daemon
Write-Host "Setting docker environment to Minikube..." -ForegroundColor Yellow
minikube docker-env | Invoke-Expression
# Build Docker images with specified tag (default: latest)
Write-Host "Building Docker images with tag: $ImageTag..." -ForegroundColor Yellow
docker build -t "sakanaisreal/smartsplit-backend:$ImageTag" ./backend
docker build -t "sakanaisreal/smartsplit-frontend:$ImageTag" ./frontend
# Tag as :latest as well for local development convenience
if ($ImageTag -ne "latest") {
docker tag "sakanaisreal/smartsplit-backend:$ImageTag" sakanaisreal/smartsplit-backend:latest
docker tag "sakanaisreal/smartsplit-frontend:$ImageTag" sakanaisreal/smartsplit-frontend:latest
}
# Create namespace
Write-Host "Creating namespace..." -ForegroundColor Yellow
kubectl apply -f k8s/namespace.yaml
# Apply Kubernetes configurations
Write-Host "Applying Kubernetes configurations..." -ForegroundColor Yellow
kubectl apply -f k8s/configmap.yaml
kubectl apply -f k8s/secrets.yaml
kubectl apply -f k8s/mysql/
kubectl apply -f k8s/backend/
kubectl apply -f k8s/frontend/
kubectl apply -f k8s/ingress.yaml
# Enable ingress addon
Write-Host "Enabling Ingress addon..." -ForegroundColor Yellow
minikube addons enable ingress
# Wait for pods to be ready
Write-Host "Waiting for pods to be ready..." -ForegroundColor Yellow
kubectl wait --namespace smartsplit --for=condition=ready pod --all --timeout=300s
# Get service URLs
Write-Host "`nDeployment completed!" -ForegroundColor Green
Write-Host "Getting Minikube IP..." -ForegroundColor Yellow
$minikubeIp = minikube ip
Write-Host "Minikube IP: $minikubeIp"
Write-Host "`nAccess your application:" -ForegroundColor Green
Write-Host "Frontend: http://$minikubeIp" -ForegroundColor Cyan
Write-Host "Backend API: http://$minikubeIp/api" -ForegroundColor Cyan
# Show pods status
Write-Host "`nPod Status:" -ForegroundColor Green
kubectl get pods -n smartsplit