This commit is contained in:
Waloshi6
2026-01-27 17:34:16 +01:00
parent 4c3bd195b7
commit c8204829e9
237 changed files with 3542 additions and 1737 deletions

44
scripts/GenerKubConf.ps1 Normal file
View File

@@ -0,0 +1,44 @@
# Activer le proxy
Start-Process kubectl -ArgumentList "proxy" -WindowStyle Hidden
# Créer le ServiceAccount
kubectl create serviceaccount dashboard-admin -n kubernetes-dashboard --force
# Lui donner les droits admin
kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=kubernetes-dashboard:dashboard-admin --force
# Générer le jeton
$Token = kubectl create token dashboard-admin -n kubernetes-dashboard
# Informations du cluster
$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)
$Kubeconfig = @"
apiVersion: v1
kind: Config
clusters:
- name: $ClusterName
cluster:
server: $Server
certificate-authority-data: $CACert
contexts:
- name: $ClusterName
context:
cluster: $ClusterName
user: dashboard-admin
current-context: $ClusterName
users:
- name: dashboard-admin
user:
token: $Token
"@
# Sauvegarder
$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."