Skip to content

[kubernetes_inventory] connecting to localhost instead of "url" parameter value #9293

@vj6

Description

@vj6

Relevant telegraf.conf:

[[inputs.kube_inventory]]
  url = ["https://kubernetes.default.svc"]
  tls_ca = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
  namespace = ""
  bearer_token = "/var/run/secrets/kubernetes.io/serviceaccount/token"
  response_timeout = "10s"
  resource_include = ["daemonsets","deployments","statefulsets","persistentvolumes","persistentvolumeclaims","pods"]
  tagexclude = ["node_name","host"]

System info:

  1. Telegraf version: 1.18.3
  2. Operating system: CentOS Linux release 7.9.2009 (Core)

Docker

  1. Kubernetes Version: v1.18.6
  2. Docker version: 19.03.15, build 99e3ed8919

Steps to reproduce:

  1. test it using telegraf --test
bash-5.0# telegraf --config /telegraf.conf --test
2021-05-24T06:48:19Z I! Starting Telegraf 1.18.3
2021-05-24T06:48:19Z E! [inputs.kube_inventory] Error in plugin: Get "https://localhost/apis/apps/v1/daemonsets": dial tcp 127.0.0.1:443: connect: connection refused
2021-05-24T06:48:19Z E! [inputs.kube_inventory] Error in plugin: Get "https://localhost/apis/apps/v1/deployments": dial tcp 127.0.0.1:443: connect: connection refused
2021-05-24T06:48:19Z E! [inputs.kube_inventory] Error in plugin: Get "https://localhost/api/v1/pods": dial tcp 127.0.0.1:443: connect: connection refused
2021-05-24T06:48:19Z E! [inputs.kube_inventory] Error in plugin: Get "https://localhost/api/v1/persistentvolumes": dial tcp 127.0.0.1:443: connect: connection refused
2021-05-24T06:48:19Z E! [inputs.kube_inventory] Error in plugin: Get "https://localhost/api/v1/persistentvolumeclaims": dial tcp 127.0.0.1:443: connect: connection refused
2021-05-24T06:48:19Z E! [inputs.kube_inventory] Error in plugin: Get "https://localhost/apis/apps/v1/statefulsets": dial tcp 127.0.0.1:443: connect: connection refused
2021-05-24T06:48:19Z E! [telegraf] Error running agent: input plugins recorded 6 errors

Expected behavior:

telegraf should read the value of url in /telegraf.conf and try connecting to mentioned URL for the Kubernetes API

Actual behavior:

kube_inventory plugin always connecting to https://localhost, despite changing the url value in /telegraf.conf to "https://$HOSTIP:6443" or anything else (another hostname or IP)

Additional info:

  1. this works fine in 1.18.2
  2. Not very much sure but is it because in 1.18.3 - Migrate from github.com/ericchiang/k8s to github.com/kubernetes/client-go (Migrate from github.com/ericchiang/k8s to github.com/kubernetes/client-go #8937) - new k8 client change?
func newClient(baseURL, namespace, bearerToken string, timeout time.Duration, tlsConfig tls.ClientConfig) (*client, error) {
-                       Server:                baseURL,
+                       ServerName: baseURL,

Metadata

Metadata

Assignees

Labels

area/k8sbugunexpected problem or unintended behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions