kubectl get resource --short-names

kubectl get resource --short-names

Ok, lets get all the persistent volume claims in our production namespace. So, the command would be:

kubectl get persistentvolumeclaims --namespace=production

Ok, the command is easy to understand, but writing such big commands in their full forms can be a pain quickly. Now image writing such big commands in the shell or powershell prompt again and again while debugging an issue.
Does it sound good?
Error debugging can quickly turn into nightmare if you have additionally take care of spellings of such big commands.
Now you would be thinking to reduce down this effort.

Thankfully we do have short identifiers for such type of common resource types.
Let me share the short identifier of above command

kubectl get pvc -n production

And if you use alias as well,

ku get pvc -n production

Isn’t this a lot better?
Here’s the complete list of shortened resource types you can use:

  • componentstatuses = cs
  • configmaps = cm
  • endpoints = ep
  • events = ev
  • limitranges = limits
  • namespaces = ns
  • nodes = no
  • persistentvolumeclaims = pvc
  • persistentvolumes = pv
  • pods = po
  • replicationcontrollers = rc
  • resourcequotas = quota
  • serviceaccounts = sa
  • services = svc
  • customresourcedefinitions = crd, crds
  • daemonsets = ds
  • deployments = deploy
  • replicasets = rs
  • statefulsets = sts
  • horizontalpodautoscalers = hpa
  • cronjobs = cj
  • certificiaterequests = cr, crs
  • certificates = cert, certs
  • certificatesigningrequests = csr
  • ingresses = ing
  • networkpolicies = netpol
  • podsecuritypolicies = psp
  • replicasets = rs
  • scheduledscalers = ss
  • priorityclasses = pc
  • storageclasses = sc

I hope you enjoyed this blog!
Happy automation!

Subscribe to Akhil Sharma - An Engineering and Writing Geek

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.