<p>How via command line can I detect if a Kubernetes node is a master/control plane or not? Is there an environment variable I can check?</p>

Justin
<p>Kubernetes provides <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/" rel="nofollow noreferrer">labels and selectors</a> which can be used to select the role assigned to a node.</p>
<p>To select controlplane nodes, use a selector to select that role:</p>
<pre><code># kubectl get nodes --selector 'node-role.kubernetes.io/controlplane' 
NAME  STATUS  ROLES              AGE  VERSION
cp01  Ready   controlplane,etcd  90d  v1.26.1
cp02  Ready   controlplane,etcd  93d  v1.26.1
cp03  Ready   controlplane,etcd  93d  v1.26.1
</code></pre>
<p>To see a list of available labels, print out the configuration of the node in YAML format, and look at the <code>labels:</code> section:</p>
<pre><code># kubectl get nodes cp01 -o yaml
...
  labels:
    kubernetes.io/os: linux
    node-role.kubernetes.io/controlplane: &quot;true&quot;
    node-role.kubernetes.io/etcd: &quot;true&quot;
...
</code></pre>
