DEV Community

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

Posted on

1

🔥 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! 🚀

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay