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:
@@ -1,11 +1,17 @@
|
||||
# Activer le proxy
|
||||
# Installer le dashboard Kubernetes s'il n'existe pas
|
||||
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml 2>$null
|
||||
|
||||
# Démarrer le proxy Kubernetes
|
||||
Start-Process kubectl -ArgumentList "proxy" -WindowStyle Hidden
|
||||
|
||||
# Créer le ServiceAccount
|
||||
kubectl create serviceaccount dashboard-admin -n kubernetes-dashboard --force
|
||||
# Attendre que le proxy soit prêt
|
||||
Start-Sleep -Seconds 5
|
||||
|
||||
# Lui donner les droits admin
|
||||
kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=kubernetes-dashboard:dashboard-admin --force
|
||||
# Créer le ServiceAccount (pas de --force, gestion propre)
|
||||
if ($(kubectl get serviceaccount dashboard-admin -n kubernetes-dashboard -o name) -eq $null) {
|
||||
kubectl create serviceaccount dashboard-admin -n kubernetes-dashboard
|
||||
kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=kubernetes-dashboard:dashboard-admin
|
||||
}
|
||||
|
||||
# Générer le jeton
|
||||
$Token = kubectl create token dashboard-admin -n kubernetes-dashboard
|
||||
@@ -15,7 +21,7 @@ $ClusterName = kubectl config current-context
|
||||
$Server = kubectl config view -o jsonpath="{.clusters[?(@.name==`"$ClusterName`")].cluster.server}"
|
||||
$CACert = kubectl config view -o jsonpath="{.clusters[?(@.name==`"$ClusterName`")].cluster.certificate-authority-data}"
|
||||
|
||||
# Générer le kubeconfig avec token uniquement (pas de certificats)
|
||||
# Générer le kubeconfig
|
||||
$Kubeconfig = @"
|
||||
apiVersion: v1
|
||||
kind: Config
|
||||
@@ -40,5 +46,10 @@ users:
|
||||
$Kubeconfig | Out-File -FilePath "C:\DevOpsProject\scripts\dashboard.kubeconfig" -Encoding UTF8
|
||||
|
||||
Write-Host "✅ kubeconfig généré : C:\DevOpsProject\scripts\dashboard.kubeconfig"
|
||||
Write-Host "Accédez au dashboard : http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/"
|
||||
Write-Host "→ Choisissez 'Kubeconfig' et sélectionnez le fichier."
|
||||
|
||||
# Ouvrir le navigateur
|
||||
$Url = "http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/"
|
||||
Start-Process $Url
|
||||
|
||||
Write-Host "🌐 Dashboard ouvert dans le navigateur."
|
||||
Write-Host "→ Choisissez 'Kubeconfig' et sélectionnez le fichier généré."
|
||||
Reference in New Issue
Block a user