<p>I have built my docker image in Docker desktop but I do not know how to config so that terraform kubernetes can refer to local image? (it stuck while creating the pod)</p>
<p>Here is my tf file look like</p>
<pre><code>....
provider &quot;kubernetes&quot; {
  config_path = &quot;~/.kube/config&quot;
}

resource &quot;kubernetes_pod&quot; &quot;test&quot; {
  metadata {
    name = &quot;backend-api&quot;
    labels = {
      app = &quot;MyNodeJsApp&quot;
    }
  }
  spec {
    container {
      image = &quot;backendnodejs:0.0.1&quot;
      name = &quot;backendnodejs-container&quot;
      # I think it keep pulling from Docker Hub 
      port {
        container_port = 5000
      }
    }
  }
}

resource &quot;kubernetes_service&quot; &quot;test&quot; {
  metadata {
    name = &quot;backendnodejs-service&quot;
  }

  spec {
    selector = {
      app = kubernetes_pod.test.metadata.0.labels.app
    }

    port {
      port = 5000
      target_port = 5000
    }

    type = &quot;LoadBalancer&quot;
  }
}
</code></pre>

Babyface_Developer
<p>So after hours researching how to deploy to minikube (installed on minikube website not docker desktop kubernetes). I found out that minikube ran as container itself in docker desktop which is why you can not use images from docker desktop to deploy into minikube.</p>
<p>Here are the link solved about this:</p>
<ul>
<li><a href="https://minikube.sigs.k8s.io/docs/handbook/pushing/" rel="nofollow noreferrer">Pushing images from minikube</a></li>
<li><a href="https://stackoverflow.com/questions/42564058/how-to-use-local-docker-images-with-minikube">How to use local docker images with Minikube?</a></li>
</ul>
<p>So things you will need before using terraform deploy to minikube:</p>
<ol>
<li><p>Pushing directly to the in-cluster Docker daemon (docker-env)</p>
<ul>
<li><strong>Windows</strong>
<ul>
<li>Powershell
<pre><code>PS&gt; &amp; minikube -p minikube docker-env --shell powershell | Invoke-Expression
</code></pre>
</li>
<li>CMD
<pre><code>CMD&gt; @FOR /f &quot;tokens=*&quot; %i IN ('minikube -p minikube docker-env --shell cmd') DO @%i
</code></pre>
</li>
</ul>
</li>
<li><strong>Linux/MacOS</strong>
<pre><code>&gt; eval $(minikube docker-env)
</code></pre>
</li>
</ul>
</li>
<li><p>Build docker image again (same terminal that been entered command above)</p>
<pre><code>docker build -t your_image_tag your_docker_file
</code></pre>
</li>
<li><p>Run normal terraform file (same terminal)</p>
</li>
</ol>
<p><a href="https://shashanksrivastava.medium.com/how-to-set-up-minikube-to-use-your-local-docker-registry-10a5b564883" rel="nofollow noreferrer">This link</a> also explained same as above</p>
