Kubernetes 1.12 以前使用 Heapster 做集群监控,以提供数据给 kubectl top
命令以及 kubernetes-dashboard 的 Web UI 查看。Heapster 默认使用 InfluxDB,而 InfluxDB 默认设置的 retention policy 是七天一个 shard,无限保留,使用内存索引,所以时间久了后 InfluxDB 会消耗接近 10GB 内存。
InfluxDB 这个 default retention policy 无法在环境变量和配置文件里修改,只能在 CRETE DATABASE WITH DURATION m REPLICATION 1 SHARD DURATION n
或者创建数据库后用 ALTER RETENTION POLICY autogen ON db DURATION m REPLICATION 1 SHARD DURATION n
修改。其员工 Michael Desa 在 stackoverflow 上解释了下:
Unfortunately there is no way to set the default retention policy via the configuration. The reason for this is that typically retention policy duration is defined during database creation.
If users were allowed to set a default retention duration via the configuration, the results of the commandCREATE DATABASE mydb
would vary from instance to instance. While this isn’t necessarily problemati