下载
git clone https://github.com/coreos/kube-prometheus.git
cd kube-prometheus/manifests
修改grafana配置文件,添加nodeport访问方式,实例
apiVersion: v1
kind: Service
metadata:
labels:
app: grafana
name: grafana
namespace: monitoring
spec:
type: NodePort
ports:
- name: http
port: 3000
targetPort: http
nodePort: 30100
selector:
app: grafana
修改prometheus配置文件,添加nodeport访问方式,实例
apiVersion: v1
kind: Service
metadata:
labels:
prometheus: k8s
name: prometheus-k8s
namespace: monitoring
spec:
type: NodePort
ports:
- name: web
port: 9090
targetPort: web
nodePort: 30200
selector:
app: prometheus
prometheus: k8s
sessionAffinity: ClientIP
修改alertmanager配置文件,添加nodeport访问方式,实例
apiVersion: v1
kind: Service
metadata:
labels:
alertmanager: main
name: alertmanager-main
namespace: monitoring
spec:
type: NodePort
ports:
- name: web
port: 9093
targetPort: web
nodePort: 30300
selector:
alertmanager: main
app: alertmanager
sessionAffinity: ClientIP
安装
kubectl create ns monitoring
kubectl apply --server-side -f setup
until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done
kubectl apply -f .
查看是否安装成功
kubectl get pod -n monitoring
浏览器ip:30200打开prometheus监控,输入下方句式添加监控项
sum by (pod_name)(rate(container_cpu_usage_seconds_total{image!="",pod_name!=""}[1m]))
浏览器ip:30100打开grafana监控,默认账号密码都是admin,打开设置里dashboards三项插件
所有评论(0)