<p>I'm writing some scripts that check the system to make sure of some cluster characteristics.  Things running on private IP address spaces, etc.  These checks are just a manual step when setting up a cluster, and used just for sanity checking.</p>

<p>They'll be run on each node, but I'd like a set of them to run when on the master node.  Is there a bash, curl, kubectl, or another command that has information indicating the current node is a master node?</p>

<p>The master(s) usually has the 'master' role associated with it. For example:</p>

<pre><code>$ kubectl get nodes
NAME                                         STATUS    ROLES     AGE       VERSION
ip-x-x-x-x.us-west-2.compute.internal        Ready     &lt;none&gt;    7d        v1.11.2
ip-x-x-x-x.us-west-2.compute.internal        Ready     master    78d       v1.11.2
ip-x-x-x-x.us-west-2.compute.internal        Ready     &lt;none&gt;    7d        v1.11.2
ip-x-x-x-x.us-west-2.compute.internal        Ready     &lt;none&gt;    7d        v1.11.2
ip-x-x-x-x.us-west-2.compute.internal        Ready     &lt;none&gt;    7d        v1.11.2
</code></pre>

<p>It also has a label <code>node-role.kubernetes.io/master</code> associated with it. For example:</p>

<pre><code>$ kubectl get node ip-x-x-x-x.us-west-2.compute.internal -o=yaml
apiVersion: v1
kind: Node
metadata:
  annotations:
    kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
    node.alpha.kubernetes.io/ttl: "0"
    projectcalico.org/IPv4Address: x.x.x.x/20
    volumes.kubernetes.io/controller-managed-attach-detach: "true"
  creationTimestamp: 2018-07-23T21:10:22Z
  labels:
    beta.kubernetes.io/arch: amd64
    beta.kubernetes.io/instance-type: t3.medium
    beta.kubernetes.io/os: linux
    failure-domain.beta.kubernetes.io/region: us-west-2
    failure-domain.beta.kubernetes.io/zone: us-west-2c
    kubernetes.io/hostname: ip-x-x-x-x.us-west-2.compute.internal
    node-role.kubernetes.io/master: ""
</code></pre>
