kubectl reference guide

3 min read

Generic kubectl usage:

  • kubectl logs previous: Using kubectl logs previous we can get the logs of the already restarted container
  • kubectl patch: Using kubectl patch we can modify Kubernetes objects in batch mode
  • kubectl explain: man for Kubernetes: With kubectl we have a sort of man to get the details of default Kubernetes objects
  • kubectl rollout history: By adding the record flag we can automatically set the change-cause annotation
  • kubectl set image: With kubectl set image we can update a container's image imperativelly
  • kubectl port-forward: Using kubectl port-forward we can reach services that are not exposed using other methods
  • kubectl run to create a pod: Let's see how to run a pod on kubernetes and it's equivalent docker commands
  • kubectl: create a yaml base template: By combining dry-run and yaml output we can use kubectl to create yaml templates for creating new resources on the cluster
  • kubectl diff usage: kubectl diff can be used to see the actual changes that will be performed by applying a given yaml file
  • kubectl top: kubectl top can be use to get a gist of what's going on on our cluster, resource-wise


cluster management

Deployment management


sorting or filtering


  • kubectl
  • reference