Files
peikarband/docs/deployment/DEPLOYMENT_QUICK_START.md
Ehsan.Asadi 6820f0ee4f refactor: reorganize project structure for better maintainability
- Move Docker files to build/docker/
- Move CI/CD configs to build/ci/
- Move deployment configs to deploy/ (helm, k8s, argocd)
- Move config files to config/
- Move scripts to tools/
- Consolidate assets to assets/ (Reflex compatible)
- Add data/ directory for local data (gitignored)
- Update all path references in Makefile, Dockerfile, CI configs
- Add comprehensive README files for build/ and deploy/
- Update project documentation

Benefits:
- Clear separation of concerns
- Cleaner root directory
- Better developer experience
- Enterprise-grade structure
- Improved maintainability
2025-12-30 21:20:32 +03:30

260 lines
5.5 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# راهنمای سریع دیپلوی - Peikarband
راهنمای سریع برای راه‌اندازی پروژه پیکربند در Production
## 🚀 دیپلوی سریع در 10 دقیقه
### 1⃣ Harbor Registry Setup (2 دقیقه)
```bash
# لاگین به Harbor
docker login harbor.peikarband.ir
# ساخت project: peikarband
# ساخت robot account: deployer
```
### 2⃣ Kubernetes Secrets (2 دقیقه)
```bash
# Harbor pull secret
kubectl create secret docker-registry harbor-registry-secret \
--docker-server=harbor.peikarband.ir \
--docker-username=robot\$peikarband+deployer \
--docker-password="YOUR_TOKEN" \
--namespace=peikarband
# Application secrets
kubectl create secret generic peikarband-prod-secrets \
--from-literal=db-password=YOUR_DB_PASS \
--from-literal=redis-password=YOUR_REDIS_PASS \
--from-literal=secret-key=YOUR_SECRET_KEY \
--from-literal=jwt-secret-key=YOUR_JWT_KEY \
--namespace=peikarband
```
### 3⃣ ArgoCD Setup (3 دقیقه)
```bash
# نصب ArgoCD
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
# Deploy application
kubectl apply -f argocd/application.yaml
# Sync
argocd app sync peikarband
```
### 4⃣ Woodpecker CI Secrets (2 دقیقه)
در Woodpecker UI یا با CLI:
```bash
woodpecker-cli secret add --name harbor_username --value "robot\$peikarband+deployer"
woodpecker-cli secret add --name harbor_password --value "YOUR_TOKEN"
woodpecker-cli secret add --name argocd_server --value "argocd.peikarband.ir"
woodpecker-cli secret add --name argocd_token --value "YOUR_ARGOCD_TOKEN"
```
### 5⃣ Push & Deploy (1 دقیقه)
```bash
git add .
git commit -m "feat: production deployment setup"
git push origin main
# Woodpecker به صورت خودکار:
# ✅ Tests را اجرا می‌کند
# ✅ Docker image را build می‌کند
# ✅ به Harbor push می‌کند
# ✅ ArgoCD را trigger می‌کند
# ✅ در Kubernetes deploy می‌شود
```
---
## 📋 Checklist قبل از Production
### Infrastructure
- [ ] Kubernetes cluster آماده است (3+ nodes)
- [ ] Harbor registry نصب شده
- [ ] ArgoCD نصب شده
- [ ] Woodpecker CI پیکربندی شده
- [ ] cert-manager برای SSL نصب شده
- [ ] Ingress NGINX نصب شده
### Database & Cache
- [ ] PostgreSQL در دسترس است
- [ ] Redis در دسترس است
- [ ] Backup strategy تعریف شده
### DNS & SSL
- [ ] Domain به cluster اشاره می‌کند
- [ ] SSL certificate صادر شده (Let's Encrypt)
- [ ] HTTPS کار می‌کند
### Secrets & Security
- [ ] Harbor robot account ساخته شده
- [ ] Kubernetes secrets ایجاد شده
- [ ] ArgoCD token ساخته شده
- [ ] Woodpecker secrets تنظیم شده
### Monitoring
- [ ] Prometheus نصب شده (اختیاری)
- [ ] Grafana پیکربندی شده (اختیاری)
- [ ] Telegram/Slack notifications تنظیم شده
---
## 🧪 تست سریع
```bash
# Health check
curl https://peikarband.ir/ping
# Expected: {"status":"ok",...}
# Kubernetes pods
kubectl get pods -n peikarband
# Expected: 3 pods در حالت Running
# ArgoCD status
argocd app get peikarband
# Expected: Health Status: Healthy, Sync Status: Synced
# Logs
kubectl logs -f deployment/peikarband -n peikarband
```
---
## 📊 CI/CD Pipeline Flow
```mermaid
graph LR
A[Git Push] --> B[Woodpecker CI]
B --> C[Run Tests]
C --> D[Build Docker Image]
D --> E[Push to Harbor]
E --> F[Update ArgoCD]
F --> G[Deploy to K8s]
G --> H[Health Check]
H --> I[Notify Team]
```
### Pipeline Stages:
1. **Lint & Test** (2-3 min)
- Python linting (flake8, black)
- Unit tests
- Integration tests
2. **Security Scan** (1-2 min)
- Dependency vulnerabilities
- Secret scanning
- Code security analysis
3. **Build & Push** (3-5 min)
- Docker build (multi-stage)
- Trivy security scan
- Push to Harbor
4. **Deploy** (2-3 min)
- Update ArgoCD app
- Kubernetes rolling update
- Health verification
**Total Pipeline Time**: ~10-15 minutes
---
## 🔧 دستورات مفید
### Development
```bash
# Local development
make dev
# Run tests
make test
# Build Docker image
make docker-build
# Push to Harbor
make docker-login
make docker-push
```
### Deployment
```bash
# Full deploy
make k8s-deploy
# Helm lint
make helm-lint
# Helm upgrade
make helm-upgrade
```
### Monitoring
```bash
# Watch pods
kubectl get pods -n peikarband -w
# Tail logs
kubectl logs -f deployment/peikarband -n peikarband
# Port forward to app
kubectl port-forward svc/peikarband -n peikarband 8000:8000
# Describe deployment
kubectl describe deployment peikarband -n peikarband
```
### Troubleshooting
```bash
# Pod details
kubectl describe pod POD_NAME -n peikarband
# Previous logs (if crashed)
kubectl logs POD_NAME -n peikarband --previous
# Execute in pod
kubectl exec -it POD_NAME -n peikarband -- /bin/bash
# Events
kubectl get events -n peikarband --sort-by='.lastTimestamp'
```
---
## 📞 Support
- **Documentation**: [docs/deployment/PRODUCTION_DEPLOYMENT.md](docs/deployment/PRODUCTION_DEPLOYMENT.md)
- **Issues**: راهنمای کامل عیب‌یابی در مستندات
- **Team**: support@peikarband.ir
---
## 🎯 Next Steps
بعد از دیپلوی موفق:
1. ✅ تنظیم monitoring و alerting
2. ✅ پیکربندی backup strategy
3. ✅ تست load testing
4. ✅ تنظیم CI/CD برای سایر برنچ‌ها
5. ✅ مستندسازی runbooks
---
**Happy Deploying! 🚀**