DEV Community

Cover image for 🔥 Ultimate Cheat Sheet for Kubernetes Commands 🔥
Osagie Anolu
Osagie Anolu

Posted on

🔥 Ultimate Cheat Sheet for Kubernetes Commands 🔥

Welcome, DevOps enthusiasts! Kubernetes is the backbone of modern cloud-native applications, and mastering its commands is a must-have skill for developers and DevOps engineers alike. In this article, we’ll explore essential Kubernetes commands, categorized for better understanding and usability.

🔣 List of Kubernetes Commands 🔣

➡️ ReplicaSets Management

kubectl create -f : Create a ReplicaSet.

kubectl get replicasets: List all ReplicaSets.

kubectl describe replicaset : Describe a specific ReplicaSet.

kubectl scale replicaset --replicas=: Scale a ReplicaSet.

➡️ Service Management

kubectl create service --tcp=: Create a service.

kubectl get services: List all services.

kubectl expose deployment --port=: Expose a deployment as a service.

kubectl describe service : Describe a specific service.

kubectl delete service : Delete a service.

kubectl get endpoints : Get information about a service.

➡️ ConfigMaps and Secrets

kubectl create configmap --from-file=: Create a ConfigMap from a file.

kubectl create secret --from-literal==: Create a secret.

kubectl get configmaps: List all ConfigMaps.

kubectl get secrets: List all secrets.

kubectl describe configmap : Describe a specific ConfigMap.

kubectl describe secret : Describe a specific secret.

kubectl delete secret : Delete a specific secret.

kubectl delete configmap : Delete a specific ConfigMap.

➡️ Networking

kubectl port-forward :: Port forward to a pod.

kubectl expose deployment --type=NodePort --port=: Expose a deployment as a NodePort service.

kubectl create ingress --rule=/=:: Create an Ingress resource.

kubectl describe ingress : Get information about an Ingress.

kubectl get ingress -o jsonpath='{.spec.rules[0].host}': Retrieve the host value from the first rule of the specified Ingress resource.

➡️ Storage

kubectl create -f : Create a PersistentVolume.

kubectl get pv: List all PersistentVolumes.

kubectl describe pv : Describe a specific PersistentVolume.

kubectl create -f : Create a PersistentVolumeClaim.

kubectl get pvc: List all PersistentVolumeClaims.

kubectl describe pvc : Describe a specific PersistentVolumeClaim.

➡️ StatefulSets

kubectl create -f : Create a StatefulSet.

kubectl get statefulsets: List all StatefulSets.

kubectl describe statefulset : Describe a specific StatefulSet.

kubectl scale statefulset --replicas=: Scale a StatefulSet.

➡️ Monitoring and Troubleshooting

kubectl get events: Check cluster events.

kubectl get componentstatuses: Get cluster component statuses.

kubectl top nodes: Get resource utilization of nodes.

kubectl top pods: Get resource utilization of pods.

kubectl debug -it --image=: Enable container shell access debugging.


📢 Conclusion

With these commands at your fingertips, you’re ready to take your Kubernetes skills to the next level. From managing ReplicaSets and services to networking, storage, and troubleshooting, this cheat sheet is your quick guide to navigating Kubernetes like a pro.

Let me know in the comments which command you use the most, and share this guide with your team! 🚀

Top comments (0)