Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upKubernetes SD fails with x509 name mismatch #1822
Comments
This comment has been minimized.
This comment has been minimized.
|
This is a deployment issue really & there isn't any option I can think of if you don't like the idea of creating a certificate with a valid IP SAN other than to disable certificate verification - see https://github.com/prometheus/prometheus/blob/master/documentation/examples/prometheus-kubernetes.yml#L22-L28 , which should also include the case where node certs don't have a valid IP SAN. |
This comment has been minimized.
This comment has been minimized.
|
Couldn't there be an option to use the host name rather than the IP? The API provides the node data with both the There are two reasons why I think this is necessary:
For these reasons, the cert cannot be assumed to have the IP as its SAN. In fact, from what I can tell, the only logical default for Prometheus is to use the I probably have time to cook up a PR if that sounds reasonable to you. |
This comment has been minimized.
This comment has been minimized.
|
Using |
This comment has been minimized.
This comment has been minimized.
|
BTW the Kubernetes SD was originally tracking what Heapster did to retrieve metrics from nodes, hence the current use of IP. |
This comment has been minimized.
This comment has been minimized.
|
Can you also verify if nodes have the same issuer as if they use self-signed certs then you're going to have to turn off certificate validation anyway... |
This comment has been minimized.
This comment has been minimized.
|
Aw dang, Kubelet doesn't use the CA at all. It's self-signed, so you're right, cert validation makes no sense. In that case, this really needs to be documented properly — unless you're running somewhere like GKE, where I believe each node is set up to sign a cert with the master's CA, then Kubelet's default behavior is to generate a self-signed cert, and |
This comment has been minimized.
This comment has been minimized.
|
Looks like we can probably rely on
We discussed this & didn't like the idea of disabling cert validation by default: felt dirty to have an insecure default. But it is going to be something that affects quite a number of users so a PR making this clearer would be very welcome I'm sure. |
This comment has been minimized.
This comment has been minimized.
|
Indeed. Re DNS, is that a requirement? Prometheus can still talk to the IP, as long as it provides the right host name in the TLS handshake. My challenge with Kubelet is that I want to be able to automate node creation (autoscaling and so forth). Doing automatic cert creation securely that way is a challenge I haven't yet solved. Unless I use a wildcard cert ( |
This comment has been minimized.
This comment has been minimized.
|
You're right that it is possible to override the expected server name in cert verification, but unfortunately there is no way to do that with Prometheus discovery AFAIK. If I was doing automated node creation & wanted to have validateable certs I'd probably look at cfssl or a custom installation of letsencrypt's boulder. |
This comment has been minimized.
This comment has been minimized.
|
FWIW, we just scrape the |
This comment has been minimized.
This comment has been minimized.
|
That's another option if you don't mind having an insecure port open on the kubelet. Some people see that port as opportunity for info leakage, & there have been plans to get rid of it for quite a while, although it's never happened (& may never). |
brian-brazil
referenced this issue
Aug 10, 2016
Closed
prometheus returnd cannot validate certificate #1882
brian-brazil
added
the
kind/question
label
Oct 26, 2016
brian-brazil
closed this
Oct 26, 2016
This comment has been minimized.
This comment has been minimized.
lock
bot
commented
Mar 24, 2019
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
atombender commentedJul 19, 2016
•
edited
What did you do?
kubernetes_sd_configs, according to official example.--hostname_override. Therefore, each node gets an unqualified host nameip-10-0-4-126or whatever./var/run/kubernetes/kubelet.crtis therefore set up like so:What did you expect to see?
Prometheus should be able to connect to Kubelet.
What did you see instead? Under which circumstances?
Instead, gets
x509: cannot validate certificate for 10.0.4.126 because it doesn't contain any IP SANstrying to connect tohttps://10.0.4.126:10250. Note use of IP instead of host name. This will never work.Environment
role: nodeto scrape the nodes.Related to #1654 and #1013. However, setting
server_nameis not possible as a workaround, obviously.FWIW, running
--hostname-override=$fqdndoesn't work either. I also tried--hostname-override=$ip, which K8s didn't like at all, although it may have been some kind of state management bug that doesn't like it when you change the hostnames after a node has previously been registered. Still, it shouldn't be necessary to change the host name. Nor should it be necessary to generate a custom cert on each Kubelet node that has the IP as the name.