[root@master ~]# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
[root@master ~]# helm repo update
[root@master ~]# helm search repo kube-prometheus-stack
NAME CHART VERSION APP VERSION DESCRIPTION
prometheus-community/kube-prometheus-stack 57.0.3 v0.72.0 kube-prometheus-stack collects Kubernetes manif...
[root@master ~]# helm install op prometheus-community/kube-prometheus-stack --namespace kube-monitor --create-namespace
NAME: op
LAST DEPLOYED: Wed Mar 20 16:52:30 2024
NAMESPACE: kube-monitor
STATUS: deployed
REVISION: 1
NOTES:
kube-prometheus-stack has been installed. Check its status by running:
kubectl --namespace kube-monitor get pods -l "release=op"
Visit https://github.com/prometheus-operator/kube-prometheus for instructions on how to create & configure Alertmanager and Prometheus instances using the Operator.
[root@master ~]# kubectl get secret op-grafana -n kube-monitor -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
prom-operator
# Gafana 暴露
[root@master ~]# kubectl edit svc op-grafana -n kube-monitor
service/op-grafana edited
[root@master ~]# kubectl get svc op-grafana -n kube-monitor -o yaml |grep -i nodeport
nodePort: 30300 # 自定义暴露端口,默认随机
type: NodePort # 类型模式
# Prometheus 暴露
[root@master ~]# kubectl edit svc op-kube-prometheus-stack-prometheus -n kube-monitor
service/op-kube-prometheus-stack-prometheus edited
[root@master ~]# kubectl get svc op-kube-prometheus-stack-prometheus -n kube-monitor -o yaml |grep -i nodeport
nodePort: 30301
nodePort: 31177
type: NodePort