# راهنمای سریع دیپلوی - 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! 🚀**