DEV Community

Cover image for My Top 50 kubectl Commands for CKA and Daily Kubernetes Administration
Shahzad Ali Ahmad
Shahzad Ali Ahmad

Posted on • Originally published at Medium

My Top 50 kubectl Commands for CKA and Daily Kubernetes Administration

During my CKA preparation, I realized that one of the biggest differences between knowing Kubernetes and working efficiently with Kubernetes was mastering kubectl.

In the beginning, I understood concepts like Pods, Deployments, Services, and Storage. However, when solving hands-on labs and mock exams, I often found myself spending too much time trying to remember commands or searching for syntax.

Over time, I built a personal list of kubectl commands that I used repeatedly during practice sessions. These commands helped me troubleshoot faster, manage workloads more efficiently, and save valuable time during the exam.

Even after earning the Certified Kubernetes Administrator (CKA) certification, many of these commands remain part of my daily workflow as a DevOps Engineer.

In this article, I’ll share my top 50 kubectl commands, along with the commands I believe every Kubernetes administrator should master.

Why kubectl Matters
kubectl is the primary interface for interacting with Kubernetes clusters.

Whether you’re:

  • Deploying applications
  • Managing resources
  • Troubleshooting issues
  • Monitoring workloads
  • Configuring networking
  • Managing storage

kubectl becomes your most important tool.

The faster and more comfortable you are with kubectl, the more effective you’ll be both during the CKA exam and in real-world Kubernetes administration.

If You Only Learn 10 Commands, Learn These First
If you’re new to Kubernetes or preparing for CKA, start with these commands:

kubectl get pods -A
kubectl describe pod <pod-name>
kubectl logs <pod-name>
kubectl exec -it <pod-name> -- sh
kubectl get events
kubectl get nodes
kubectl get svc
kubectl rollout undo deployment/<deployment-name>
kubectl explain deployment.spec
kubectl top pods
Enter fullscreen mode Exit fullscreen mode

I used these commands almost every day during preparation.

Cluster Administration Commands

Check Cluster Information

kubectl cluster-info
Enter fullscreen mode Exit fullscreen mode

Check Kubernetes Version

kubectl version --short
Enter fullscreen mode Exit fullscreen mode

List Nodes

kubectl get nodes
Enter fullscreen mode Exit fullscreen mode

Describe Node

kubectl describe node <node-name>
Enter fullscreen mode Exit fullscreen mode

View Component Status

kubectl get componentstatuses
Enter fullscreen mode Exit fullscreen mode

Pod Management Commands

List Pods

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

List Pods Across All Namespaces

kubectl get pods -A
Enter fullscreen mode Exit fullscreen mode

Wide Output

kubectl get pods -o wide
Enter fullscreen mode Exit fullscreen mode

Describe Pod

kubectl describe pod <pod-name>
Enter fullscreen mode Exit fullscreen mode

Delete Pod

kubectl delete pod <pod-name>
Enter fullscreen mode Exit fullscreen mode

Create Pod

kubectl run nginx --image=nginx
Enter fullscreen mode Exit fullscreen mode

Export Pod YAML

kubectl get pod <pod-name> -o yaml
Enter fullscreen mode Exit fullscreen mode

Edit Pod

kubectl edit pod <pod-name>
Enter fullscreen mode Exit fullscreen mode

Execute Command Inside Pod

kubectl exec -it <pod-name> -- sh
Enter fullscreen mode Exit fullscreen mode

Copy Files

kubectl cp <pod-name>:/tmp/file .
Enter fullscreen mode Exit fullscreen mode

Logging and Troubleshooting Commands

View Logs

kubectl logs <pod-name>
Enter fullscreen mode Exit fullscreen mode

Follow Logs

kubectl logs -f <pod-name>
Enter fullscreen mode Exit fullscreen mode

View Previous Logs

kubectl logs --previous <pod-name>
Enter fullscreen mode Exit fullscreen mode

List Events

kubectl get events
Enter fullscreen mode Exit fullscreen mode

Sort Events by Timestamp

kubectl get events --sort-by=.metadata.creationTimestamp
Enter fullscreen mode Exit fullscreen mode

Real CKA Troubleshooting Example

One of the most common issues during CKA preparation was a Pod stuck in a CrashLoopBackOff state.

My troubleshooting workflow looked like this:

kubectl get pods
kubectl describe pod <pod-name>
kubectl logs <pod-name>
Enter fullscreen mode Exit fullscreen mode

In many cases, these three commands were enough to identify the root cause.
This simple workflow saved me a lot of time during practice exams.

Deployment Commands

List Deployments

kubectl get deployments
Enter fullscreen mode Exit fullscreen mode

Create Deployment

kubectl create deployment nginx --image=nginx
Enter fullscreen mode Exit fullscreen mode

Scale Deployment

kubectl scale deployment nginx --replicas=5
Enter fullscreen mode Exit fullscreen mode

Update Image

kubectl set image deployment/nginx nginx=nginx:latest
Enter fullscreen mode Exit fullscreen mode

Check Rollout Status

kubectl rollout status deployment/nginx
Enter fullscreen mode Exit fullscreen mode

Rollout History

kubectl rollout history deployment/nginx
Enter fullscreen mode Exit fullscreen mode

Rollback Deployment

kubectl rollout undo deployment/nginx
Enter fullscreen mode Exit fullscreen mode

Service and Networking Commands

List Services

kubectl get svc
Enter fullscreen mode Exit fullscreen mode

Describe Service

kubectl describe svc <service-name>
Enter fullscreen mode Exit fullscreen mode

Expose Deployment

kubectl expose deployment nginx --port=80
Enter fullscreen mode Exit fullscreen mode

Port Forward

kubectl port-forward pod/<pod-name> 8080:80
Enter fullscreen mode Exit fullscreen mode

View Endpoints

kubectl get endpoints
Enter fullscreen mode Exit fullscreen mode

List Network Policies

kubectl get networkpolicy
Enter fullscreen mode Exit fullscreen mode

Namespace Commands

List Namespaces

kubectl get ns
Enter fullscreen mode Exit fullscreen mode

Create Namespace

kubectl create namespace dev
Enter fullscreen mode Exit fullscreen mode

Switch Namespace

kubectl config set-context --current --namespace=dev
Enter fullscreen mode Exit fullscreen mode

Delete Namespace

kubectl delete ns dev
Enter fullscreen mode Exit fullscreen mode

ConfigMaps and Secrets

List ConfigMaps

kubectl get configmaps
Enter fullscreen mode Exit fullscreen mode

Create ConfigMap

kubectl create configmap app-config --from-literal=env=prod
Enter fullscreen mode Exit fullscreen mode

List Secrets

kubectl get secrets
Enter fullscreen mode Exit fullscreen mode

Create Secret

kubectl create secret generic db-secret \
--from-literal=password=admin123
Enter fullscreen mode Exit fullscreen mode

Storage Commands

List Persistent Volumes

kubectl get pv
Enter fullscreen mode Exit fullscreen mode

List Persistent Volume Claims

kubectl get pvc
Enter fullscreen mode Exit fullscreen mode

Describe PVC

kubectl describe pvc <pvc-name>
Enter fullscreen mode Exit fullscreen mode

Resource Monitoring Commands

Node Resource Usage

kubectl top nodes
Enter fullscreen mode Exit fullscreen mode

Pod Resource Usage

kubectl top pods
Enter fullscreen mode Exit fullscreen mode

Namespace Resource Usage

kubectl top pods -n kube-system
Enter fullscreen mode Exit fullscreen mode

Commands I Wish I Had Learned Earlier
Looking back, these commands would have saved me significant time if I had mastered them earlier:

kubectl explain deployment.spec
kubectl get events
kubectl top pods
kubectl rollout history deployment/nginx
kubectl auth can-i create deployments
Enter fullscreen mode Exit fullscreen mode

The kubectl explain command was particularly useful because it helped me understand resource structures directly from the terminal.

My Favorite CKA Productivity Commands
Generate YAML Quickly
Instead of manually writing YAML, I frequently used:

kubectl run nginx \
--image=nginx \
--dry-run=client \
-o yaml
Enter fullscreen mode Exit fullscreen mode

Generate Deployment YAML

kubectl create deployment nginx \
--image=nginx \
--dry-run=client \
-o yaml
Enter fullscreen mode Exit fullscreen mode

Explain Resource Fields

kubectl explain deployment.spec.template.spec
Enter fullscreen mode Exit fullscreen mode

This command became one of my favorites during preparation.

My kubectl Setup for CKA
One of the first things I configured in every lab environment was:

alias k=kubectl
Enter fullscreen mode Exit fullscreen mode

This allowed me to type:

k get pods
Enter fullscreen mode Exit fullscreen mode

instead of:

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

It seems minor, but over hundreds of commands, it saves a surprising amount of time.

My Personal Learning Strategy
I didn’t try to memorize 50 commands overnight.

Instead, I followed a simple process:

Learn
Understand what the command does.

Practice
Use it repeatedly in labs.

Troubleshoot
Apply it while fixing real problems.

Repeat
Build muscle memory through repetition.

Eventually, many commands became second nature.

Final Thoughts
The difference between a beginner Kubernetes engineer and an experienced administrator is often not knowledge — it’s speed.

Speed comes from repetition.

The more comfortable you become with kubectl, the less time you’ll spend remembering commands and the more time you’ll spend solving problems.

These 50 commands helped me during my CKA preparation and continue to help me in real-world Kubernetes administration every day.

If you’re preparing for the CKA exam, start practicing them today.

Your future self will thank you.

Connect With Me
If you’re preparing for Kubernetes certifications, pursuing the Kubestronaut journey, or working in the cloud-native ecosystem, I’d love to connect.

Follow me for more articles on Kubernetes, CNCF certifications, DevOps, Platform Engineering, and Cloud-Native technologies.

LinkedIn: https://www.linkedin.com/in/shahzadaliahmad/

LFX Profile: https://openprofile.dev/profile/shahzadahmad91

Credly: https://www.credly.com/users/shahzadahmad

If you found this article helpful, consider sharing it with others in the Kubernetes community.

Top comments (0)