_OPTIDIEN-TECH

K8S_CLUSTER_CONTROL

KUBECTL_v1.30_CONNECTED

01_Context_Cluster

  • kubectl cluster-info - État du cluster
  • kubectl config get-contexts - Liste contextes
  • kubectl config use-context [n] - Switch cluster
  • kubectl config set-context --current --namespace=[n] - Set NS def.
  • kubectl get nodes - Liste les nœuds
  • kubectl describe node [n] - Détails ressources nœud
  • kubectl get namespaces - Liste Namespaces
  • kubectl api-resources - Liste types ressources
  • kubectl version --short - Version K8s

02_Pods_Runtime

  • kubectl get pods - Pods NS actuel
  • kubectl get pods -A - Tous les Namespaces
  • kubectl get pod [p] -o wide - Avec IP et Node
  • kubectl run [n] --image=[i] - Lancer Pod rapide
  • kubectl describe pod [p] - Debug events Pod
  • kubectl delete pod [p] - Suppr Pod
  • kubectl get pod [p] -o yaml - Export YAML
  • kubectl label pod [p] app=v1 - Ajouter label
  • kubectl annotate pod [p] [a] - Annoter

03_Deploy_Scale

  • kubectl get deploy - Liste Deployments
  • kubectl scale deploy [d] --replicas=5 - Scaler
  • kubectl rollout status deploy [d] - Suivre MAJ
  • kubectl rollout history deploy [d] - Historique
  • kubectl rollout undo deploy [d] - Rollback
  • kubectl set image deploy [d] [c]=[i] - MAJ image
  • kubectl autoscale deploy [d] --min=2 --max=10 - HPA
  • kubectl get rs - Liste ReplicaSets

04_Network_Svc

  • kubectl get svc - Liste Services
  • kubectl expose deploy [d] --port=80 - Créer SVC
  • kubectl get ingress - Liste Ingress
  • kubectl get endpoints - Liste Endpoints
  • kubectl port-forward [p] 8080:80 - Tunnel local
  • kubectl proxy - Proxy API Server
  • kubectl get networkpolicy - Liste NetPol

05_Config_Storage

  • kubectl get cm - Liste ConfigMaps
  • kubectl get secret - Liste Secrets
  • kubectl create secret generic [n] - Créer Secret
  • kubectl get pv - Persistent Volumes
  • kubectl get pvc - PV Claims
  • kubectl get storageclass - Classes de stockage
  • kubectl edit cm [n] - Edit Live Config

06_Debug_Logs

  • kubectl logs [p] - Voir les logs
  • kubectl logs -f [p] -c [container] - Follow log
  • kubectl exec -it [p] -- sh - Shell interactif
  • kubectl top pod - Usage CPU/RAM Pods
  • kubectl top node - Usage CPU/RAM Nodes
  • kubectl get events --sort-by=.metadata.creationTimestamp - Events
  • kubectl auth can-i [verb] [res] - Check RBAC

07_Advanced_Ops

  • kubectl apply -f [file.yaml] - Déployer YAML
  • kubectl diff -f [file.yaml] - Diff local/cluster
  • kubectl patch [res] [n] -p [patch] - Patch rapide
  • kubectl replace --force -f [f] - Re-créer
  • kubectl cordon [node] - Marquer unschedulable
  • kubectl drain [node] - Vider le nœud
  • kubectl uncordon [node] - Réactiver nœud
  • kubectl explain pod.spec - Doc interactive

08_Helm_Basics

  • helm install [n] [chart] - Installer App
  • helm list -A - Voir toutes releases
  • helm upgrade [n] [chart] - Mettre à jour
  • helm uninstall [n] - Suppr release
  • helm repo add [n] [url] - Ajouter repo
  • helm rollback [n] [rev] - Revenir arrière
  • helm template [n] [chart] - Debug YAML

09_K8s_Power_Tools

  • alias k='kubectl' - Alias ultime
  • k9s - TUI incroyable pour K8s
  • kubectx - Switch context rapide
  • kubens - Switch namespace rapide

10_Troubleshooting_Flow

Séquence de survie :

1. kubectl get pods (Check status)
2. kubectl describe pod [n] (Check Events/Errors)
3. kubectl logs [n] --tail=100 (Check App Logs)
4. kubectl exec -it [n] -- curl localhost:port (Check Net)