文档地址:https://github.com/coreos/kube-prometheus

git 到本地:

git clone https://github.com/coreos/kube-prometheus.git

cd到yaml文件目录:

cd /kube-prometheus/manifests

修改svc为NodoPort可供外部访问:

修改 grafana-service.yaml 文件,使用 nodepode 方式访问 grafana:

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-service.yaml,改为 nodepode

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-service.yaml,改为 nodepode

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

首先运行setup文件下的yaml:

kubectl apply -f ../setup

在运行manifests文件夹下的:

 等待所有pod启动完毕:

 查看:

 http://192.168.170.140:30100/login 

默认 密码 账号:admin admin

数据来源:

这里已经为我们添加好了直接选即可:

 导入模版:

所有节点的状态:

数据:

命令:

kubectl top node

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐