# Déploiement sur AKS (Azure Kubernetes Service)

## Pré-requis
- Azure CLI (`az`), `kubectl`, Docker (présent sur le poste)
- Un registre **ACR** (Azure Container Registry)
- Un cluster **AKS**
- Une base **Azure Database for MySQL — Flexible Server**

## 1. Base de données
```bash
az mysql flexible-server create \
  --resource-group rg-formation --name mysql-formation \
  --admin-user fadmin --admin-password '***' --tier Burstable --sku-name Standard_B1ms
az mysql flexible-server db create -g rg-formation -s mysql-formation -d plateforme_formation
```

## 2. Build & push de l'image
```bash
az acr build -r acrformation -t plateforme-formation:1.0 -f deploy/Dockerfile .
```

## 3. Secrets & config
```bash
kubectl create secret generic app-secrets \
  --from-literal=APP_KEY='base64:...' \
  --from-literal=DB_PASSWORD='***' \
  --from-literal=FEDAPAY_SECRET_KEY='***' \
  --from-literal=KKIAPAY_PRIVATE_KEY='***'
kubectl apply -f deploy/k8s/configmap.yaml
```

## 4. Déploiement
```bash
kubectl apply -f deploy/k8s/deployment.yaml
kubectl apply -f deploy/k8s/service.yaml
kubectl apply -f deploy/k8s/ingress.yaml
```

## Notes
- Médias vidéo → **Azure Blob Storage** (`FILESYSTEM_DISK=azure`).
- Files d'attente → un **pod worker** séparé (`php artisan queue:work`) ou un Deployment dédié.
- Tâches planifiées → **CronJob** Kubernetes exécutant `php artisan schedule:run`.
- TLS via Ingress (cert-manager + Let's Encrypt) ou Azure Application Gateway.
- Montée en charge horizontale via **HPA** sur le Deployment.
