helm安装prometheus+grafana,监控nginx
Get Repo Info
helm repo add grafana https://grafana.github.io/helm-charts
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
Installing the Chart
helm install grafana -n monitor grafana/grafana
helm install prometheus -n monitor prometheus-community/prometheus
一些修改
We need to visit the UI page to see the effect, so we expose the ports of prometheus-altermanager, prometheus, and granfana. And made ingress for grafana (although it was not used much).
我们应该修改svc的type为NodePort, 接下来是grafana的ingress文件
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: grafana
namespace: monitor
spec:
tls:
- hosts:
- grafana.digiits.xzf
rules:
- host: grafana.digiits.xzf
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: grafana
port:
number: 80
k apply -f ingress.yaml
get user/password from secret
xzfa@xiongzfa:~/workfiles/yaml/monitor$ k get secrets -n monitor
NAME TYPE DATA AGE
grafana Opaque 3 10d
xzfa@xiongzfa:~/workfiles/yaml/monitor$ k edit secrets -n monitor grafana
base64 user/password
配置nginx接入prometheus
nginx需要把自己的信息给暴露出来,需要再default.conf文件中进行配置,因为测试需要经常修改,因此我只是做了一个pvc把配置文件挂载出来。之后会用configmap的方式挂载配置文件。
因为关于vue的配置在之前的部署在部署文档中写过,这里只是做了一个修改,因此ingress、svc、vue的挂载就不再多说。下面只是对deployment的一些修改、以及nginx配置文件的挂载
apiVersion: v1
kind: PersistentVolume
metadata:
name: nginx
spec:
capacity:
storage: 100m
volumeMode: Filesystem
accessModes:
- ReadWriteMany
hostPath:
path: "/mnt/nginx/"
type: DirectoryOrCreate
persistentVolumeReclaimPolicy: Delete
storageClassName: local-path
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nginx
spec:
accessModes:
- ReadWriteMany
volumeMode: Filesystem
resources:
requests:
storage: 100m
storageClassName: "local-path"
apiVersion: apps/v1
kind: Deployment
metadata:
name</