kubectl get nodes
The output will vary depending on your cluster. The example below is taken from a minikube cluster:
NAME STATUS ROLES AGE VERSION minikube Ready control-plane,master 42m v1.20.2
One uncommon, but still important, requirement is to make Kubernetes schedule a pod on a certain node. For this, we first need to label the node we want to target (using the node name as retrieved above):
kubectl label nodes minikube shouldrun=here
kubectl apply -f https://raw.githubusercontent.com/openshift-evangelists/kbe/main/specs/nodes/pod.yaml
kubectl get pods --output=wide
In this case, the node is the same one that was labeled in the
label command above.
describesubcommand contains a wealth of information about the node (the example output below has been truncated for readability):
Name: minikube Roles: control-plane,master ... Addresses: InternalIP: 192.168.39.147 Hostname: minikube Capacity: cpu: 4 ephemeral-storage: 17784752Ki hugepages-2Mi: 0 memory: 11999700Ki pods: 110 ... Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal NodeHasSufficientMemory 47m (x7 over 47m) kubelet Node minikube status is now: NodeHasSufficientMemory Normal NodeHasNoDiskPressure 47m (x6 over 47m) kubelet Node minikube status is now: NodeHasNoDiskPressure Normal NodeHasSufficientPID 47m (x6 over 47m) kubelet Node minikube status is now: NodeHasSufficientPID Normal Starting 47m kubelet Starting kubelet. ...
Note that there are more sophisticated methods than shown above, such as using affinity, to assign pods to nodes.