🔧 1. Cluster Info and Context
kubectl cluster-info # Display cluster endpoint info
kubectl config get-contexts # List contexts
kubectl config use-context <context-name> # Switch to a specific context
kubectl get nodes # List all worker/master nodes
kubectl describe node <node-name> # Detailed info about a node
📦 2. Pods
kubectl get pods # List all pods in the current namespace
kubectl get pods -A # List all pods in all namespaces
kubectl describe pod <pod-name> # Show detailed info about a pod
kubectl logs <pod-name> # View logs of a pod
kubectl logs -f <pod-name> # Stream logs
kubectl exec -it <pod-name> -- /bin/bash # Get shell access inside a pod
kubectl delete pod <pod-name> # Delete a pod
🚀 3. Deployments
kubectl get deployments # List deployments
kubectl describe deployment <name> # Show details of a deployment
kubectl apply -f <deployment.yaml> # Apply/update deployment from YAML
kubectl rollout restart deployment <name> # Restart the deployment
kubectl delete deployment <name> # Delete a deployment
📡 4. Services
kubectl get svc # List services in current namespace
kubectl get svc -A # List services in all namespaces
kubectl describe svc <service-name> # Show detailed info about a service
kubectl port-forward svc/<name> <local-port>:<svc-port> # Forward port
📂 5. Namespaces
kubectl get namespaces # List all namespaces
kubectl create namespace <name> # Create a new namespace
kubectl delete namespace <name> # Delete a namespace
🔄 6. ConfigMaps & Secrets
kubectl get configmaps # List ConfigMaps
kubectl describe configmap <name> # View ConfigMap details
kubectl get secrets # List Secrets
kubectl describe secret <name> # View Secret details
🌐 7. Ingress
kubectl get ingress # List Ingress resources
kubectl describe ingress <name> # Detailed info about an Ingress
📄 8. Apply/Update/Delete YAML
kubectl apply -f <file.yaml> # Create or update resources
kubectl delete -f <file.yaml> # Delete resources from file
kubectl create -f <file.yaml> # Strictly create resources (error if exists)
🧠 9. Debugging / Events
kubectl get events # View recent events in cluster
kubectl describe <resource> <name> # Show detailed info (works with pods, svc, etc.)
📋 10. Miscellaneous
kubectl top pod # View CPU/memory usage (metrics-server required)
kubectl top node # View resource usage of nodes
kubectl api-resources # List all supported resource types
kubectl explain <resource> # Get documentation on a resource (e.g. deployment)
No comments:
Post a Comment