| kubectl get pods |
List all pods in the default namespace |
kubectl get pods |
| kubectl get services |
List all services in the default namespace |
kubectl get services |
| kubectl get deployments |
List all deployments in the default namespace |
kubectl get deployments |
| kubectl get nodes |
List all nodes in the cluster |
kubectl get nodes |
| kubectl describe pod <pod-name> |
Get detailed information about a specific pod |
kubectl describe pod my-pod |
| kubectl logs <pod-name> |
View logs from a specific pod |
kubectl logs my-pod |
| kubectl exec -it <pod-name> — /bin/bash |
Open a shell in a running pod |
kubectl exec -it my-pod — /bin/bash |
| kubectl create -f <file> |
Create a resource from a file |
kubectl create -f deployment.yaml |
| kubectl apply -f <file> |
Apply changes to a resource from a file |
kubectl apply -f deployment.yaml |
| kubectl delete -f <file> |
Delete a resource defined in a file |
kubectl delete -f deployment.yaml |
| kubectl delete pod <pod-name> |
Delete a specific pod |
kubectl delete pod my-pod |
| kubectl scale deployment <deployment-name> –replicas=<number> |
Scale a deployment to a specified number of replicas |
kubectl scale deployment my-deployment –replicas=3 |
| kubectl rollout status deployment <deployment-name> |
Check the status of a deployment rollout |
kubectl rollout status deployment my-deployment |
| kubectl rollout undo deployment <deployment-name> |
Undo the last rollout of a deployment |
kubectl rollout undo deployment my-deployment |
| kubectl get configmaps |
List all config maps in the default namespace |
kubectl get configmaps |
| kubectl describe configmap <configmap-name> |
Get detailed information about a specific config map |
kubectl describe configmap my-configmap |
| kubectl get secrets |
List all secrets in the default namespace |
kubectl get secrets |
| kubectl describe secret <secret-name> |
Get detailed information about a specific secret |
kubectl describe secret my-secret |
| kubectl get namespaces |
List all namespaces in the cluster |
kubectl get namespaces |
| kubectl create namespace <namespace-name> |
Create a new namespace |
kubectl create namespace my-namespace |
| kubectl delete namespace <namespace-name> |
Delete a namespace |
kubectl delete namespace my-namespace |
| kubectl get events |
List all events in the default namespace |
kubectl get events |
| kubectl get ingress |
List all ingress resources in the default namespace |
kubectl get ingress |
| kubectl describe ingress <ingress-name> |
Get detailed information about a specific ingress resource |
kubectl describe ingress my-ingress |
| kubectl top nodes |
Display resource usage (CPU and memory) of nodes |
kubectl top nodes |
| kubectl top pods |
Display resource usage (
CPU and memory) of pods |
kubectl top pods |
| kubectl get deployments -o yaml |
List deployments in YAML format |
kubectl get deployments -o yaml |
| kubectl get pods -o json |
List pods in JSON format |
kubectl get pods -o json |
| kubectl edit deployment <deployment-name> |
Edit a deployment directly in your editor |
kubectl edit deployment my-deployment |
| kubectl patch deployment <deployment-name> -p <patch> |
Patch a deployment with a specified JSON patch |
kubectl patch deployment my-deployment -p ‘{“spec”:{“replicas”:5}}’ |
| kubectl annotate pod <pod-name> <annotation-key>=<annotation-value> |
Add an annotation to a pod |
kubectl annotate pod my-pod environment=production |
| kubectl label pod <pod-name> <label-key>=<label-value> |
Add a label to a pod |
kubectl label pod my-pod app=web |
| kubectl rollout history deployment <deployment-name> |
View the rollout history of a deployment |
kubectl rollout history deployment my-deployment |
| kubectl create secret generic <secret-name> –from-literal=<key>=<value> |
Create a generic secret |
kubectl create secret generic my-secret –from-literal=password=my-password |
| kubectl expose deployment <deployment-name> –port=<port> –target-port=<target-port> |
Expose a deployment as a service |
kubectl expose deployment my-deployment –port=80 –target-port=8080 |
| kubectl set image deployment <deployment-name> <container-name>=<image> |
Update the image of a container in a deployment |
kubectl set image deployment my-deployment my-container=my-image:latest |
| kubectl get statefulsets |
List all stateful sets in the default namespace |
kubectl get statefulsets |
| kubectl describe statefulset <statefulset-name> |
Get detailed information about a specific stateful set |
kubectl describe statefulset my-statefulset |
| kubectl get jobs |
List all jobs in the default namespace |
kubectl get jobs |
| kubectl describe job <job-name> |
Get detailed information about a specific job |
kubectl describe job my-job |
| kubectl get cronjobs |
List all cron jobs in the default namespace |
kubectl get cronjobs |
| kubectl describe cronjob <cronjob-name> |
Get detailed information about a specific cron job |
kubectl describe cronjob my-cronjob |
| kubectl get persistentvolumes |
List all persistent volumes in the cluster |
kubectl get persistentvolumes |
| kubectl describe persistentvolume <persistentvolume-name> |
Get detailed information about a specific persistent volume |
kubectl describe persistentvolume my-pv |
| kubectl get persistentvolumeclaims |
List all persistent volume claims in the default namespace |
kubectl get persistentvolumeclaims |
| kubectl describe persistentvolumeclaim <persistentvolumeclaim-name> |
Get detailed information about a specific persistent volume claim |
kubectl describe persistentvolumeclaim my-pvc |
| kubectl get endpoints |
List all endpoints in the default namespace |
kubectl get endpoints |
| kubectl describe endpoints <endpoints-name> |
Get detailed information about specific endpoints |
kubectl describe endpoints my-endpoints |
| kubectl config view |
View the kubeconfig file |
kubectl config view |
| kubectl config get-contexts |
List all contexts in the kubeconfig file |
kubectl config get-contexts |
| kubectl config use-context <context-name> |
Switch to a different context in the kubeconfig file |
kubectl config use-context my-context |
| kubectl create configmap <configmap-name> –from-file=<file-path> |
Create a config map from a file |
kubectl create configmap my-configmap –from-file=config.txt |
| kubectl replace -f <file> |
Replace a resource with the contents of a file |
kubectl replace -f deployment.yaml |
| kubectl cp <pod-name>:<source-path> <destination-path> |
Copy files or directories to and from containers |
kubectl cp my-pod:/tmp/file.txt /local/path |
|
kubectl port-forward <pod-name> <local-port>:<remote-port> |
Forward one or more local ports to a pod |
kubectl port-forward my-pod 8080:80 |
| kubectl logs <pod-name> |
View the logs for a pod |
kubectl logs my-pod |
| kubectl exec -it <pod-name> — <command> |
Execute a command in a container |
kubectl exec -it my-pod — /bin/bash |
| kubectl run <name> –image=<image> –command — <command> |
Run a new pod with a specified image and command |
kubectl run my-pod –image=my-image –command — /bin/bash |
| kubectl apply -f <file> |
Apply a configuration from a file |
kubectl apply -f deployment.yaml |
| kubectl delete -f <file> |
Delete resources defined in a file |
kubectl delete -f deployment.yaml |
| kubectl describe pod <pod-name> |
Get detailed information about a specific pod |
kubectl describe pod my-pod |
| kubectl scale deployment <deployment-name> –replicas=<number> |
Scale a deployment to a specified number of replicas |
kubectl scale deployment my-deployment –replicas=3 |
| kubectl rollout status deployment <deployment-name> |
Check the status of a deployment rollout |
kubectl rollout status deployment my-deployment |
| kubectl get events |
List events in the default namespace |
kubectl get events |
| kubectl top nodes |
Display resource usage (CPU and memory) of nodes |
kubectl top nodes |
| kubectl get pods –all-namespaces |
List all pods across all namespaces |
kubectl get pods –all-namespaces |
| kubectl get services |
List all services in the default namespace |
kubectl get services |
| kubectl get namespaces |
List all namespaces in the cluster |
kubectl get namespaces |
| kubectl create namespace <namespace-name> |
Create a new namespace |
kubectl create namespace my-namespace |
| kubectl delete namespace <namespace-name> |
Delete a namespace |
kubectl delete namespace my-namespace |
| kubectl get nodes |
List all nodes in the cluster |
kubectl get nodes |
| kubectl describe node <node-name> |
Get detailed information about a specific node |
kubectl describe node my-node |
| kubectl drain <node-name> –ignore-daemonsets |
Drain a node to prepare for maintenance |
kubectl drain my-node –ignore-daemonsets |
| kubectl cordon <node-name> |
Mark a node as unschedulable |
kubectl cordon my-node |
| kubectl uncordon <node-name> |
Mark a node as schedulable |
kubectl uncordon my-node |
| kubectl get configmaps |
List all config maps in the default namespace |
kubectl get configmaps |
| kubectl describe configmap <configmap-name> |
Get detailed information about a specific config map |
kubectl describe configmap my-configmap |
| kubectl get secrets |
List all secrets in the default namespace |
kubectl get secrets |
| kubectl describe secret <secret-name> |
Get detailed information about a specific secret |
kubectl describe secret my-secret |
| kubectl get ingresses |
List all ingress resources in the default namespace |
kubectl get ingresses |
| kubectl describe ingress <ingress-name> |
Get detailed information about a specific ingress |
kubectl describe ingress my-ingress |
| kubectl api-resources |
List all API resources available in the cluster |
kubectl api-resources |
| kubectl api-versions |
List all API versions available in the cluster |
kubectl api-versions |
| kubectl cluster-info |
Display cluster information |
kubectl cluster-info |
| kubectl top pods –containers |
Display CPU and memory usage for containers within pods |
kubectl top pods –containers |
| kubectl port-forward <service-name> <local-port>:<remote-port> |
Forward one or more local ports to a service |
kubectl port-forward my-service 8080:80 |
| kubectl exec -it <pod-name> — <command> |
Execute a command in a container |
kubectl exec -it my-pod — /bin/bash |
| kubectl create secret generic <secret-name> –from-literal=<key>=<value> |
Create a new secret |
kubectl create secret generic my-secret –from-literal=password=my-password |