<p>I'm trying to connect to a kubernetes cluster running on my Windows PC from my Mac. This is so I can continue to develop from my Mac but run everything on a machine with more resources. I know that to do this I need to change the kubectl context on my Mac to point towards my Windows PC but don't know how to manually do this.</p>
<p>When I've connected to a cluster before on AKS, I would use <code>az aks get-credentials</code> and this would correctly an entry to .kube/config and change the context to it. I'm basically trying to do this but on a local network.</p>
<p>I've tried to add an entry into kubeconfig but get <code>The connection to the server 192.168.1.XXX:6443 was refused - did you specify the right host or port?</code>. I've also checked my antivirus on the Windows computer and no requests are getting blocked.</p>
<pre><code>apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: {CERT}
    server: https://192.168.1.XXX:6443
  name: windows-docker-desktop
current-context: windows-docker-desktop
kind: Config
preferences: {}
users:
- name: windows-docker-desktop
  user:
    client-certificate-data: {CERT}
    client-key-data: {KEY}
</code></pre>
<p>I've also tried using <code>kubectl --insecure-skip-tls-verify --context=windows-docker-desktop get pods</code> which results in the same error: <code>The connection to the server 192.168.1.XXX:6443 was refused - did you specify the right host or port?</code>.</p>
<p>Many thanks.</p>

Bailey S
<p>From your MAC try if the port is open: Like nc -zv 192.168.yourwindowsIp 6443. If it doest respond Open, you have a network problem.
Try this.</p>
<pre><code>clusters:
- cluster:
    server: https://192.168.1.XXX:6443
    name: windows-docker-desktop
    insecure-skip-tls-verify: true
</code></pre>
<p>directly in the configfile</p>
<p>the set-context you dont need to specify as you have only one.
To be sure it is not your firewall, disable it just for a very short period, only to test the conection.</p>
<p>Last thing: Seems you are using Kubernetes in Docker-Desktop. If not and you have a local cluster with more than 1 node, you need to install a network fabric in your cluster like Flannel or Calico.
<a href="https://projectcalico.docs.tigera.io/about/about-calico" rel="nofollow noreferrer">https://projectcalico.docs.tigera.io/about/about-calico</a>
<a href="https://github.com/flannel-io/flannel" rel="nofollow noreferrer">https://github.com/flannel-io/flannel</a></p>
