170 lines
4.6 KiB
Markdown
170 lines
4.6 KiB
Markdown
# 🚀 Déploiement Rapide AfterWork API
|
||
|
||
## ⚡ Commandes de Déploiement (Copier-Coller)
|
||
|
||
### Option 1 : Déploiement Automatique via Script PowerShell
|
||
|
||
```powershell
|
||
cd C:\Users\dadyo\PersonalProjects\mic-after-work-server-impl-quarkus-main
|
||
|
||
# Déploiement complet (build + push + deploy)
|
||
.\scripts\deploy.ps1 -Action all -Version 1.0.0
|
||
|
||
# Ou étape par étape
|
||
.\scripts\deploy.ps1 -Action build # Build Maven + Docker
|
||
.\scripts\deploy.ps1 -Action push # Push vers registry
|
||
.\scripts\deploy.ps1 -Action deploy # Déploiement K8s
|
||
|
||
# Vérifier le statut
|
||
.\scripts\deploy.ps1 -Action status
|
||
```
|
||
|
||
### Option 2 : Déploiement Manuel
|
||
|
||
```powershell
|
||
cd C:\Users\dadyo\PersonalProjects\mic-after-work-server-impl-quarkus-main
|
||
|
||
# 1. Build Maven (tests non-bloquants)
|
||
mvn clean package -DskipTests
|
||
|
||
# 2. Build Docker
|
||
docker build -f docker/Dockerfile.prod -t registry.lions.dev/afterwork-api:1.0.0 -t registry.lions.dev/afterwork-api:latest .
|
||
|
||
# 3. Push vers Registry
|
||
docker login registry.lions.dev
|
||
docker push registry.lions.dev/afterwork-api:1.0.0
|
||
docker push registry.lions.dev/afterwork-api:latest
|
||
|
||
# 4. Déploiement Kubernetes
|
||
kubectl create namespace applications --dry-run=client -o yaml | kubectl apply -f -
|
||
kubectl apply -f kubernetes/afterwork-configmap.yaml
|
||
kubectl apply -f kubernetes/afterwork-secrets.yaml
|
||
kubectl apply -f kubernetes/afterwork-deployment.yaml
|
||
kubectl apply -f kubernetes/afterwork-service.yaml
|
||
kubectl apply -f kubernetes/afterwork-ingress.yaml
|
||
|
||
# 5. Vérification
|
||
kubectl get pods -n applications -l app=afterwork-api
|
||
kubectl logs -n applications -l app=afterwork-api -f
|
||
```
|
||
|
||
### Option 3 : Déploiement via lionsctl pipeline
|
||
|
||
```bash
|
||
cd C:\Users\dadyo\PersonalProjects\mic-after-work-server-impl-quarkus-main
|
||
|
||
# Le pipeline clone le repo, build Maven, construit l’image Docker et déploie sur K8s. Remplacer <org> et <email>.
|
||
|
||
# Déploiement
|
||
lionsctl pipeline -u https://git.lions.dev/<org>/mic-after-work-server-impl-quarkus-main -b develop -j 17 -e dev -c k1 -m <email>
|
||
```
|
||
|
||
---
|
||
|
||
## ⚠️ IMPORTANT : Modifier les Secrets AVANT le Déploiement
|
||
|
||
```bash
|
||
# Éditer le fichier de secrets
|
||
notepad kubernetes/afterwork-secrets.yaml
|
||
|
||
# Changer la ligne:
|
||
# DB_PASSWORD: "CHANGE_ME_IN_PRODUCTION"
|
||
# Par le vrai mot de passe
|
||
```
|
||
|
||
---
|
||
|
||
## ✅ Vérifications Post-Déploiement
|
||
|
||
```bash
|
||
# 1. Pods en cours d'exécution
|
||
kubectl get pods -n applications -l app=afterwork-api
|
||
|
||
# 2. Health check
|
||
curl https://api.lions.dev/afterwork/q/health/ready
|
||
curl https://api.lions.dev/afterwork/q/health/live
|
||
|
||
# 3. Logs
|
||
kubectl logs -n applications -l app=afterwork-api --tail=50
|
||
|
||
# 4. Ingress
|
||
kubectl get ingress -n applications afterwork-api
|
||
```
|
||
|
||
---
|
||
|
||
## 🔧 Configuration Frontend
|
||
|
||
Une fois l'API déployée, builder l'application Flutter :
|
||
|
||
```powershell
|
||
cd C:\Users\dadyo\PersonalProjects\lions-workspace\afterwork
|
||
|
||
# Build APK production
|
||
.\build-prod.ps1 -Target apk
|
||
|
||
# Ou Build AAB pour Play Store
|
||
.\build-prod.ps1 -Target appbundle
|
||
|
||
# Les APKs seront dans:
|
||
# build/app/outputs/flutter-apk/
|
||
```
|
||
|
||
---
|
||
|
||
## 🐛 Troubleshooting Rapide
|
||
|
||
### Si les pods ne démarrent pas :
|
||
```bash
|
||
kubectl describe pod <pod-name> -n applications
|
||
kubectl logs <pod-name> -n applications
|
||
```
|
||
|
||
### Si l'API n'est pas accessible :
|
||
```bash
|
||
# Vérifier l'Ingress
|
||
kubectl describe ingress afterwork-api -n applications
|
||
|
||
# Vérifier les certificats TLS
|
||
kubectl get certificate -n applications
|
||
|
||
# Port-forward pour test direct
|
||
kubectl port-forward -n applications svc/afterwork-api 8080:8080
|
||
curl http://localhost:8080/afterwork/q/health
|
||
```
|
||
|
||
### Si la base de données est inaccessible :
|
||
```bash
|
||
# Tester la connexion DB depuis un pod
|
||
kubectl run -it --rm debug --image=postgres:15 --restart=Never -- \
|
||
psql -h postgres -U afterwork -d afterwork_db
|
||
```
|
||
|
||
---
|
||
|
||
## 📋 Checklist Pré-Déploiement
|
||
|
||
- [ ] PostgreSQL est installé et accessible sur le cluster
|
||
- [ ] La base de données `afterwork_db` existe
|
||
- [ ] L'utilisateur `afterwork` a les droits sur la base
|
||
- [ ] Le mot de passe DB est configuré dans `kubernetes/afterwork-secrets.yaml`
|
||
- [ ] Docker est installé et fonctionnel
|
||
- [ ] Accès au registry `registry.lions.dev` configuré
|
||
- [ ] kubectl configuré et accès au cluster K8s
|
||
- [ ] Ingress Controller (nginx) installé sur le cluster
|
||
- [ ] Cert-Manager installé pour les certificats SSL
|
||
|
||
---
|
||
|
||
## 🎯 Résumé des URLs
|
||
|
||
- **API Production** : `https://api.lions.dev/afterwork`
|
||
- **Health Check** : `https://api.lions.dev/afterwork/q/health`
|
||
- **Métriques** : `https://api.lions.dev/afterwork/q/metrics`
|
||
- **WebSocket** : `wss://api.lions.dev/afterwork/ws/notifications/{userId}`
|
||
|
||
---
|
||
|
||
**Temps estimé de déploiement** : 5-10 minutes
|
||
**Dernière mise à jour** : 2026-01-09
|