Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DevOps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CLEMENTE Damien
DevOps
Commits
5401b631
Commit
5401b631
authored
4 months ago
by
CLEMENTE Damien
Browse files
Options
Downloads
Patches
Plain Diff
Update file 9.Aide_Kubernetes.md
parent
3a32c1f4
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
9.Aide_Kubernetes.md
+179
-0
179 additions, 0 deletions
9.Aide_Kubernetes.md
with
179 additions
and
0 deletions
9.Aide_Kubernetes.md
0 → 100644
+
179
−
0
View file @
5401b631
# 📌 Commandes Utiles pour Kubernetes
## 🔧 Dépannage Kubernetes
### 📄 Afficher les logs d’un pod
```
sh
kubectl logs <pod-name>
kubectl logs <pod-name>
-n
<namespace>
kubectl logs <pod-name>
-c
<container-name>
kubectl logs
-f
<pod-name>
# Logs en temps réel
```
### 🚀 Vérifier l’état des pods
```
sh
kubectl get pods
kubectl get pods
-A
kubectl get pods
-o
wide
kubectl get pods
-n
<namespace>
kubectl get pods
--show-labels
kubectl get pods
--field-selector
=
status.phase
=
Running
```
### 🔍 Débugger un pod
```
sh
kubectl describe pod <pod-name>
kubectl describe pod <pod-name>
-n
<namespace>
kubectl
exec
-it
<pod-name>
--
/bin/sh
# Accéder à un conteneur
kubectl
exec
-it
<pod-name>
-c
<container-name>
--
/bin/sh
kubectl attach
-it
<pod-name>
# Attacher un terminal interactif
```
### 🏗 Dépannage des nodes
```
sh
kubectl get nodes
kubectl describe node <node-name>
kubectl get nodes
-o
wide
kubectl cordon <node-name>
# Marquer un node comme non planifiable
kubectl drain <node-name>
--ignore-daemonsets
--delete-local-data
# Vider un node
kubectl uncordon <node-name>
# Rendre le node à nouveau planifiable
```
### 🔧 Debug d’un service
```
sh
kubectl get svc
kubectl get svc
-n
<namespace>
kubectl describe svc <service-name>
kubectl get endpoints <service-name>
```
### 🌐 Vérifier les ingress
```
sh
kubectl get ingress
kubectl describe ingress <ingress-name>
```
### 🔀 Vérifier les réseaux
```
sh
kubectl get networkpolicy
kubectl describe networkpolicy <networkpolicy-name>
```
### 📦 Vérifier les volumes et le stockage
```
sh
kubectl get pvc
kubectl describe pvc <pvc-name>
kubectl get pv
kubectl describe pv <pv-name>
```
---
## 📜 Commandes Générales Kubernetes
### 📌 Gestion des ressources
#### 🗃 Liste des ressources
```
sh
kubectl api-resources
```
#### 🎯 Gestion des pods
```
sh
kubectl get pods
kubectl get pods
-n
<namespace>
kubectl get pods
-o
yaml
kubectl delete pod <pod-name>
kubectl delete pod <pod-name>
--grace-period
=
0
--force
kubectl rollout restart deployment <deployment-name>
# Redémarrer un déploiement
```
#### ⚙ Gestion des deployments
```
sh
kubectl get deployments
kubectl get deployments
-o
wide
kubectl describe deployment <deployment-name>
kubectl scale deployment <deployment-name>
--replicas
=
3
kubectl rollout
history
deployment <deployment-name>
kubectl rollout undo deployment <deployment-name>
```
#### 🎭 Gestion des services
```
sh
kubectl get svc
kubectl get svc
-o
wide
kubectl delete svc <service-name>
```
#### 🔄 Gestion des configmaps et secrets
```
sh
kubectl get configmap
kubectl describe configmap <configmap-name>
kubectl create configmap <configmap-name>
--from-literal
=
key
=
value
kubectl get secret
kubectl describe secret <secret-name>
kubectl create secret generic <secret-name>
--from-literal
=
key
=
value
```
#### 🏗 Gestion des namespaces
```
sh
kubectl get namespaces
kubectl create namespace <namespace>
kubectl delete namespace <namespace>
```
#### 📊 Ressources et monitoring
```
sh
kubectl top nodes
kubectl top pods
kubectl top pods
--containers
```
#### 🎯 Récupérer l’IP d’un service ou pod
```
sh
kubectl get svc <service-name>
-o
jsonpath
=
'{.spec.clusterIP}'
kubectl get pod <pod-name>
-o
jsonpath
=
'{.status.podIP}'
```
#### 📥 Appliquer un fichier de configuration
```
sh
kubectl apply
-f
<file.yaml>
kubectl delete
-f
<file.yaml>
kubectl replace
-f
<file.yaml>
```
---
## 🔥 Commandes Avancées
### 🚧 Simuler une panne dans un pod (chaos engineering)
```
sh
kubectl
exec
-it
<pod-name>
--
kill
1
kubectl delete pod <pod-name>
```
### 🧩 Vérifier la connectivité réseau entre les pods
```
sh
kubectl
exec
-it
<pod-name>
--
ping <other-pod-ip>
kubectl
exec
-it
<pod-name>
--
curl <service-name>:<port>
```
### 📶 Debug d’un container via un conteneur temporaire
```
sh
kubectl debug pod/<pod-name>
-it
--image
=
busybox
```
### 🏗 Gérer les labels et annotations
```
sh
kubectl label pod <pod-name>
env
=
production
kubectl annotate pod <pod-name>
description
=
"Ce pod est utilisé pour la production"
```
### 🔥 Purger tous les pods en erreur
```
sh
kubectl get pods |
grep
Evicted |
awk
'{print $1}'
| xargs kubectl delete pod
kubectl delete pod
--field-selector
=
status.phase
==
Failed
```
---
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment