Aller au contenu

Quick Start: Deploy to Digital Ocean

Brouillon : cette page n'a pas encore été relue et peut être incomplète ou inexacte.

This is a condensed version for quickly deploying to Digital Ocean. For detailed instructions, see DEPLOY-DIGITAL-OCEAN.md.

Fenêtre de terminal
# Install doctl
brew install doctl # macOS
# or download from: https://github.com/digitalocean/doctl/releases
# Authenticate
doctl auth init
# Paste your API token from: https://cloud.digitalocean.com/account/api/tokens
Fenêtre de terminal
# Create cluster (takes ~5 minutes)
doctl kubernetes cluster create kili-shops-test \
--region nyc1 \
--version 1.28.2-do.0 \
--node-pool "name=worker-pool;size=s-2vcpu-4gb;count=3"
# Configure kubectl
doctl kubernetes cluster kubeconfig save kili-shops-test
# Verify
kubectl get nodes
Fenêtre de terminal
# Create registry
doctl registry create kili-shops
# Login
doctl registry login
Fenêtre de terminal
cd /Users/moise/projects/af-corp/kili-shops-microservices
# Build and push images
./scripts/do-build-and-push.sh
# Deploy with Helm
./scripts/do-deploy.sh
# Wait for Load Balancer IP (2-3 minutes)
kubectl get service api-gateway -w
# Save the EXTERNAL-IP when it appears
export BACKEND_IP=<your-external-ip>
Fenêtre de terminal
cd /Users/moise/projects/af-corp/kilimmanjaro
# Build and push frontend image
REACT_APP_API_URL="http://${BACKEND_IP}/api" ./scripts/do-build-and-push.sh
# Deploy with Helm
./scripts/do-deploy.sh ${BACKEND_IP}
# Wait for Load Balancer IP (2-3 minutes)
kubectl get service kilimmanjaro-frontend -w
# Save the EXTERNAL-IP
export FRONTEND_IP=<your-external-ip>
Fenêtre de terminal
echo "Frontend: http://${FRONTEND_IP}"
echo "Backend API: http://${BACKEND_IP}"
# Open in browser
open "http://${FRONTEND_IP}"
Fenêtre de terminal
# Check all pods are running
kubectl get pods
# Test backend API
curl http://${BACKEND_IP}/health
# Test frontend
curl http://${FRONTEND_IP}/health

Add A records in your DNS provider:

  • test.kilimmanjaro.com → ${FRONTEND_IP}
  • api.test.kilimmanjaro.com → ${BACKEND_IP}

Then rebuild frontend with domain:

Fenêtre de terminal
cd /Users/moise/projects/af-corp/kilimmanjaro
REACT_APP_API_URL="http://api.test.kilimmanjaro.com/api" ./scripts/do-build-and-push.sh
kubectl rollout restart deployment/kilimmanjaro-frontend
Fenêtre de terminal
# Delete applications
helm uninstall kilimmanjaro
helm uninstall kili-shops
# Delete PVCs
kubectl delete pvc --all
# Delete cluster
doctl kubernetes cluster delete kili-shops-test
# Delete registry
doctl registry delete kili-shops

~$98/month:

  • Kubernetes: 3 nodes × $24 = $72
  • Load Balancers: 2 × $12 = $24
  • Storage: ~$2
Fenêtre de terminal
# View pod status
kubectl get pods
# View logs
kubectl logs -f deployment/api-gateway
kubectl logs -f deployment/kilimmanjaro-frontend
# Describe pod
kubectl describe pod <pod-name>
# Check events
kubectl get events --sort-by=.metadata.creationTimestamp