Skip to content

AKS - dial tcp [::1]:80: connect: connection refused on all plans modifying the azurerm_kubernetes_cluster resource #1307

@jamurtag

Description

@jamurtag

Please see this comment for the explanation of the root cause.

Terraform Version, Provider Version and Kubernetes Version

Terraform version: 0.15, 1.0
Kubernetes provider version: 2.3.0
Kubernetes version: 1.19

Affected Resource(s)

  • all resources

Terraform Configuration Files

Our configuration is almost identical to your aks example code, so I tried using that and replicated the behaviour.

Note - I simulated by modifying the workers_count variable in the aks-cluster directory, however this isn't actually implemented in your code. Modify line 23 to be node_count = var.workers_count, then pass a new value in via the aks-cluster module in main.tf.

Steps to Reproduce

  1. Update the aks-cluster module as directed above to support workers_count
  2. terraform apply
  3. Change the workers_count variable to any other value
  4. terraform plan

Expected Behavior

Terraform should display a plan showing the updated node pool count.

Actual Behavior

The following error is reported:

$ terraform plan
random_id.cluster_name: Refreshing state... [id=aE_9C3A]
module.aks-cluster.azurerm_resource_group.default: Refreshing state... [id=/subscriptions/ff83a9d2-8d6e-4c4a-8b34-641163f8c99f/resourceGroups/tf-k8s-684ffd0b70]
module.aks-cluster.azurerm_kubernetes_cluster.default: Refreshing state... [id=/subscriptions/ff83a9d2-8d6e-4c4a-8b34-641163f8c99f/resourcegroups/tf-k8s-684ffd0b70/providers/Microsoft.ContainerService/managedClusters/tf-k8s-684ffd0b70]
module.kubernetes-config.local_file.kubeconfig: Refreshing state... [id=1ca8ad3c1c7f4aff65e5eda0038b619788b0956a]
module.kubernetes-config.helm_release.nginx_ingress: Refreshing state... [id=nginx-ingress-controller]
module.kubernetes-config.kubernetes_namespace.test: Refreshing state... [id=test]
╷
│ Error: Get "http://localhost/api/v1/namespaces/test": dial tcp [::1]:80: connect: connection refused
│
│   with module.kubernetes-config.kubernetes_namespace.test,
│   on kubernetes-config/main.tf line 14, in resource "kubernetes_namespace" "test":14: resource "kubernetes_namespace" "test" {
│
╵
╷
│ Error: Kubernetes cluster unreachable: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
│
│   with module.kubernetes-config.helm_release.nginx_ingress,
│   on kubernetes-config/main.tf line 59, in resource "helm_release" "nginx_ingress":59: resource helm_release nginx_ingress {

The data source is clearly not passing back valid data, even though there is a dependency on the aks-cluster module.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions