Unable to detect the kubelet URL automatically / cannot validate certificate
Output of the info page
Getting the status from the agent.
==============
Agent (v6.6.0)
==============
Status date: 2018-11-13 23:10:34.603102 UTC
Pid: 342
Python Version: 2.7.15
Logs:
Check Runners: 4
Log Level: info
Paths
=====
Config File: /etc/datadog-agent/datadog.yaml
conf.d: /etc/datadog-agent/conf.d
checks.d: /etc/datadog-agent/checks.d
Clocks
======
NTP offset: 1.461ms
System UTC time: 2018-11-13 23:10:34.603102 UTC
Host Info
=========
bootTime: 2018-11-08 08:50:28.000000 UTC
kernelVersion: 4.9.0-7-amd64
os: linux
platform: debian
platformFamily: debian
platformVersion: buster/sid
procs: 70
uptime: 133h51m42s
virtualizationRole: host
virtualizationSystem: kvm
Hostnames
=========
hostname: reverent-kapitsa-1us
socket-fqdn: datadog-agent-pxkhm
socket-hostname: datadog-agent-pxkhm
hostname provider: container
unused hostname providers:
aws: not retrieving hostname from AWS: the host is not an ECS instance, and other providers already retrieve non-default hostnames
configuration/environment: hostname is empty
gce: unable to retrieve hostname from GCE: status code 404 trying to GET http://169.254.169.254/computeMetadata/v1/instance/hostname
=========
Collector
=========
Running Checks
==============
cpu
---
Instance ID: cpu [OK]
Total Runs: 114
Metric Samples: 6, Total: 678
Events: 0, Total: 0
Service Checks: 0, Total: 0
Average Execution Time : 0s
disk (1.4.0)
------------
Instance ID: disk:e5dffb8bef24336f [OK]
Total Runs: 114
Metric Samples: 190, Total: 21,660
Events: 0, Total: 0
Service Checks: 0, Total: 0
Average Execution Time : 197ms
docker
------
Instance ID: docker [OK]
Total Runs: 113
Metric Samples: 216, Total: 23,850
Events: 0, Total: 6
Service Checks: 1, Total: 113
Average Execution Time : 203ms
file_handle
-----------
Instance ID: file_handle [OK]
Total Runs: 114
Metric Samples: 5, Total: 570
Events: 0, Total: 0
Service Checks: 0, Total: 0
Average Execution Time : 0s
io
--
Instance ID: io [OK]
Total Runs: 113
Metric Samples: 39, Total: 4,380
Events: 0, Total: 0
Service Checks: 0, Total: 0
Average Execution Time : 0s
kubelet (2.2.0)
---------------
Instance ID: kubelet:d884b5186b651429 [ERROR]
Total Runs: 114
Metric Samples: 0, Total: 0
Events: 0, Total: 0
Service Checks: 0, Total: 0
Average Execution Time : 8ms
Error: Unable to detect the kubelet URL automatically.
Traceback (most recent call last):
File "/opt/datadog-agent/embedded/lib/python2.7/site-packages/datadog_checks/base/checks/base.py", line 366, in run
self.check(copy.deepcopy(self.instances[0]))
File "/opt/datadog-agent/embedded/lib/python2.7/site-packages/datadog_checks/kubelet/kubelet.py", line 113, in check
raise CheckException("Unable to detect the kubelet URL automatically.")
CheckException: Unable to detect the kubelet URL automatically.
kubernetes_apiserver
--------------------
Instance ID: kubernetes_apiserver [OK]
Total Runs: 113
Metric Samples: 0, Total: 0
Events: 0, Total: 0
Service Checks: 0, Total: 0
Average Execution Time : 11ms
load
----
Instance ID: load [OK]
Total Runs: 114
Metric Samples: 6, Total: 684
Events: 0, Total: 0
Service Checks: 0, Total: 0
Average Execution Time : 2ms
memory
------
Instance ID: memory [OK]
Total Runs: 113
Metric Samples: 17, Total: 1,921
Events: 0, Total: 0
Service Checks: 0, Total: 0
Average Execution Time : 0s
network (1.7.0)
---------------
Instance ID: network:2a218184ebe03606 [OK]
Total Runs: 114
Metric Samples: 74, Total: 8,754
Events: 0, Total: 0
Service Checks: 0, Total: 0
Average Execution Time : 9ms
ntp
---
Instance ID: ntp:b4579e02d1981c12 [OK]
Total Runs: 113
Metric Samples: 1, Total: 113
Events: 0, Total: 0
Service Checks: 1, Total: 113
Average Execution Time : 2ms
uptime
------
Instance ID: uptime [OK]
Total Runs: 114
Metric Samples: 1, Total: 114
Events: 0, Total: 0
Service Checks: 0, Total: 0
Average Execution Time : 2ms
========
JMXFetch
========
Initialized checks
==================
no checks
Failed checks
=============
no checks
=========
Forwarder
=========
CheckRunsV1: 113
Dropped: 0
DroppedOnInput: 0
Events: 0
HostMetadata: 0
IntakeV1: 11
Metadata: 0
Requeued: 0
Retried: 0
RetryQueueSize: 0
Series: 0
ServiceChecks: 0
SketchSeries: 0
Success: 237
TimeseriesV1: 113
API Keys status
===============
API key ending with 1ed66 on endpoint https://app.datadoghq.com: API Key valid
==========
Logs Agent
==========
container_collect_all
---------------------
Type: docker
Status: Pending
=========
DogStatsD
=========
Checks Metric Sample: 65,227
Event: 7
Events Flushed: 7
Number Of Flushes: 113
Series Flushed: 53,494
Service Check: 1,478
Service Checks Flushed: 1,578
Dogstatsd Metric Sample: 11,877
Additional environment details (Operating System, Cloud provider, etc):
Kubernetes 1.12 cluster on DigitalOcean.
Steps to reproduce the issue:
- Deploy the Datadog agent using the provider Kubernetes resources.
- View logs
Describe the results you received:
[ AGENT ] 2018-11-13 22:42:31 UTC | ERROR | (kubeutil.go:50 in GetKubeletConnectionInfo) | connection to kubelet failed: temporary failure in kubeutil, will retry later: try delay not elapsed yet
[ AGENT ] 2018-11-13 22:42:31 UTC | ERROR | (runner.go:289 in work) | Error running check kubelet: [{"message": "Unable to detect the kubelet URL automatically.", "traceback": "Traceback (most recent call last):\n File \"/opt/datadog-agent/embedded/lib/python2.7/site-packages/datadog_checks/base/checks/base.py\", line 366, in run\n self.check(copy.deepcopy(self.instances[0]))\n File \"/opt/datadog-agent/embedded/lib/python2.7/site-packages/datadog_checks/kubelet/kubelet.py\", line 113, in check\n raise CheckException(\"Unable to detect the kubelet URL automatically.\")\nCheckException: Unable to detect the kubelet URL automatically.\n"}]
[...]
[ AGENT ] 2018-11-13 22:42:39 UTC | ERROR | (autoconfig.go:608 in collect) | Unable to collect configurations from provider Kubernetes: temporary failure in kubeutil, will retry later: cannot connect: https: "Get https://10.133.78.180:10250/pods: x509: cannot validate certificate for 10.133.78.180 because it doesn't contain any IP SANs", http: "Get http://10.133.78.180:10255/pods: dial tcp 10.133.78.180:10255: connect: connection refused"
[ AGENT ] 2018-11-13 22:42:39 UTC | INFO | (autoconfig.go:362 in initListenerCandidates) | kubelet listener cannot start, will retry: temporary failure in kubeutil, will retry later: cannot connect: https: "Get https://10.133.78.180:10250/pods: x509: cannot validate certificate for 10.133.78.180 because it doesn't contain any IP SANs", http: "Get http://10.133.78.180:10255/pods: dial tcp 10.133.78.180:10255: connect: connection refused"
Many dashboard entries remain empty.
Describe the results you expected:
No errors, access to kubelet, functional Kubernetes dashboard.
Additional information you deem important (e.g. issue happens only occasionally):
Seems to be the same problem as #1829, however that issue is closed. Hosted Kubernetes services like DigitalOcean do not allow editing the kubelet configuration as far as I know.
This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.
I'm seeing this issue in kubernetes v1.12 on digital ocean as well
@mjhuber I opened a ticket on the Datadog issue tracker. Advice was to set DD_KUBELET_TLS_VERIFY=false for now. Hopefully DO will start using real certificates for the Kubelet API.
Im running into this same issue using AWS EKS, using the EKS Optimized AMI Image for a worker node.
Using DD_KUBELET_TLS_VERIFY=false is not a solution for us: the problem seems to be that the read only port on kubelet is deprecated on recent versions of Kubernetes (I'm on 1.11)
I suppose the Datadog agent should get stats from kubelet using a different method.
The recommendation for newer Kubernetes versions is to use kube-state-metrics for cluster-level metrics and use the metrics API (powered by e.g. metrics-server) for node-level and pod-level metrics.
@praseodym oh hi Mark ;-) Where did you find this recommendation? Because both the integrations page in Datadog, and the documentation pointed me towards a 'standard' kubernetes deployment that uses the kubelet readonly port.
Someone then pointed me to the helm chart for deploying datadog which uses the method you suggest and that works for me.
@PHameete did you solve your issue using DD_KUBERNETES_HTTPS_KUBELET_PORT or weren't you able to find a solution?
Sorry seems I had an old version of the page open.
@PHameete Sorry for the confusion here: I meant that the Datadog agent itself should be updated to use kube-state-metrics and the metrics API, which should prevent it from needing access to the kubelets directly. This is more of an improvement than an actual bug, though.
Regarding your issue with EKS, you should still be able to connect to the TLS port (10250) if RBAC is configured correctly so that the agent can authenticate to kubelet. We’re running without the read-only port on Kubernetes v1.13.2 and disabling TLS verification in the agent was all we had to do.
Edit: I only now noticed that the Helm chart you linked does mention the agent using kube-state-metrics, so I guess that part is already implemented :)
Even I ran into same problem ! Problem is with the EKS AMI(worker node) with the new AMI datadog and even some cpu and memory related metrics are also not working properly. I have used ami-0a0b913ef3249b655 and its working fine.
Just worked through this and wanted to share what it I understand it would take to not set DD_KUBELET_TLS_VERIFY=false.
We use typhoon which runs the kubelet via systemd. It disables the readonly port and passes --authentication-token-webhook --authorization-mode=Webhook to enable bearer token auth with the kubelet API. We install the datadog agent via Helm and found that disabling TLS verification was all we needed to do in order to collect metrics without the read only port.
I hopped onto a worker and tried curl https://localhost:10250 --cacert /etc/kubernetes/ca.crt, thinking the kubelet api's certs were signed with the same CA used to sign the apiserver's certs. Turns out that's not the case.
https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet-tls-bootstrapping/#client-and-serving-certificates
By default, the kubelet is creating a self-signed key/cert for its server on start. If you specified --tls-{private-key,cert}-file and provide the CA cert used to sign them to the client (i.e. curl or the datadog agent), it should work.
Here's some discussion about addressing this issue in kubeadm:
https://github.com/kubernetes/kubeadm/issues/1223
Given that the datadog role is effectively read-only, we felt the risks of unverified TLS were acceptable until we have an opportunity to look at ways to sign kubelet API certs with a known CA or have the kubelet write its CA cert out to disk.
We are seeing this error even after setting DD_KUBELET_TLS_VERIFY=false. Any help is much appreciated
I have tried running all versions from 6.6.0 to 6.9.0
We are seeing this error even after setting
DD_KUBELET_TLS_VERIFY=false. Any help is much appreciatedI have tried running all versions from 6.6.0 to 6.9.0
@sridhar81 have you tried my solution ?
We are seeing this error even after setting
DD_KUBELET_TLS_VERIFY=false. Any help is much appreciated I have tried running all versions from 6.6.0 to 6.9.0@sridhar81 have you tried my solution ?
@VinayVanama Thanks for the pointer. We are not using EKS. We are running our own cluster. Changing the AMI is going to be hard.
Hi everyone,
There seems to be several problems here.
For @jcassee:
As you mentioned, we previously suggested setting kubelet_tls_verify to false. We understand it’s not a great solution, security wise.
As we can see from the logs, it seems that the issue is from the certificate.
If we take a deeper look, we can see on this log:
[ AGENT ] 2018-11-13 22:42:39 UTC | INFO | (autoconfig.go:362 in initListenerCandidates) | kubelet listener cannot start, will retry: temporary failure in kubeutil, will retry later: cannot connect: https: "Get https://10.133.78.180:10250/pods: x509: cannot validate certificate for 10.133.78.180 because it doesn't contain any IP SANs", http: "Get http://10.133.78.180:10255/pods: dial tcp 10.133.78.180:10255: connect: connection refused"
The certificate cannot be validated because there is no SAN for the IP address of the node. The certificate most likely uses the hostname of the node, as its common Name. What you could do is deploy our agent to use the node name instead of the IP to connect to the kubelet, by modifying the daemonset. Replace:
- name: DD_KUBERNETES_KUBELET_HOST
valueFrom:
fieldRef:
fieldPath: status.hostIP
By:
- name: DD_KUBERNETES_KUBELET_HOST
valueFrom:
fieldRef:
fieldPath: spec.nodeName
We are also in touch with DigitalOcean to suggest adding the node IP as a SAN in the certificate.
For @mjhuber Could you try the same work-around? Thanks!
For @PHameete and @praseodym We do try querying the Kubelet on the (read-only) port 10255 to get Kubernetes metrics: https://docs.datadoghq.com/agent/kubernetes/metrics/#kubelet But only after trying the HTTPS port (10250) which should always be open. I suspect the message you’re seeing happens after the https call fails.
We also have the kubernetes_state integration which queries the KSM pod and get these metrics: https://docs.datadoghq.com/agent/kubernetes/metrics/#kube-state-metrics Which are different.
Disabling the TLS verification should not be needed if the correct certificates are used. If it doesn't work, we would be happy to investigate. Please reach out to our support team if needed: [email protected]
For @bendrucker
Indeed, if your kubelet configuration doesn't use this certificate /etc/kubernetes/ca.crt, our integration won't work out of the box.
However, if you have access to the certificate and the key, you can mount them in the agent pod, and use these env vars to specify the new paths:
DD_KUBELET_CLIENT_CA : to specify the path of the ca.crt
DD_KUBELET_CLIENT_CRT : to specify the path of the crt
DD_KUBELET_CLIENT_KEY : to specify the path of the key
Please reach out to our support team if you need further details: [email protected]
For @sridhar81
If DD_KUBELET_TLS_VERIFY=false doesn't work. It might not be a certificate issue.
Did you use the RBACs provided in our documentation?
https://docs.datadoghq.com/agent/kubernetes/daemonset_setup/#configure-rbac-permissions
Please reach out to our support team if more troubleshooting is needed: [email protected]
@Simwar I determined that the certificate does not, unfortunately, has the plain hostname as the common name:
root@datadog-agent-4tfsc:/# gnutls-cli -p 10250 $DD_KUBERNETES_KUBELET_HOST
Processed 0 CA certificate(s).
Resolving '10.133.96.228:10250'...
Connecting to '10.133.96.228:10250'...
- Certificate type: X.509
- Got a certificate list of 2 certificates.
- Certificate[0] info:
- subject `CN=priceless-easley-c7ti@1551951286', issuer `CN=priceless-easley-c7ti-ca@1551951286', serial 0x02, RSA key 2048 bits, signed using RSA-SHA256, activated `2019-03-07 08:34:46 UTC', expires `2020-03-06 08:34:46 UTC', pin-sha256="WfR4bITrk3Hh7r4ogdDSmzjFIbMDbf2+jsfg1Xb2QGo="
Public Key ID:
sha1:ab0f29c4eb8269623802dbb9e473bfc89ff73a72
sha256:59f4786c84eb9371e1eebe2881d0d29b38c521b3036dfdbe8ec7e0d576f6406a
Public Key PIN:
pin-sha256:WfR4bITrk3Hh7r4ogdDSmzjFIbMDbf2+jsfg1Xb2QGo=
- Certificate[1] info:
- subject `CN=priceless-easley-c7ti-ca@1551951286', issuer `CN=priceless-easley-c7ti-ca@1551951286', serial 0x01, RSA key 2048 bits, signed using RSA-SHA256, activated `2019-03-07 08:34:46 UTC', expires `2020-03-06 08:34:46 UTC', pin-sha256="F3NkU0M9gT1FID/MzxTFK8eohaAZrMElr1Yz1Bj1Rr4="
- Status: The certificate is NOT trusted. The certificate issuer is unknown. The name in the certificate does not match the expected.
*** PKI verification of server certificate failed...
*** Fatal error: Error in the certificate.
Also, the node hostname cannot be resolved from within the pod:
root@datadog-agent-4tfsc:/# host priceless-easley-c7ti
Host priceless-easley-c7ti not found: 3(NXDOMAIN)
Can confirm adding DD_KUBELET_TLS_VERIFY=false does indeed work.
For posterity: https://github.com/chris-short/wingedblade/blob/master/datadog-agent.yaml#L35
Confirming that with Kubernetes 1.13 installed via kubeadm DD_KUBELET_TLS_VERIFY=false fixed my issues as well :)
This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.
I am running on k8s v1.11.5 on digital ocean
it says:
cannot validate certificate for local-ipbecause it doesn't contain any IP SANs
http: "Get http://<local-ip>:10255/pods: dial tcp 10.131.62.180:10255: connect: connection refused"
This confirms the findings of @jcassee
DD_KUBELET_TLS_VERIFY=false did not work for me
I am getting a different error:
Failed to establish a new connection: [Errno 113] No route to host
along with warning
Network "" not found, trying bridge IP instead