eddycharly / terraform-provider-kops

Brings kOps into terraform in a fully managed way
Apache License 2.0
85 stars 20 forks source link

metrics-server deployment failing - failed to scrape node #1095

Open joaozanuttoqr opened 10 months ago

joaozanuttoqr commented 10 months ago

I just started using the provider (version 1.26.0-alpha.1) with a basic configuration but I'm having trouble with the metrics-server. It fails to scrape node metrics with the error message:

E0906 16:54:20.683294       1 scraper.go:140] "Failed to scrape node" err="Get \"https://i-04cb08573c1656c4f.ec2.internal:10250/metrics/resource\": dial tcp: lookup i-04cb08573c1656c4f.ec2.internal on 100.64.0.10:53: no such host" node="i-04cb08573c1656c4f"

I found this workaround where I had to manually edit the metrics-server deployment and add the --kubelet-preferred-address-types=InternalIP arg and it worked, but I wanted it to be configured on cluster startup. Is it possible to add an input variable in the metrics_server_config in order to allow custom args? Or is there an easier solution that I'm missing?

I'm running a single control-plane node with two worker nodes on AWS. My current cluster config is looking like this:

resource "kops_cluster" "cluster" {
  name               = "${var.cluster_name}.${var.domain}"
  kubernetes_version = "1.26.8"
  dns_zone           = var.domain

  networking {
    calico {}

    network_id = aws_vpc.vpc.id
    topology {
      control_plane = "private"
      nodes         = "private"
      dns           = "Public"
    }
    dynamic "subnet" {
      for_each = ["a", "b", "c"]
      content {
        name = "private-${subnet.key}"
        type = "Private"
        zone = "us-east-1${subnet.value}"
      }
    }
    dynamic "subnet" {
      for_each = ["a", "b", "c"]
      content {
        name = "utility-${subnet.key}"
        type = "Utility"
        zone = "us-east-1${subnet.value}"
      }
    }
  }

  cloud_provider {
    aws {
      ebs_csi_driver {
        enabled = true
        managed = true
      }
    }
  }

  iam {
    allow_container_registry = true
  }

  api {
    access = ["0.0.0.0/0"]
  }

  authentication {
    aws {
      backend_mode = "CRD"
      identity_mappings {
        arn      = "arn:aws:iam::<account_id>:user/joao.zanutto"
        username = "admin"
        groups   = ["admin"]
      }
    }
  }

  authorization {
    rbac {}
  }

  metrics_server {
    enabled  = true
    insecure = false
  }

  cert_manager {
    enabled = true
    managed = true
  }

  etcd_cluster {
    name = "main"
    member {
      name           = "control-plane"
      instance_group = "control-plane"
    }
  }
  etcd_cluster {
    name = "events"
    member {
      name           = "control-plane"
      instance_group = "control-plane"
    }
  }
}