我正在尝试根据自定义指标在Kubernetes 1.2.3(beta)群集上设置自动缩放。 (我已经在群集上尝试过基于CPU的自动缩放,它工作正常。)
我试图关注他们的custom metrics proposal,但我在创建必要的设置方面遇到了问题。
这是我到目前为止所做的:
为正在部署的pod规范添加了自定义指标注释 (类似于他们提案中提供的配置):
apiVersion: v1
kind: ReplicationController
metadata:
name: metrix
namespace: "default"
spec:
replicas: 1
template:
metadata:
labels:
app: metrix
annotations:
metrics.alpha.kubernetes.io/custom-endpoints: >
[
{
"api": "prometheus",
"path": "/status",
"port": "9090",
"names": ["test1"]
},
{
"api": "prometheus",
"path": "/metrics",
"port": "9090"
"names": ["test2"]
}
]
spec:
containers:
- name: metrix
image: janaka/prometheus-ep:v1
resources:
requests:
cpu: 400m
创建了一个标记为janaka/prometheus-ep:v1
(本地)的Docker容器,在端口9090上运行与Prometheus兼容的服务器,/status
和/metrics
端点
在--enable-custom-metrics=true
KUBELET_OPTS
上/etc/default/kubelet
添加default
(基于the kubelet CLI reference)并重新启动kubelet
所有广告连播(在kube-system
和$ kubesys logs -f heapster-daftr
I0427 05:07:45.807277 1 heapster.go:60] /heapster --source=kubernetes:https://kubernetes.default --sink=influxdb:http://monitoring-influxdb:8086
I0427 05:07:45.807359 1 heapster.go:61] Heapster version 1.1.0-beta1
I0427 05:07:45.807638 1 configs.go:60] Using Kubernetes client with master "https://kubernetes.default" and version "v1"
I0427 05:07:45.807661 1 configs.go:61] Using kubelet port 10255
E0427 05:08:15.847319 1 influxdb.go:185] issues while creating an InfluxDB sink: failed to ping InfluxDB server at "monitoring-influxdb:8086" - Get http://monitoring-influxdb:8086/ping: dial tcp xxx.xxx.xxx.xxx:8086: i/o timeout, will retry on use
I0427 05:08:15.847376 1 influxdb.go:199] created influxdb sink with options: host:monitoring-influxdb:8086 user:root db:k8s
I0427 05:08:15.847412 1 heapster.go:87] Starting with InfluxDB Sink
I0427 05:08:15.847427 1 heapster.go:87] Starting with Metric Sink
I0427 05:08:15.877349 1 heapster.go:166] Starting heapster on port 8082
I0427 05:08:35.000342 1 manager.go:79] Scraping metrics start: 2016-04-27 05:08:00 +0000 UTC, end: 2016-04-27 05:08:30 +0000 UTC
I0427 05:08:35.035800 1 manager.go:152] ScrapeMetrics: time: 35.209696ms size: 24
I0427 05:08:35.044674 1 influxdb.go:177] Created database "k8s" on influxDB server at "monitoring-influxdb:8086"
I0427 05:09:05.000441 1 manager.go:79] Scraping metrics start: 2016-04-27 05:08:30 +0000 UTC, end: 2016-04-27 05:09:00 +0000 UTC
I0427 05:09:06.682941 1 manager.go:152] ScrapeMetrics: time: 1.682157776s size: 24
I0427 06:43:38.767146 1 manager.go:79] Scraping metrics start: 2016-04-27 05:09:00 +0000 UTC, end: 2016-04-27 05:09:30 +0000 UTC
I0427 06:43:38.810243 1 manager.go:152] ScrapeMetrics: time: 42.940682ms size: 1
I0427 06:44:05.012989 1 manager.go:79] Scraping metrics start: 2016-04-27 06:43:30 +0000 UTC, end: 2016-04-27 06:44:00 +0000 UTC
I0427 06:44:05.063583 1 manager.go:152] ScrapeMetrics: time: 50.368106ms size: 24
I0427 06:44:35.002038 1 manager.go:79] Scraping metrics start: 2016-04-27 06:44:00 +0000 UTC, end: 2016-04-27 06:44:30 +0000 UTC
名称空间中)都在运行,而heapster pod日志并不包含任何“异常”广告。输出(由于InfluxDB临时不可用,启动时出现小故障除外):
skip_before_action :authenticate_user!
但是,自定义端点没有被删除。 (我通过为我的服务器的启动和端点处理程序添加stderr日志来验证它;只有服务器初始化日志显示在pod的kubectl日志中。)
因为我是Kubernetes的新手,所以感谢任何帮助。
(根据我对提案以及this issue的理解,我们不必在群集中运行单独的Prometheus收集器,因为 cAdvisor 应该已经从中提取数据pod规范中定义的端点。这是真的吗,还是我还需要一个单独的Prometheus收集器?)