These are the basic commands you’ll use often when working with Kubernetes. Think of them as tools to check, create, change, and fix things inside your Kubernetes system.
1. Viewing What's Running
These commands help you see what’s going on inside your Kubernetes cluster.
kubectl get pods # shows all running pods
kubectl get deployments # shows all deployments
kubectl get services # shows all services
kubectl get all # shows most resources
in the current namespace
2. Getting Detailed Information
kubectl describe pod my-pod # details about one pod
kubectl describe node my-node # details about one node
3. Creating Things
kubectl create -f my-deployment.yaml # create from file
4. Updating Things
kubectl apply -f my-deployment.yaml # update using the file
5. Deleting Things
kubectl delete pod my-pod # delete a specific pod
kubectl delete service my-service # delete a specific service
Debugging and Fixing Problems
6. Checking Logs
kubectl logs my-pod
kubectl logs my-pod -c my-container
7. Running Commands Inside a Pod
kubectl exec -it my-pod -- bash
8. Accessing a Pod from Your Local Machine
kubectl port-forward my-pod 8080:80
9. Checking Resource Usage
kubectl top pod # resource usage for each pod
kubectl top node # usage for each node
10. Understanding Resources
kubectl explain pod
kubectl explain pod.spec
Managing Apps and Workloads
11. Rolling Out Changes
kubectl rollout status deployment/my-deployment
kubectl rollout undo deployment/my-deployment
12. Scaling Your App
kubectl scale deployment/my-deployment --replicas=5
13. Editing Configurations
kubectl edit deployment my-deployment

Comments
Post a Comment