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
This commit is contained in:
154
deploy/argocd/README.md
Normal file
154
deploy/argocd/README.md
Normal file
@@ -0,0 +1,154 @@
|
||||
# ArgoCD Deployment
|
||||
|
||||
This directory contains ArgoCD Application manifests for deploying Peikarband to Kubernetes.
|
||||
|
||||
## Files
|
||||
|
||||
- `application.yaml`: Production deployment (main branch → peikarband namespace)
|
||||
- `application-staging.yaml`: Staging deployment (develop branch → peikarband-staging namespace)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. ArgoCD installed in your cluster
|
||||
2. Git repository access configured in ArgoCD
|
||||
3. Docker registry credentials (if using private registry)
|
||||
|
||||
## Deployment
|
||||
|
||||
### 1. Add Git Repository to ArgoCD
|
||||
|
||||
```bash
|
||||
# For HTTPS with token
|
||||
argocd repo add https://git.peikarband.ir/ehsan-minadd/peikarband.git \
|
||||
--username YOUR_USERNAME \
|
||||
--password YOUR_ACCESS_TOKEN
|
||||
|
||||
# Or using argocd UI: Settings → Repositories → Connect Repo
|
||||
```
|
||||
|
||||
### 2. Deploy Production
|
||||
|
||||
```bash
|
||||
kubectl apply -f argocd/application.yaml
|
||||
```
|
||||
|
||||
### 3. Deploy Staging
|
||||
|
||||
```bash
|
||||
kubectl apply -f argocd/application-staging.yaml
|
||||
```
|
||||
|
||||
## Sync Policy
|
||||
|
||||
Both applications use **automatic sync** with:
|
||||
- **Auto-prune**: Remove resources deleted from Git
|
||||
- **Self-heal**: Automatically sync when cluster state differs from Git
|
||||
- **Retry logic**: 5 attempts with exponential backoff
|
||||
|
||||
## Monitoring
|
||||
|
||||
```bash
|
||||
# Check application status
|
||||
argocd app get peikarband
|
||||
argocd app get peikarband-staging
|
||||
|
||||
# Watch sync progress
|
||||
argocd app sync peikarband --watch
|
||||
|
||||
# View logs
|
||||
argocd app logs peikarband
|
||||
```
|
||||
|
||||
## Manual Sync
|
||||
|
||||
```bash
|
||||
# Force sync
|
||||
argocd app sync peikarband --force
|
||||
|
||||
# Sync with prune
|
||||
argocd app sync peikarband --prune
|
||||
```
|
||||
|
||||
## Rollback
|
||||
|
||||
```bash
|
||||
# List history
|
||||
argocd app history peikarband
|
||||
|
||||
# Rollback to specific revision
|
||||
argocd app rollback peikarband <REVISION>
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────┐
|
||||
│ ArgoCD │
|
||||
│ ┌───────────────────┐ ┌──────────────────┐ │
|
||||
│ │ Production App │ │ Staging App │ │
|
||||
│ │ (main branch) │ │ (develop branch) │ │
|
||||
│ └─────────┬─────────┘ └────────┬─────────┘ │
|
||||
└────────────┼─────────────────────┼──────────────┘
|
||||
│ │
|
||||
▼ ▼
|
||||
┌────────────────┐ ┌─────────────────┐
|
||||
│ namespace: │ │ namespace: │
|
||||
│ peikarband │ │ peikarband-stg │
|
||||
└────────────────┘ └─────────────────┘
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Override via Helm values:
|
||||
|
||||
```yaml
|
||||
# In values-production.yaml or values-staging.yaml
|
||||
env:
|
||||
- name: DATABASE_URL
|
||||
value: "postgresql://..."
|
||||
- name: REDIS_URL
|
||||
value: "redis://..."
|
||||
```
|
||||
|
||||
## Secrets Management
|
||||
|
||||
Secrets should be managed outside Git:
|
||||
|
||||
```bash
|
||||
# Using kubectl
|
||||
kubectl create secret generic peikarband-secrets \
|
||||
--from-literal=database-password=xxx \
|
||||
--namespace=peikarband
|
||||
|
||||
# Or using Sealed Secrets, External Secrets Operator, etc.
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Application Out of Sync
|
||||
|
||||
```bash
|
||||
argocd app sync peikarband --force
|
||||
```
|
||||
|
||||
### Image Pull Errors
|
||||
|
||||
Check registry credentials:
|
||||
```bash
|
||||
kubectl get secret regcred -n peikarband -o yaml
|
||||
```
|
||||
|
||||
### Health Check Failing
|
||||
|
||||
View pod logs:
|
||||
```bash
|
||||
kubectl logs -n peikarband -l app=peikarband --tail=100
|
||||
```
|
||||
|
||||
### Helm Values Override Not Working
|
||||
|
||||
Verify values file path in Application manifest:
|
||||
```bash
|
||||
argocd app manifests peikarband | grep valueFiles
|
||||
```
|
||||
|
||||
58
deploy/argocd/application-staging.yaml
Normal file
58
deploy/argocd/application-staging.yaml
Normal file
@@ -0,0 +1,58 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: peikarband-staging
|
||||
namespace: argocd
|
||||
annotations:
|
||||
notifications.argoproj.io/subscribe.on-deployed.telegram: ""
|
||||
notifications.argoproj.io/subscribe.on-sync-failed.telegram: ""
|
||||
finalizers:
|
||||
- resources-finalizer.argocd.argoproj.io
|
||||
labels:
|
||||
app: peikarband
|
||||
environment: staging
|
||||
spec:
|
||||
project: default
|
||||
|
||||
source:
|
||||
repoURL: https://git.peikarband.ir/ehsan-minadd/peikarband.git
|
||||
targetRevision: develop
|
||||
path: helm/peikarband
|
||||
helm:
|
||||
releaseName: peikarband-staging
|
||||
valueFiles:
|
||||
- values-staging.yaml
|
||||
parameters:
|
||||
- name: image.repository
|
||||
value: harbor.peikarband.ir/peikarband/landing
|
||||
- name: image.tag
|
||||
value: develop
|
||||
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: peikarband-staging
|
||||
|
||||
syncPolicy:
|
||||
automated:
|
||||
prune: true
|
||||
selfHeal: true
|
||||
allowEmpty: false
|
||||
syncOptions:
|
||||
- CreateNamespace=true
|
||||
- PrunePropagationPolicy=foreground
|
||||
- PruneLast=true
|
||||
retry:
|
||||
limit: 5
|
||||
backoff:
|
||||
duration: 5s
|
||||
factor: 2
|
||||
maxDuration: 3m
|
||||
|
||||
revisionHistoryLimit: 10
|
||||
|
||||
ignoreDifferences:
|
||||
- group: apps
|
||||
kind: Deployment
|
||||
jsonPointers:
|
||||
- /spec/replicas
|
||||
|
||||
64
deploy/argocd/application.yaml
Normal file
64
deploy/argocd/application.yaml
Normal file
@@ -0,0 +1,64 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: peikarband
|
||||
namespace: argocd
|
||||
annotations:
|
||||
notifications.argoproj.io/subscribe.on-deployed.telegram: ""
|
||||
notifications.argoproj.io/subscribe.on-health-degraded.telegram: ""
|
||||
notifications.argoproj.io/subscribe.on-sync-failed.telegram: ""
|
||||
finalizers:
|
||||
- resources-finalizer.argocd.argoproj.io
|
||||
labels:
|
||||
app: peikarband
|
||||
environment: production
|
||||
spec:
|
||||
project: default
|
||||
|
||||
source:
|
||||
repoURL: https://git.peikarband.ir/ehsan-minadd/peikarband.git
|
||||
targetRevision: main
|
||||
path: helm/peikarband
|
||||
helm:
|
||||
releaseName: peikarband
|
||||
valueFiles:
|
||||
- values-production.yaml
|
||||
parameters:
|
||||
- name: image.repository
|
||||
value: harbor.peikarband.ir/peikarband/landing
|
||||
- name: image.tag
|
||||
value: latest # This will be updated by CI/CD
|
||||
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: peikarband
|
||||
|
||||
syncPolicy:
|
||||
automated:
|
||||
prune: true
|
||||
selfHeal: true
|
||||
allowEmpty: false
|
||||
syncOptions:
|
||||
- CreateNamespace=true
|
||||
- PrunePropagationPolicy=foreground
|
||||
- PruneLast=true
|
||||
- ApplyOutOfSyncOnly=true
|
||||
retry:
|
||||
limit: 5
|
||||
backoff:
|
||||
duration: 5s
|
||||
factor: 2
|
||||
maxDuration: 3m
|
||||
|
||||
revisionHistoryLimit: 10
|
||||
|
||||
ignoreDifferences:
|
||||
- group: apps
|
||||
kind: Deployment
|
||||
jsonPointers:
|
||||
- /spec/replicas
|
||||
- group: apps
|
||||
kind: StatefulSet
|
||||
jsonPointers:
|
||||
- /spec/replicas
|
||||
|
||||
Reference in New Issue
Block a user