- 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
Deploy Directory
این دایرکتوری شامل همه فایلهای مربوط به deployment پروژه است.
📁 ساختار
deploy/
├── helm/ # Helm charts
│ └── peikarband/
│ ├── Chart.yaml # Chart metadata
│ ├── values.yaml # Default values
│ ├── values-production.yaml
│ ├── values-staging.yaml
│ └── templates/ # K8s resource templates
├── kubernetes/ # Raw K8s manifests
│ └── secrets-template.yaml
└── argocd/ # ArgoCD GitOps
├── application.yaml
├── application-staging.yaml
└── README.md
⚓ Helm Charts
نصب با Helm
Staging:
helm upgrade --install peikarband ./deploy/helm/peikarband \
--namespace staging \
--values deploy/helm/peikarband/values-staging.yaml \
--create-namespace
Production:
helm upgrade --install peikarband ./deploy/helm/peikarband \
--namespace production \
--values deploy/helm/peikarband/values-production.yaml \
--create-namespace
یا استفاده از Makefile:
make helm-upgrade NAMESPACE=production
Values Files
values.yaml: Default values (برای development)values-staging.yaml: Staging overridesvalues-production.yaml: Production overrides
مهمترین تنظیمات:
image:
repository: hub.peikarband.ir/peikarband/landing
tag: "latest"
resources:
requests:
cpu: 500m
memory: 512Mi
limits:
cpu: 1000m
memory: 1Gi
autoscaling:
enabled: true
minReplicas: 2
maxReplicas: 10
☸️ Kubernetes Manifests
Secrets
Template برای secrets:
kubectl create secret generic peikarband-secrets \
--from-file=deploy/kubernetes/secrets-template.yaml \
--namespace production
🔄 ArgoCD GitOps
Setup ArgoCD Application
Staging:
kubectl apply -f deploy/argocd/application-staging.yaml
Production:
kubectl apply -f deploy/argocd/application.yaml
Sync Policy
- Auto-sync: Enabled برای staging
- Manual sync: Required برای production
مانیتورینگ
argocd app get peikarband
argocd app sync peikarband
argocd app logs peikarband
🎯 Deployment Flow
graph LR
A[Code Push] --> B[CI Build]
B --> C[Push Image]
C --> D{Environment}
D -->|Staging| E[ArgoCD Auto-Sync]
D -->|Production| F[Manual ArgoCD Sync]
E --> G[Deploy]
F --> G
Staging Deployment
- Push به branch
main - CI builds & pushes image
- ArgoCD auto-sync
- Rolling update
Production Deployment
- Tag release (e.g.,
v1.0.0) - CI builds & pushes image با tag
- Update
values-production.yamlبا tag جدید - Manual ArgoCD sync یا
make helm-upgrade - Rolling update با health checks
🔍 Troubleshooting
Check Pod Status
kubectl get pods -n production
kubectl logs -f deployment/peikarband -n production
kubectl describe pod <pod-name> -n production
Check Helm Release
helm list -n production
helm status peikarband -n production
helm history peikarband -n production
Rollback
helm rollback peikarband <revision> -n production
# یا
kubectl rollout undo deployment/peikarband -n production
📊 Monitoring & Observability
Health Checks
- Liveness:
/pingendpoint - Readiness:
/healthendpoint - Startup: 60s timeout
Metrics
- Prometheus metrics exposed on
/metrics - Grafana dashboards
- Alert rules
Logs
- Centralized logging with Loki
- Log aggregation
- Search & filtering
🔐 Security
Secrets Management
- Kubernetes Secrets
- Sealed Secrets (recommended)
- External Secrets Operator
Network Policies
- Ingress rules defined
- Egress restrictions
- Service mesh (optional)
RBAC
- ServiceAccount per namespace
- Minimal permissions
- Pod Security Standards
🎯 Best Practices
-
Versioning
- Semantic versioning
- Tag images با versions
- Lock Helm chart versions
-
Resources
- Set requests & limits
- Monitor usage
- Right-size pods
-
Autoscaling
- HPA based on CPU/memory
- VPA for recommendations
- Cluster autoscaling
-
High Availability
- Multiple replicas (min 2)
- Pod disruption budgets
- Anti-affinity rules
-
Updates
- Rolling updates
- Health checks
- Gradual rollout