<p>I need to know to which master node my current worker node is connected. I can see the worker nodes by typing "kubectl get nodes" command in the master node, but I need to find the master node from the worker node itself.</p>

<p>In simple words, How to find the master node from the worker node in the kubernetes cluster?</p>

<p>You can usually find it on your <code>kubelet</code> config file: <code>/etc/kubernetes/kubelet.conf</code></p>

<pre><code>$ cat /etc/kubernetes/kubelet.conf
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: REDACTED
    server: https://1.1.1.1:6443 &lt;== here
  name: default-cluster
contexts:
- context:
    cluster: default-cluster
    namespace: default
    user: default-auth
  name: default-context
current-context: default-context
kind: Config
preferences: {}
users:
- name: default-auth
  user:
    client-certificate: /var/lib/kubelet/pki/kubelet-client-current.pem
    client-key: /var/lib/kubelet/pki/kubelet-client-current.pem
</code></pre>

<p>If you have something like <a href="https://kislyuk.github.io/yq/" rel="nofollow noreferrer"><code>yq</code></a> you can get it like this:</p>

<pre><code>yq .clusters[0].cluster.server /etc/kubernetes/kubelet.conf | tr -d "\n\""
</code></pre>
