K8S cheat sheet for developer, daily used k8s cheat sheet!!

music group performing on stage with empty audience seats

Basic Commands

  1. kubectl get: list resources

  2. kubectl describe: show details of a resource

  3. kubectl create: create a resource from a file or stdin

  4. kubectl apply: apply a configuration file to create or update resources

  5. kubectl delete: delete a resource

  6. kubectl edit: edit a resource live


  1. kubectl run: create a new deployment with one or more replicas

  2. kubectl logs: show the logs of a pod

  3. kubectl exec: run a command in a running container in a pod


    1. kubectl create deployment <deployment name> --image=<image name>: Create a new deployment with a specified image.

      1. kubectl get deployments: List all deployments in the current namespace.

      2. kubectl describe deployment <deployment name>: Get detailed information about a deployment.

      3. kubectl rollout status deployment/<deployment name>: Check the status of a deployment rollout.

      4. kubectl rollout history deployment/<deployment name>: View the revision history of a deployment.

      5. kubectl rollout undo deployment/<deployment name>: Roll back a deployment to the previous revision.

      6. kubectl scale deployment <deployment name> --replicas=<number>: Scale the number of replicas in a deployment.

      7. kubectl set image deployment/<deployment name> <container name>=<new image>: Update the image of a container in a deployment.

      8. kubectl delete deployment <deployment name>: Delete a deployment.


    1. kubectl get services: View a list of all services in the current namespace.

      1. kubectl describe service <service-name>: Get detailed information about a specific service.

      2. kubectl create service <service-type> <service-name> [--tcp=<port>] [--dry-run]: Create a new service. <service-type> can be ClusterIP, NodePort, or LoadBalancer.

      3. kubectl expose <resource-type> <resource-name> [--port=<port>] [--target-port=<target-port>] [--type=<service-type>] [--name=<service-name>]: Expose a port for a resource (e.g. a deployment or pod) as a new service. <service-type> can be ClusterIP, NodePort, or LoadBalancer.

      4. kubectl edit service <service-name>: Edit the configuration of an existing service.

      5. kubectl delete service <service-name>: Delete a service.

  • Note that some of these commands require additional parameters, such as the port number or target port. Also, the expose command is deprecated in recent versions of Kubernetes, so it's recommended to use create service instead.


  1. kubectl config view: View the current kubeconfig file configuration.

  2. kubectl config use-context <context-name>: Set the active context in the kubeconfig file.

  3. kubectl config set-context <context-name> --namespace=<namespace>: Set a namespace for a specific context.

  4. kubectl config set-cluster <cluster-name> --server=<server-url>: Set the server URL for a cluster in the kubeconfig file.

  5. kubectl config set-credentials <user-name> --token=<token>: Set the credentials for a user in the kubeconfig file.

  6. kubectl config delete-context <context-name>: Delete a context from the kubeconfig file.

  7. kubectl config unset <property>: Unset a specific property in the current context.

  8. kubectl config use-context <context-name> --kubeconfig=<file-path>: Set the active context in a specific kubeconfig file.

  9. kubectl config view --minify: View the current kubeconfig file configuration in a compact format.

  10. kubectl config current-context: Display the name of the current context in the kubeconfig file.

There are many more commands but in general if you are a developer these commands are more than enough.

I hope this helps, you!!

More such articles:





If this article adds any value to you then please clap and comment.

Let’s connect on Stackoverflow, LinkedIn, & Twitter.

Did you find this article valuable?

Support techwasti by becoming a sponsor. Any amount is appreciated!