for your local machine - New versions of K8s exams already has auto-complete setup on clusters
source <(kubectl completion bash) # setup autocomplete in bash into the current shell, bash-completion package should be installed first.
echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.
alias k=kubectl
complete -F __start_kubectl k
alias k='kubectl'
alias kg='kubectl get'
alias ke='kubectl edit'
alias kd='kubectl describe'
alias kdd='kubectl delete'
alias kgp='kubectl get pods'
alias kgd='kubectl get deployments'
alias kns='kubens'
alias kcx='kubectx'
alias wkgp='watch kubectl get pod'
kubectl get pods
kubectl get pods --all-namespaces OR kubectl get pods -A
kubectl get pod <podname> -o wide
kubectl get pod <podname> -o wide
kubectl describe pod <podname>
kubectl run <podname> --image=nginx
kubectl scale deploy <deploymentname> --replicas=<No.ofPods>
kubectl get services
kubectl expose deploy <deployname> --port=80 --type=NodePort > type can be ClusterIP/NodePort/LoadBalancer (if using a cloud-native cluster)
kubectl create cm <configmapname> --from-file=<file.txt>
kubectl get cm <configmapname> -o yaml
kubectl get pv
kubectl get pvc
kubectl get ingress OR kubectl get ing
kubectl
kubectl get hpa
kubectl autoscale deployment <name> --min=2 --max=8
kubectl autoscale deployment <name> --max=3 --cpu-percent=60
kubectl create role <rolename> --verb=create,get,update,delete --resource=pods,deployments,services
kubectl create rolebinding foo --role=<rolename> --serviceaccount=namespace:serviceaccountname
kubectl get rolebinding foo -o yaml
# Any Troubleshooting useful commands
```sh
kubectl logs <podname>
kubectl get events
kubectl exec -it <podname> -- sh