Bytes
Data Science

Kubernetes Cheat Sheet/ Kubectl Cheat Sheet (Updated 2025)

Last Updated: 28th March, 2025
icon

Arunav Goswami

Data Science Consultant at almaBetter

Explore our Kubernetes cheat sheet for essential commands and concepts. Learn kubectl commands, Kubernetes objects, and more to streamline orchestration tasks

Kubernetes, an open-source container orchestration platform, automates the deployment, scaling, and management of containerized applications. For developers and system administrators, having a cheat sheet for Kubernetes commands can significantly improve efficiency and understanding. This guide provides an essential Kubernetes commands cheat sheet, covering kubectl commands, Kubernetes objects, concepts, and more.

Introduction to Kubernetes

Kubernetes is designed to manage containerized applications in a clustered environment, providing mechanisms for deployment, maintenance, and scaling of applications. This cheat sheet will help you navigate through essential commands and concepts of Kubernetes, ensuring you have the necessary tools and knowledge at your fingertips.

Kubernetes Commands Cheat Sheet

Basic Kubectl Commands Cheat Sheet

kubectl version  # Display the Kubernetes client and server version.
kubectl version --short  # Displays a concise version information.
kubectl cluster-info  # Display cluster information.
kubectl get [resource]  # List one or more resources.
kubectl get pods  # Lists all pods in the current namespace.
kubectl describe [resource] [name]  # Show detailed information about a resource.
kubectl describe pod [pod-name]  # Provides detailed information about the specified pod.
kubectl logs [pod]  # Print the logs for a container in a pod.
kubectl logs [pod-name]  # Prints logs from the specified pod.

Creating and Deleting Resources

kubectl create -f [file]  # Create a resource from a file.
kubectl create -f deployment.yaml  # Creates resources defined in deployment.yaml.
kubectl apply -f [file]  # Apply a configuration to a resource by file name or stdin.
kubectl apply -f deployment.yaml  # Applies changes from deployment.yaml.
kubectl delete [resource] [name]  # Delete resources by names.
kubectl delete pod [pod-name]  # Deletes the specified pod.
kubectl delete -f [file]  # Delete resources defined in a file.
kubectl delete -f deployment.yaml  # Deletes resources defined in deployment.yaml.

Kubernetes Objects Cheat Sheet

Pods

Pods are the smallest, most basic deployable objects in Kubernetes. A pod represents a single instance of a running process in your cluster.

Deployments

Deployments provide declarative updates to applications. They are used to manage stateless services.

kubectl get deployments  # Lists all deployments.

Services

Services are an abstract way to expose an application running on a set of pods as a network service.

kubectl get services  # Lists all services in the current namespace.

ConfigMaps

ConfigMaps are used to store configuration data in key-value pairs.

kubectl get configmaps  # Lists all ConfigMaps.

Secrets

Secrets are used to store sensitive data, such as passwords and tokens.

kubectl get secrets  # Lists all secrets.

Kubernetes Concepts Cheat Sheet

Namespaces

Namespaces are used to divide cluster resources between multiple users.

kubectl get namespaces  # Lists all namespaces in the cluster.

Labels and Selectors

Labels are key-value pairs attached to objects, used for organizing and selecting subsets of objects.

kubectl get pods --selector app=myapp  # Lists all pods with the label app=myapp.

Annotations

Annotations are key-value pairs attached to objects, used to store non-identifying information.

kubectl annotate pod [pod-name] description='my pod'  # Adds an annotation to a pod.

Taints and Tolerations

Taints are applied to nodes to prevent them from accepting any pods that do not tolerate the taints.

kubectl taint nodes node1 key=value:NoSchedule  # Applies a taint to a node.

Tolerations are applied to pods, allowing them to be scheduled on nodes with matching taints.

kubectl get pods --selector key=value  # Lists pods that tolerate specific taints.

Kubernetes Imperative Commands Cheat Sheet

Creating a Pod

kubectl run nginx --image=nginx  # Creates a pod with the nginx image.

Creating a Deployment

kubectl create deployment nginx --image=nginx  # Creates a deployment named nginx.

Exposing a Deployment

kubectl expose deployment nginx --port=80 --target-port=80  # Exposes the nginx deployment on port 80.

Scaling a Deployment

kubectl scale deployment nginx --replicas=3  # Scales the nginx deployment to 3 replicas.

Working with Pods

kubectl get pods [--namespace [namespace]]  # Lists all pods in the specified namespace.
kubectl describe pod [pod-name]  # Describes a pod in detail.
kubectl logs [pod-name]  # Retrieves logs for a pod.
kubectl exec [pod-name] -- [command]  # Executes a command in a container in the pod.
kubectl delete pod [pod-name]  # Deletes a specified pod.

Managing Deployments

kubectl get deployments [--namespace [namespace]]
kubectl describe deployment [deployment-name]
kubectl create deployment [deployment-name] --image=[image]
kubectl scale deployment [deployment-name] --replicas=[number]
kubectl rollout status deployment [deployment-name]
kubectl rollout undo deployment [deployment-name]

Services and Networking

kubectl get services [--namespace [namespace]]
kubectl describe service [service-name]
kubectl expose deployment [deployment-name] --type=[type] --port=[port]

ConfigMaps and Secrets

kubectl create configmap [configmap-name] --from-literal=[key]=[value]
kubectl get configmaps
kubectl describe configmap [configmap-name]
kubectl create secret generic [secret-name] --from-literal=[key]=[value]
kubectl get secrets
kubectl describe secret [secret-name]

Persistent Storage

kubectl get pv
kubectl describe pv [pv-name]
kubectl get pvc
kubectl describe pvc [pvc-name]

Namespace Management

kubectl get namespaces
kubectl create namespace [namespace]
kubectl delete namespace [namespace]

Monitoring and Debugging

kubectl top nodes
kubectl top pods [--namespace [namespace]]
kubectl logs [pod-name]
kubectl port-forward [pod-name] [local-port]:[pod-port]

Kubernetes Terms Cheat Sheet

Common Terms

  • Cluster: A set of nodes that run containerized applications managed by Kubernetes.
  • Node: A worker machine in Kubernetes, can be a VM or a physical machine.
  • Pod: The smallest and simplest Kubernetes object. Represents a single instance of a running process.
  • Service: An abstract way to expose an application running on a set of pods as a network service.
  • Ingress: Manages external access to services, typically HTTP.
  • ConfigMap: A way to store configuration data in key-value pairs.
  • Secret: A way to store sensitive data, such as passwords and tokens.
  • Volume: A directory containing data, accessible to containers in a pod.
  • Persistent Volume (PV): A piece of storage in the cluster that has been provisioned by an administrator.
  • Persistent Volume Claim (PVC): A request for storage by a user.

Conclusion

This Kubernetes cheat sheet serves as a quick reference guide for developers and system administrators. Keep this cheat sheet handy to streamline your Kubernetes operations and enhance your productivity.

More Cheat Sheets and Top Picks

  • Official Address
  • 4th floor, 133/2, Janardhan Towers, Residency Road, Bengaluru, Karnataka, 560025
  • Communication Address
  • Follow Us
  • facebookinstagramlinkedintwitteryoutubetelegram

© 2025 AlmaBetter