<p>What is the cause of 'terraform apply' giving me the error below on my local machine? It seems to run fine on the build server.</p>
<p>I've also checked the related stackoverflow messages:</p>
<ul>
<li>Windows Firewall is disabled, thus 80 is allowed on the private network</li>
<li>config_path in AKS is not used, no kubeconfig seems to be configured anywhere</li>
</ul>
<pre><code>Plan: 3 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

kubernetes_namespace.azurevotefront-namespace: Creating...
kubernetes_service.azurevotefront-metadata: Creating...
kubernetes_deployment.azurevotefront-namespace: Creating...
╷
│ Error: Post &quot;http://localhost/api/v1/namespaces&quot;: dial tcp 127.0.0.1:80: connect: connection refused   
│
│   with kubernetes_namespace.azurevotefront-namespace,
│   on kubernetes.tf line 1, in resource &quot;kubernetes_namespace&quot; &quot;azurevotefront-namespace&quot;:
│    1: resource &quot;kubernetes_namespace&quot; &quot;azurevotefront-namespace&quot; {
│
╵
╷
│ Error: Failed to create deployment: Post &quot;http://localhost/apis/apps/v1/namespaces/azurevotefront-namespace/deployments&quot;: dial tcp 127.0.0.1:80: connect: connection refused
│
│   with kubernetes_deployment.azurevotefront-namespace,
│   on main.tf line 1, in resource &quot;kubernetes_deployment&quot; &quot;azurevotefront-namespace&quot;:
│    1: resource &quot;kubernetes_deployment&quot; &quot;azurevotefront-namespace&quot; {
│
╵
╷
│ Error: Post &quot;http://localhost/api/v1/namespaces/azurevotefront-namespace/services&quot;: dial tcp 127.0.0.1:80: connect: connection refused
│
│   with kubernetes_service.azurevotefront-metadata,
│   on main.tf line 47, in resource &quot;kubernetes_service&quot; &quot;azurevotefront-metadata&quot;:
│   47: resource &quot;kubernetes_service&quot; &quot;azurevotefront-metadata&quot; {
</code></pre>
<p>Kubernetes.tf</p>
<pre class="lang-json prettyprint-override"><code>resource &quot;kubernetes_namespace&quot; &quot;azurevotefront-namespace&quot; {
  metadata {
    annotations = {
      name = &quot;azurevotefront-annotation&quot;
    }

    labels = {
      mylabel = &quot;azurevotefront-value&quot;
    }

    name = &quot;azurevotefront-namespace&quot;
  }
}
</code></pre>
<p>Provider.tf</p>
<pre class="lang-json prettyprint-override"><code>terraform {
  backend &quot;azurerm&quot; {
    key = &quot;terraform.tfstate&quot;
    resource_group_name = &quot;MASKED&quot;
    storage_account_name = &quot;MASKED&quot;
    access_key = &quot;MASKED&quot;
    container_name = &quot;MASKED&quot;
  }
  required_providers {
    azurerm = {
      source  = &quot;hashicorp/azurerm&quot;
      version = &quot;~&gt;2.68&quot;
    }
    kubernetes = {
      source  = &quot;hashicorp/kubernetes&quot;
      version = &quot;~&gt; 2.4&quot;
    }
  }
}

provider &quot;azurerm&quot; {
  tenant_id = &quot;MASKED&quot;
  subscription_id = &quot;MASKED&quot;
  client_id = &quot;MASKED&quot;
  client_secret = &quot;MASKED&quot;
  features {}
}

</code></pre>

Jay
<p>as mentioned in the comments you are missing the kubernetes provider config:</p>
<pre><code>provider &quot;kubernetes&quot; {
  host                   = azurerm_kubernetes_cluster.aks.kube_admin_config.0.host
  client_certificate     = base64decode(azurerm_kubernetes_cluster.aks.kube_admin_config.0.client_certificate)
  client_key             = base64decode(azurerm_kubernetes_cluster.aks.kube_admin_config.0.client_key)
  cluster_ca_certificate = base64decode(azurerm_kubernetes_cluster.aks.kube_admin_config.0.cluster_ca_certificate)
}
</code></pre>
