DEV Community

Cover image for πŸ”₯ Ultimate Cheat Sheet for Kubernetes Commands πŸ”₯
Osagie Anolu
Osagie Anolu

Posted on β€’ Edited 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 GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Billboard image

Try REST API Generation for Snowflake

DevOps for Private APIs. Automate the building, securing, and documenting of internal/private REST APIs with built-in enterprise security on bare-metal, VMs, or containers.

  • Auto-generated live APIs mapped from Snowflake database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

πŸ‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay