Kubernetes Cheatsheet

Essential Kubernetes Commands Namespace Operations 1 2 3 4 5 6 7 8 9 10 11 12 # List all namespaces kubectl get namespaces # Create a namespace kubectl create namespace [namespace_name] kubectl create ns devops --context myContext # Delete a namespace kubectl delete namespace devops # Set default namespace for current context kubectl config set-context --current --namespace=devops Pod Operations 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 # List pods kubectl get pods -A # All namespaces kubectl get po -A # Short form kubectl get pods -n kube-system # Specific namespace kubectl get pods -o wide # Detailed pod information kubectl get pods --watch # Watch pod status changes kubectl get pods -l label_name # Filter pods by label # Pod management kubectl logs -f pod_name # Follow pod logs kubectl logs pod_name # View pod logs kubectl exec -it pod_name -- /bin/sh # Shell into pod kubectl delete pods pod_name # Delete pod kubectl edit pod pod_name # Edit pod configuration kubectl cp pod_name:/src/path local_path # Copy from pod Deployment & ReplicaSet 1 2 3 4 5 6 # View deployments and replicasets kubectl get deployment kubectl get rs # Scale deployment kubectl scale deploy deployment_name --replicas=3 Service Operations 1 2 3 4 5 6 7 8 9 10 # List services kubectl get services kubectl get svc -w # Watch service changes # Get service details kubectl get services -n namespace service_name -o yaml # Access service (Minikube) minikube service service_name --url minikube service -n namespace_name service_name --url Storage Operations 1 2 3 4 5 6 7 8 9 # Persistent Volumes kubectl apply -f volume.yaml kubectl get pv kubectl delete pv pv_name # Persistent Volume Claims kubectl apply -f volumeClaim.yaml kubectl get pvc kubectl delete pvc pvc_name Configuration & Secrets 1 2 3 4 5 6 7 8 9 # ConfigMaps kubectl get configmap kubectl apply -f configmap.yaml # Secrets kubectl apply -f secret.yaml kubectl get secrets kubectl get secrets secret_name -o yaml kubectl get docker-registry -o yaml Helm Commands 1 2 3 4 5 6 7 8 # Get values from release helm get values release_name # Show and save chart values helm show values repo/chart > values.yaml # Upgrade release with values helm upgrade release_name repo/chart --version x.y.z -f values.yaml RBAC (Role-Based Access Control) Role Permissions create update delete get list patch watch Resource Types 1 2 3 4 kind: Role rules: - resources: ["pods", "services"] verbs: ["get", "list", "watch"] Container Lifecycle Probes 1 2 3 4 5 6 readinessProbe: exec: command: - health-check - get - status Important Concepts Resource Management Kubernetes schedules containers based on resource requests, not limits Best practice: Set equal values for requests and limits in production Deployment Controller Deployments create ReplicaSets ReplicaSets manage pod lifecycle Default policies: imagePullPolicy: Always restartPolicy: Always Security Features Resource Quotas: Limit resource usage per namespace Pod Security Policies: Restrict pod privileges RBAC: Control access to Kubernetes resources Additional Tools Security Scanning Trivy: Container vulnerability scanner Grype: Vulnerability scanner for containers Observability OpenTelemetry: Observability framework for cloud-native applications Build Tools Kaniko: Container image builder in Kubernetes Configuration Location Default config path: ~/.kube/config Windows path: C:\Users\Username.kube

 · 529 words

Vim Neomvim

“Ajouter Ouvrir avec NeoVim au menu contextuel clic droit. 1 2 3 4 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\Ouvrir avec Neovim\command] @="C:\\Program Files\\Neovim\\bin\\nvim-qt.exe -qwindowgeometry 1310x650+20+20 \"%1" Ouvrir la fenêtre de terminal 1 2 3 :terminal :te :shell

 · 37 words

Linux and Bash Command Cheatsheet

File System Navigation 1 2 3 4 5 6 7 8 9 10 # Directory operations pwd # Print working directory ls # List files ls -la # List all files with details cd directory # Change directory cd .. # Go up one directory cd ~ # Go to home directory mkdir directory # Create directory rmdir directory # Remove empty directory rm -rf directory # Remove directory and contents File Operations 1 2 3 4 5 6 7 8 9 10 # Basic file operations touch file.txt # Create empty file cp source dest # Copy file mv source dest # Move/rename file rm file # Remove file cat file # Display file contents less file # View file with pagination head -n 10 file # Show first 10 lines tail -n 10 file # Show last 10 lines tail -f file # Follow file updates File Permissions 1 2 3 4 5 6 7 8 # Change permissions chmod 755 file # Set permissions (rwxr-xr-x) chmod u+x file # Add execute permission for user chown user:group file # Change file owner and group # Permission numbers # 4 (read) + 2 (write) + 1 (execute) # Example: 755 means rwx for owner, rx for group and others Text Processing 1 2 3 4 5 6 7 8 9 10 11 # Search and filter grep pattern file # Search for pattern grep -r pattern dir # Recursive search grep -i pattern file # Case-insensitive search # Text manipulation sed 's/old/new/g' file # Replace text awk '{print $1}' file # Print first column sort file # Sort lines uniq # Remove duplicates wc -l file # Count lines System Information 1 2 3 4 5 6 7 # System resources top # Process viewer htop # Enhanced process viewer free -h # Memory usage df -h # Disk usage du -sh directory # Directory size ps aux # Process list Network Operations 1 2 3 4 5 6 7 8 9 # Network commands ping host # Test connectivity curl url # HTTP requests wget url # Download files netstat -tulpn # Show active ports ifconfig # Network interfaces ip addr # Modern interface info ssh user@host # SSH connection scp file user@host: # Secure copy SSH and Security 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 # Generate SSH key ssh-keygen -t rsa -b 4096 # Copy SSH key to server ssh-copy-id user@host # Generate SSL/TLS keys # Generate private key openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:4096 # Extract public key openssl rsa -pubout -in private_key.pem -out public_key.pem # Generate CSR (Certificate Signing Request) openssl req -new -newkey rsa:2048 -nodes -keyout domain.key -out domain.csr Process Management 1 2 3 4 5 6 7 8 # Process control ps aux | grep process # Find process kill pid # Kill process killall process # Kill by name nohup command & # Run in background bg # Background job fg # Foreground job jobs # List jobs Package Management (Ubuntu/Debian) 1 2 3 4 5 6 7 # APT commands apt update # Update package list apt upgrade # Upgrade packages apt install package # Install package apt remove package # Remove package apt search package # Search packages apt list --installed # List installed packages System Administration 1 2 3 4 5 6 7 8 9 10 11 # User management sudo command # Run as root useradd username # Create user usermod -aG group user # Add user to group passwd username # Change password # Service management systemctl start service systemctl stop service systemctl status service systemctl enable service Bash Scripting Basics 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 #!/bin/bash # Variables NAME="John" echo $NAME # Conditionals if [ "$NAME" = "John" ]; then echo "Hello John" elif [ "$NAME" = "Jane" ]; then echo "Hello Jane" else echo "Hello stranger" fi # Loops for i in {1..5}; do echo $i done # While loop while [ condition ]; do echo "Loop" done # Functions function greet() { echo "Hello $1" } greet "World" Useful Shortcuts Ctrl + C: Interrupt current process Ctrl + Z: Suspend current process Ctrl + D: Exit current shell Ctrl + L: Clear screen Ctrl + R: Search command history Ctrl + A: Go to beginning of line Ctrl + E: Go to end of line Ctrl + U: Clear line before cursor Ctrl + K: Clear line after cursor Environment Variables 1 2 3 4 5 6 7 8 9 10 11 12 13 14 # View environment variables env echo $PATH echo $HOME # Set environment variable export VAR="value" # Add to PATH export PATH=$PATH:/new/path # Permanent changes (add to ~/.bashrc) echo 'export VAR="value"' >> ~/.bashrc source ~/.bashrc

 · 821 words

Cmd Cheatsheet

dir Displays files and folders in the current directory cd, chdir Changes the directory or displays the current directory md, mkdir Creates a folder copy Copies files to another location move Moves files from one folder to another ren, rename Renames a file or a folder del Deletes files exit Exits the command line echo The echo of commands can be turned off with the command ECHO OFF or re-enabled with the command ECHO ON. This command is also useful for displaying messages on the screen. ...

 · 106 words

Docker and Docker Compose Cheatsheet

Docker Basic Commands 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 # View list of Docker images on your system docker images # Pull an image from Docker Hub docker pull image_name # Run a container from an image docker run image_name # View running containers docker ps # Kill a running container docker kill container_id # Use 'docker ps' to get the container ID # Advanced useful commands docker run --name my_container -d image_name # Run container as daemon with a custom name docker run --rm -it image_name /bin/bash # Run container interactively with terminal access Dockerfile Components FROM Specifies the base image to use for building your container. ...

 · 442 words