Modification des fichiers nginx et argo en .yaml pour k8' selon best practice en prod + écriture de 2 scripts vérifés et fonctionnels pour configurer le dashbord de k8' et argoced et les ouvrir dans une page web
This commit is contained in:
49
scripts/start-argocd.ps1
Normal file
49
scripts/start-argocd.ps1
Normal file
@@ -0,0 +1,49 @@
|
||||
# === 1. Appliquer le namespace principal d'abord ===
|
||||
Write-Host "🚀 Création du namespace devops-demo..."
|
||||
kubectl apply -f C:\DevOpsProject\kubernetes\manifests\namespace.yaml
|
||||
|
||||
# Attendre que le namespace soit actif
|
||||
Write-Host "⏳ Attente que le namespace devops-demo soit prêt..."
|
||||
kubectl wait --for=condition=Active namespace/devops-demo --timeout=60s
|
||||
|
||||
# === 2. Appliquer les ConfigMap et Secret (préalables à nginx) ===
|
||||
Write-Host "📦 Création du ConfigMap et Secret pour Nginx..."
|
||||
kubectl apply -f C:\DevOpsProject\kubernetes\manifests\configmap.yaml
|
||||
kubectl create secret generic nginx-tls --from-file=C:\DevOpsProject\config\certs -n devops-demo --dry-run=client -o yaml | kubectl apply -f -
|
||||
|
||||
# === 3. Appliquer tous les autres manifests (y compris nginx-proxy.yaml) ===
|
||||
Write-Host "🔄 Application des déploiements (app, db, nginx-proxy)..."
|
||||
kubectl apply -f C:\DevOpsProject\kubernetes\manifests
|
||||
|
||||
# === 4. Attendre que nginx-proxy soit prêt (dépendance critique) ===
|
||||
Write-Host "⏳ Attente que nginx-proxy soit en état Ready..."
|
||||
kubectl wait --for=condition=ready pod -l app=nginx-proxy -n devops-demo --timeout=120s
|
||||
|
||||
# === 5. Installer ArgoCD si ce n'est pas déjà fait ===
|
||||
if ($(kubectl get namespace argocd -o name) -eq $null) {
|
||||
Write-Host "🎯 Installation d'ArgoCD..."
|
||||
kubectl create namespace argocd
|
||||
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
|
||||
}
|
||||
|
||||
# Attendre que ArgoCD soit disponible
|
||||
Write-Host "⏳ Attente du déploiement d'ArgoCD..."
|
||||
kubectl wait --for=condition=available --timeout=180s -n argocd deployment/argocd-server
|
||||
|
||||
# === 6. Récupérer le mot de passe admin ===
|
||||
$Password = kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath="{.data.password}" | ForEach-Object { [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($_)) }
|
||||
|
||||
# === 7. Lancer le port-forward pour ArgoCD ===
|
||||
Start-Process kubectl -ArgumentList "port-forward svc/argocd-server -n argocd 8080:443" -WindowStyle Hidden
|
||||
|
||||
# === 8. Ouvrir l'interface ArgoCD dans le navigateur ===
|
||||
Start-Sleep -Seconds 5
|
||||
$Url = "https://localhost:8080"
|
||||
Start-Process $Url
|
||||
|
||||
# === Résumé final ===
|
||||
Write-Host "✅ Restauration terminée !"
|
||||
Write-Host "🌐 Accès ArgoCD : $Url"
|
||||
Write-Host "👤 Utilisateur : admin"
|
||||
Write-Host "🔑 Mot de passe : $Password"
|
||||
Write-Host "💡 Acceptez le certificat auto-signé dans le navigateur."
|
||||
Reference in New Issue
Block a user