<p>I have minikube cluster running on Windows WSL2, and I have a Dev Container <a href="https://code.visualstudio.com/docs/remote/create-dev-container" rel="nofollow noreferrer">https://code.visualstudio.com/docs/remote/create-dev-container</a>) running my React Application and Kubernetes CLI tools. My goal is to containerize the application and run that on the minikube cluster.</p>
<p>So now I have exposed the local configurations and certifications of minikube to my Dev Container, and I am using that as a default KUBECONFIG. I have a deployment, and Docker Image ready - so next step is to try to use deployment and have that running on the cluster.</p>
<p>When I am running a kubectl command inside the Dev Container, I am getting error message like this:</p>
<pre><code>The connection to the server 127.0.0.1:51515 was refused - did you specify the right host or port?
</code></pre>
<p>When I am inspecting the minikube container, I see that its listening only to localhost</p>
<pre><code>gcr.io/k8s-minikube/kicbase:v0.0.28                          &quot;/usr/local/bin/entr…&quot;   3 hours ago          Up 3 hours          127.0.0.1:58892-&gt;22/tcp, 127.0.0.1:58893-&gt;2376/tcp, 127.0.0.1:58895-&gt;5000/tcp, 127.0.0.1:58896-&gt;8443/tcp, 127.0.0.1:58894-&gt;32443/tcp   minikube
</code></pre>
<p>So as far as I know, these requests fail, because request from Dev Container is not considered as a localhost request (I am able to ping localhost.). I am running the Dev Container with network=host flag.</p>
<p>So atleast one way to get this setup working it to bind minikube's ports to listen to 0.0.0.0, instead of localhost - is there any other way? How could I get that 0.0.0.0 bind working? I am having a feeling that this could be Docker Desktop settings related - that I need to somehow change some kind of default settings from 127.0.0.1 -&gt; 0.0.0.0.</p>
<p>Running minikube with this command didn't do the trick.</p>
<pre><code>minikube start --driver=docker --listen-address='0.0.0.0'
</code></pre>
<p>Versions:</p>
<ul>
<li>Docker Desktop 4.6.0 (75818)</li>
<li>Docker 20.10.13, build a224086</li>
<li>minikube v1.24.0</li>
<li>kubectl 1.21.5</li>
</ul>
<p>Thank you in advance!</p>
<p>EDIT:</p>
<p>I also tried different alternatives to localhost, without changing the configuration in minikube, with the same port that is on host computer - these didn't do the trick. I can however ping every address from Container.</p>
<pre><code>kubernetes.docker.internal, host.docker.internal, 192.168.49.2 (Minikube's IP on localhost), minikubeCA, control-plane.minikube.internal, kubernetes.default.svc.cluster.local, kubernetes.default.svc, kubernetes.default, kubernetes, localhost
</code></pre>
<p>Here is my minikube's KUBECONFIG.</p>
<pre><code>- cluster:
    certificate-authority-data: Removed for Security.
    extensions:
    - extension:
        last-update: Mon, 28 Mar 2022 17:30:48 EEST
        provider: minikube.sigs.k8s.io
        version: v1.24.0
      name: cluster_info
    server: https://localhost:58896
  name: minikube
</code></pre>

haapjari
<p>I managed to solve this. Docker Desktop requires to use <code>host.docker.internal</code> instead of <code>localhost</code> inside Kubernetes Config YAML.</p>
<p>Problem is that first address is not allowed by Minikubes Certificate. Running kubectl commands with flag <code>--insecure-skip-tls-verify</code> - so for example</p>
<pre><code>kubectl get nodes -A --insecure-skip-tls-verify
</code></pre>
<p>works, with setup defined above.</p>
<p>Found also some documentation: <a href="https://github.com/Microsoft/vscode-dev-containers/tree/main/containers/kubernetes-helm" rel="nofollow noreferrer">https://github.com/Microsoft/vscode-dev-containers/tree/main/containers/kubernetes-helm</a></p>
