# 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)](https://www.credly.com/badges/e72821a9-97a5-4ee8-a7f6-93f40246e864/public_url) 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:

```plaintext
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
```

I used these commands almost every day during preparation.

## **Cluster Administration Commands**

### **Check Cluster Information**

```plaintext
kubectl cluster-info
```

### **Check Kubernetes Version**

```plaintext
kubectl version --short
```

### **List Nodes**

```plaintext
kubectl get nodes
```

### **Describe Node**

```plaintext
kubectl describe node <node-name>
```

### **View Component Status**

```plaintext
kubectl get componentstatuses
```

## **Pod Management Commands**

### **List Pods**

```plaintext
kubectl get pods
```

### **List Pods Across All Namespaces**

```plaintext
kubectl get pods -A
```

### **Wide Output**

```plaintext
kubectl get pods -o wide
```

### **Describe Pod**

```plaintext
kubectl describe pod <pod-name>
```

### **Delete Pod**

```plaintext
kubectl delete pod <pod-name>
```

### **Create Pod**

```plaintext
kubectl run nginx --image=nginx
```

### **Export Pod YAML**

```plaintext
kubectl get pod <pod-name> -o yaml
```

### **Edit Pod**

```plaintext
kubectl edit pod <pod-name>
```

### **Execute Command Inside Pod**

```plaintext
kubectl exec -it <pod-name> -- sh
```

### **Copy Files**

```plaintext
kubectl cp <pod-name>:/tmp/file .
```

## **Logging and Troubleshooting Commands**

### **View Logs**

```plaintext
kubectl logs <pod-name>
```

### **Follow Logs**

```plaintext
kubectl logs -f <pod-name>
```

### **View Previous Logs**

```plaintext
kubectl logs --previous <pod-name>
```

### **List Events**

```plaintext
kubectl get events
```

### **Sort Events by Timestamp**

```plaintext
kubectl get events --sort-by=.metadata.creationTimestamp
```

## **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:

```plaintext
kubectl get pods
kubectl describe pod <pod-name>
kubectl logs <pod-name>
```

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**

```plaintext
kubectl get deployments
```

### **Create Deployment**

```plaintext
kubectl create deployment nginx --image=nginx
```

### **Scale Deployment**

```plaintext
kubectl scale deployment nginx --replicas=5
```

### **Update Image**

```plaintext
kubectl set image deployment/nginx nginx=nginx:latest
```

### **Check Rollout Status**

```plaintext
kubectl rollout status deployment/nginx
```

### **Rollout History**

```plaintext
kubectl rollout history deployment/nginx
```

### **Rollback Deployment**

```plaintext
kubectl rollout undo deployment/nginx
```

## **Service and Networking Commands**

### **List Services**

```plaintext
kubectl get svc
```

### **Describe Service**

```plaintext
kubectl describe svc <service-name>
```

### **Expose Deployment**

```plaintext
kubectl expose deployment nginx --port=80
```

### **Port Forward**

```plaintext
kubectl port-forward pod/<pod-name> 8080:80
```

### **View Endpoints**

```plaintext
kubectl get endpoints
```

### **List Network Policies**

```plaintext
kubectl get networkpolicy
```

## **Namespace Commands**

### **List Namespaces**

```plaintext
kubectl get ns
```

### **Create Namespace**

```plaintext
kubectl create namespace dev
```

### **Switch Namespace**

```plaintext
kubectl config set-context --current --namespace=dev
```

### **Delete Namespace**

```plaintext
kubectl delete ns dev
```

## **ConfigMaps and Secrets**

### **List ConfigMaps**

```plaintext
kubectl get configmaps
```

### **Create ConfigMap**

```plaintext
kubectl create configmap app-config --from-literal=env=prod
```

### **List Secrets**

```plaintext
kubectl get secrets
```

### **Create Secret**

```plaintext
kubectl create secret generic db-secret \
--from-literal=password=admin123
```

## **Storage Commands**

### **List Persistent Volumes**

```plaintext
kubectl get pv
```

### **List Persistent Volume Claims**

```plaintext
kubectl get pvc
```

### **Describe PVC**

```plaintext
kubectl describe pvc <pvc-name>
```

## **Resource Monitoring Commands**

### **Node Resource Usage**

```plaintext
kubectl top nodes
```

### **Pod Resource Usage**

```plaintext
kubectl top pods
```

### **Namespace Resource Usage**

```plaintext
kubectl top pods -n kube-system
```

## **Commands I Wish I Had Learned Earlier**

Looking back, these commands would have saved me significant time if I had mastered them earlier:

```plaintext
kubectl explain deployment.spec
kubectl get events
kubectl top pods
kubectl rollout history deployment/nginx
kubectl auth can-i create deployments
```

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:

```plaintext
kubectl run nginx \
--image=nginx \
--dry-run=client \
-o yaml
```

### **Generate Deployment YAML**

```plaintext
kubectl create deployment nginx \
--image=nginx \
--dry-run=client \
-o yaml
```

### **Explain Resource Fields**

```plaintext
kubectl explain deployment.spec.template.spec
```

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:

```plaintext
alias k=kubectl
```

This allowed me to type:

```plaintext
k get pods
```

instead of:

```plaintext
kubectl get pods
```

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/](https://www.linkedin.com/in/shahzadaliahmad/)

LFX Profile: [https://openprofile.dev/profile/shahzadahmad91](https://openprofile.dev/profile/shahzadahmad91)

Credly: [https://www.credly.com/users/shahzadahmad](https://www.credly.com/users/shahzadahmad)

Website: [https://shahzadahmad.dev/](https://shahzadahmad.dev/)

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