Kubernetes kubectl commands

A collection of kubectl commands that are handy. ~/.kube/config Here’s the Kubernetes config. Note that I believe that minikube creates this on creation: apiVersion: v1 clusters: - cluster: certificate-authority: /Users/USERNAME/.minikube/ca.crt server: name: minikube contexts: - context: cluster: minikube user: minikube name: minikube current-context: minikube kind: Config preferences: {} users: - name: minikube user: client-certificate: /Users/USERNAME/.minikube/apiserver.crt client-key: /Users/USERNAME/.minikube/apiserver.key commands Get pods in wide view (shows what nodes they’re running on): kubectl get pods --all-namespaces -o wide Get Kubernetes nodes labels: kubectl get nodes --show-labels Remove all pods from a node: kubectl drain ip-10-1-1-2.