安装方法和k8s-V1.6.2安装prometheus-operator一样。需要修改部署时contrib\kube-prometheus\manifests的yaml文件。
prometheus-operator:v0.11.3 (prometheus-operatorv0.12.0最低需要k8s >=v1.7.0)
k8s: 1.6.2
使用私有docker register
依赖的镜像:
quay.io/coreos/prometheus-operator:v0.11.3
quay.io/coreos/grafana-watcher:v0.0.6
grafana/grafana:4.4.1
quay.io/prometheus/alertmanager:v0.7.1
quay.io/coreos/kube-state-metrics:v0.5.0
quay.io/prometheus/node-exporter:v0.14.0
quay.io/coreos/config-reloader:v0.0.1
quay.io/coreos/prometheus-config-reloader:v0.0.2
quay.io/prometheus/prometheus:v1.7.0
全部9个镜像pull下来并tag修改为私有register,push到私有register中。push镜像到私有register中时需要配置私库,在/etc/sysconfig/docker中配置–insecure-registry 之后, systemctl restart docker
即可生效
[root@docker225 sysconfig]# cat /etc/sysconfig/docker
# /etc/sysconfig/docker
DOCKER_OPTIONS=" --insecure-registry 192.168.14.xxx:5000 --insecure-registry 192.168.14.172:10080
pull
docker pull quay.io/coreos/prometheus-operator:v0.11.3
tag
docker tag quay.io/coreos/prometheus-operator:v0.11.3 ${my_register}/quay.io/coreos/prometheus-operator:v0.11.3
push
docker push ${my_register}/quay.io/coreos/prometheus-operator:v0.11.3
prometheus-operator文档 https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md
prometheus-operator-0.11.3\contrib\kube-prometheus\manifests下所有使用到的镜像修改为私库register镜像。
例 quay.io/coreos/prometheus-operator:v0.11.3
修改为 ${my_register}/quay.io/coreos/prometheus-operator:v0.11.3
(以自己私库镜像名为准)。
镜像中依赖的镜像在配置文件中未标明,无法正常启动时依赖此镜像,需要修改为私库镜像
官方配置文档api地址
prometheus-operator 详细总结(helm一键安装) https://www.cnblogs.com/kevincaptain/p/10032694.html
Altertmanager
prometheus-operator下
k8s集群配置文件夹下prometheus/hack/manifests/alertmanager/alertmanager.yaml,增加baseImage: 192.168.14.171:5000/quay.io/prometheus/alertmanager从私有库获取镜像,镜像为 b a s e I m a g e : {baseImage}: baseImage:{version}
这里的默认值为baseImage=quay.io/prometheus/alertmanager
spec:
replicas: 3
version: v0.7.1
baseImage: 192.168.14.171:5000/quay.io/prometheus/alertmanager
在prometheus-k8s.yaml配置文件也添加baseImage: 192.168.14.171:5000/quay.io/prometheus/prometheus
spec:
replicas: 2
version: v1.7.0
baseImage: 192.168.14.171:5000/quay.io/prometheus/prometheus
serviceAccountName: prometheus-k8s
增加- --prometheus-config-reloader=192.168.14.171:5000/quay.io/coreos/prometheus-config-reloader:v0.0.2
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: prometheus-operator
spec:
containers:
- args:
- --kubelet-service=kube-system/kubelet
- --config-reloader-image=192.168.14.171:5000/quay.io/coreos/configmap-reload:v0.0.1
- --prometheus-config-reloader=192.168.14.171:5000/quay.io/coreos/prometheus-config-reloader:v0.0.2
image: 192.168.14.171:5000/quay.io/coreos/prometheus-operator:v0.11.3
name: prometheus-operator
服务器中时间为 ZT -0500 和 容器中 0000相差 5个小时
在grafana中显示的时间 应该是按上海的时区 +8 0800和容器数据时间相差8小时吻合。
原因:prometheus使用的时区和用户查看时的时区不一致。测试时相差8小时
结论:
所以部署prometheus成功后使用grafana看监控数据时,刚启动的时候因为容器和显示的时区相差8个小时。需要拉长监控时间才能看到数据
设置主机时区:
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
查看相差几个小时
[root@docker175 ~]# date -R
Fri, 22 Feb 2019 03:15:29 +0800
k8s中容器的时区修改:k8s容器时区为 0000,修改主机时区主机时间修改,容器的时间也会同步修改。
Kubernetes监控(coreos/prometheus-operator)
打印所有需要的镜像 docker images|grep -E "quay|grafana"| awk '{print $1}'
[root@docker176 ~]# docker images|grep -E "quay|grafana"| awk '{print $1}'
192.168.1.171:5000/quay.io/coreos/prometheus-operator
192.168.1.171:5000/quay.io/coreos/grafana-watcher
192.168.1.171:5000/grafana/grafana
192.168.1.171:5000/quay.io/coreos/prometheus-config-reloader
192.168.1.171:5000/quay.io/prometheus/alertmanager
192.168.1.171:5000/quay.io/prometheus/prometheus
192.168.1.171:5000/quay.io/coreos/kube-state-metrics
192.168.1.171:5000/quay.io/prometheus/node-exporter
192.168.1.171:5000/google_containers/heapster-grafana-amd64
192.168.1.171:5000/quay.io/coreos/configmap-reload
#将prometheus-operator需要的镜像打包
docker images|grep -E "quay|grafana"| awk '{print $1}' | xargs docker save -o prometheus-operator-v0.11.3.images.tar.gz
docker load -i $images_file
即
docker load -i docker save -o prometheus-operator-v0.11.3.images.tar.gz
导入私库