139 lines
3.8 KiB
Markdown
139 lines
3.8 KiB
Markdown
# ✅ Kubernetes Setup - Ready to Deploy!
|
|
|
|
## 🎯 Everything is Configured and Ready
|
|
|
|
### ✅ What's Set Up
|
|
|
|
1. **Kubernetes Manifests** (`kubernetes/manifests/`)
|
|
- ✅ `namespace.yaml` - Namespace for your app
|
|
- ✅ `secrets.yaml` - NATS credentials and external API config
|
|
- ✅ `fastapi-deployment.yaml` - FastAPI backend (4 replicas, auto-scaling)
|
|
- ✅ `fastapi-service.yaml` - Service on port 8000
|
|
- ✅ `fastapi-hpa.yaml` - Horizontal Pod Autoscaler (4-20 pods)
|
|
- ✅ `worker-deployment.yaml` - NATS workers (2 replicas, auto-scaling)
|
|
- ✅ `worker-hpa.yaml` - Worker autoscaler (2-10 pods)
|
|
- ✅ `gateway.yaml` - Gateway API (ports 8201/8441 - no conflict with Traefik)
|
|
- ✅ `dashboard.yaml` - Kubernetes Dashboard UI
|
|
|
|
2. **Deployment Scripts**
|
|
- ✅ `simple-deploy.sh` - One-command deployment
|
|
- ✅ `deploy-dashboard.sh` - Dashboard deployment
|
|
- ✅ `setup-jetstream.sh` - JetStream setup
|
|
|
|
3. **Configuration**
|
|
- ✅ Port conflicts resolved (8201/8441 instead of 80/443)
|
|
- ✅ Image pull policy set to `Never` (uses local containerd images)
|
|
- ✅ NATS connection configured (external NATS server)
|
|
- ✅ External API endpoints configured
|
|
- ✅ HTTP methods correctly forwarded (PUT for update delivery)
|
|
|
|
4. **Documentation**
|
|
- ✅ `DEPLOY_CHECKLIST.md` - Step-by-step deployment guide
|
|
- ✅ `DASHBOARD_SETUP.md` - Dashboard access guide
|
|
- ✅ `README.md` - Main documentation
|
|
|
|
## 🚀 Quick Deployment Steps
|
|
|
|
### Step 1: Start k3s (if not running)
|
|
```bash
|
|
sudo systemctl start k3s
|
|
sudo systemctl status k3s
|
|
```
|
|
|
|
### Step 2: Build and Import Docker Images
|
|
```bash
|
|
cd ~/kubernetes
|
|
|
|
# Build images
|
|
docker build -t fastapi-backend:latest --target api -f Dockerfile .
|
|
docker build -t nats-worker:latest --target worker -f Dockerfile .
|
|
|
|
# Import to containerd (k3s uses containerd)
|
|
docker save fastapi-backend:latest | sudo k3s ctr images import -
|
|
docker save nats-worker:latest | sudo k3s ctr images import -
|
|
```
|
|
|
|
### Step 3: Setup JetStream
|
|
```bash
|
|
chmod +x setup-jetstream.sh
|
|
./setup-jetstream.sh
|
|
```
|
|
|
|
### Step 4: Deploy Everything
|
|
```bash
|
|
chmod +x simple-deploy.sh
|
|
./simple-deploy.sh
|
|
```
|
|
|
|
### Step 5: Deploy Dashboard (Optional)
|
|
```bash
|
|
chmod +x deploy-dashboard.sh
|
|
./deploy-dashboard.sh
|
|
```
|
|
|
|
## 🔍 Verify Deployment
|
|
|
|
```bash
|
|
# Check pods
|
|
kubectl get pods -n nats-backend
|
|
|
|
# Check services
|
|
kubectl get svc -n nats-backend
|
|
|
|
# Check Gateway
|
|
kubectl get gateway -n nats-backend
|
|
|
|
# Check HPA
|
|
kubectl get hpa -n nats-backend
|
|
```
|
|
|
|
## 🖥️ Access Dashboard
|
|
|
|
```bash
|
|
# Start proxy
|
|
kubectl proxy
|
|
|
|
# Visit in browser:
|
|
# http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
|
|
```
|
|
|
|
Or use port-forward:
|
|
```bash
|
|
kubectl port-forward -n kubernetes-dashboard service/kubernetes-dashboard 9090:9090
|
|
# Visit: http://localhost:9090
|
|
```
|
|
|
|
## 📊 What You'll See in Dashboard
|
|
|
|
- **Namespaces:** `nats-backend`, `kubernetes-dashboard`
|
|
- **Pods:** FastAPI pods, Worker pods, Dashboard pod
|
|
- **Services:** FastAPI service, Dashboard service
|
|
- **Deployments:** All your deployments
|
|
- **HPA:** Autoscaling configurations
|
|
- **Resources:** CPU, Memory usage
|
|
- **Logs:** View logs from any pod
|
|
- **Events:** Cluster events and errors
|
|
|
|
## ⚙️ Configuration Summary
|
|
|
|
| Component | Configuration |
|
|
|-----------|--------------|
|
|
| **FastAPI** | 4 initial pods, scales 4-20, port 8000 |
|
|
| **Workers** | 2 initial pods, scales 2-10 |
|
|
| **Gateway** | Ports 8201 (HTTP), 8441 (HTTPS) |
|
|
| **NATS** | External: `nats://nats.workolik.com:4222` |
|
|
| **Domain** | `queue.workolik.com` |
|
|
| **External API** | `https://jupiter.nearle.app` |
|
|
|
|
## ✅ All Systems Ready!
|
|
|
|
Everything is configured and ready to deploy. Just follow the steps above!
|
|
|
|
**Need help?** Check:
|
|
- `DEPLOY_CHECKLIST.md` - Detailed deployment guide
|
|
- `DASHBOARD_SETUP.md` - Dashboard access options
|
|
- `README.md` - Full documentation
|
|
|
|
🎉 **You're all set!**
|
|
|