<p>I'm currently using Kubernetes Python Client V1 API.
Since there is a way to list node details but I could not find which one is master</p>
<pre class="lang-py prettyprint-override"><code>k8s_api = client.CoreV1Api()
logger.info(&quot;Getting k8s nodes...&quot;)
response = k8s_api.list_node()
</code></pre>

<pre><code>k8s_api = client.CoreV1Api()
response = k8s_api.list_node()

# Loop through the nodes and check for the master node label
for node in response.items:
    if &quot;node-role.kubernetes.io/master&quot; in node.metadata.labels:
        print(f&quot;Master node: {node.metadata.name}&quot;)
</code></pre>
