Kubectl
Get Kube configs from the .kube config file
kubectl config get-contextsSelect specific cluster to work on
kubectl config use-context yourClusterNameGet Kubernetes pods
kubectl get podsRestart deployments - sometimes useful when implementing a new config change or pulling an updated image
kubectl rollout restart deployments deploymentNameFind out the storage Class Names
kubectl get scGet the details of the persistent volume - including how they are attached etc
kubectl get pvIf your cluster finds it self in a difficult spot and being starved of resources. Your pods might start to get evicted because of "Disk Pressure" or some other error. If you do not action these quickly, you can end up with a high number of evicted pods in the cluster. How would you identify them and remove them?
you can use these two commands:
To Identify them:
kubectl get pods --all-namespaces -o json | jq '.items[] | select(.status.reason=="Evicted") | {namespace: .metadata.namespace, name: .metadata.name, status: .status.phase, reason: .status.reason}'To Remove them:
kubectl get pods --all-namespaces -o json | jq '.items[] | select(.status.reason!=null) | select(.status.reason | contains("Evicted")) | "kubectl delete pod \(.metadata.name) -n \(.metadata.namespace)"' | xargs -n 1 bash -cLast updated