cadvisor:提供密钥和证书时 TLS 不工作

cadvisor: TLS not working when provinding a key and a certificate

根据 cadvisor 文档 (https://github.com/google/cadvisor/blob/master/docs/runtime_options.md#metrics),使用选项 collector_cert 和 collector_key 应该在 Prometheus 端点上启用 TLS。

我已经使用以下命令启动了 cadvisor 容器: docker run --rm -d --volume=/:/rootfs:ro --volume=/tmp/cadvisor.crt:/etc/ssl/cadvisor.crt --volume=/tmp/cadvisor.key:/etc/ssl/cadvisor.key --volume=/var/run:/var/run:rw --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --publish=8080:8080 --name=cadvisor gcr.io/cadvisor/cadvisor:latest --collector_cert=/etc/ssl/cadvisor.crt --collector_key=/etc/ssl/cadvisor.key

但是当我尝试使用 curl https://127.0.0.1:8080/metrics -v 访问指标时,出现以下错误:

* Trying 127.0.0.1:8080...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* error:1408F10B:SSL routines:ssl3_get_record:wrong version number
* Closing connection 0
curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number

另一方面,使用 curl http://127.0.0.1:8080/metrics -v returns docker 主机指标

*   Trying 127.0.0.1:8080...
* TCP_NODELAY set
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /metrics HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/plain; version=0.0.4; charset=utf-8
< Date: Mon, 01 Feb 2021 11:03:33 GMT
< Transfer-Encoding: chunked
< 
{ [12148 bytes data]
100  300k    0  300k    0     0  4421k      0 --:--:-- --:--:-- --:--:-- 4357k
* Connection #0 to host 127.0.0.1 left intact

任何指点将不胜感激。

据我所知,cAdvisor 不支持https。也许您可以改用反向代理? github 上的同一主题存在问题:https://github.com/google/cadvisor/issues/2539

这些标志用于从启用了 TLS 身份验证的另一个端点收集数据。