Kubectl Useful Commands

Maciej
4 min readMar 22, 2021

Kubernetes Shortcuts

  • po : Pods
  • rs : ReplicaSets
  • deploy : Deployments
  • svc : Services
  • ns : Namespaces
  • netpol : Network policies
  • pv : Persistent Volumes
  • pvc : PersistentVolumeClaims
  • in : Service Accounts

Backup

root@vagrant:/home/vagrant# kubectl get all -A -o yaml > backup.yaml

Explain

root@vagrant:/home/vagrant# kubectl explain sc --recursive | less

Pods

#List Pod
root@vagrant:/home/vagrant# kubectl get pods
root@vagrant:/home/vagrant# kubectl get pods -o wide
root@vagrant:/home/vagrant# kubectl get pods -n kube-system
root@vagrant:/home/vagrant# kubectl get pods --selector app=test-application,env=develop
root@vagrant:/home/vagrant# kubectl get pods -l app=test-application,env=develop
root@vagrant:/home/vagrant# kubectl get pods --all-namespaces
root@vagrant:/home/vagrant# kubectl get pods --show-labels
#Pod Status
root@vagrant:/home/vagrant# kubectl describe pod mypod
#Create Pod
root@vagrant:/home/vagrant# kubectl run mypod --image nginx

--

--

Maciej
Maciej

Written by Maciej

DevOps Consultant. I’m strongly focused on automation, security, and reliability.

Responses (1)