Frequently used Kubernetes commands

  • kubectl get clusterrolebinding (Gives permission to Super User to access API’s and Kube dashboard)
  • kubectl edit svc/kubernetes-dashboard --namespace=kube-system (Edits a service yaml)
  • kubectl create clusterrolebinding serviceaccounts-cluster-admin --clusterrole=cluster-admin --group=system:serviceaccounts (Grants access to all cluster-wide service accounts to the Super User)
  • kubectl edit svc/kube-dns --namespace=kube-system (Edits yaml of a service)
  • kubectl get jobs | cut -c 1-15 | grep -v 'NAME' | xargs kubectl delete job (Deletes all jobs)
  • docker rm $(docker ps -a -f status=exited -q) (Deletes all exited Docker Containers)
  • kubectl get pods --show-all |grep -e "Error" -e "Completed" | cut -f1 -d ' ' | xargs kubectl delete pods (Deletes errors and completed pods )