编辑 /etc/kubez/globals.yml
取消 enable_prometheus: "no"
的注释,并设置为 "yes"
# grafana will also be deploy when prometheus is enable.
enable_prometheus: "yes"
[root@k8s-151 ~]# kubectl get pods -A | grep prometheus
pixiu-system prometheus-alertmanager-55ff5486b8-6xfx9 2/2 Running 10 (95s ago) 20h
pixiu-system prometheus-kube-state-metrics-5d7c465bbd-cbx4q 1/1 Running 5 (95s ago) 20h
pixiu-system prometheus-node-exporter-kvkc7 1/1 Running 5 (95s ago) 20h
pixiu-system prometheus-pushgateway-6475d4bbcc-lj6f5 1/1 Running 5 (95s ago) 20h
pixiu-system prometheus-server-5bc886d8bf-7c9b2 2/2 Running 10 (95s ago) 20h
cat monitoring-ingress.yaml
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
labels:
app: grafana
name: grafana
namespace: pixiu-system
spec:
ingressClassName: nginx
rules:
- host: k8s-grafana.pixiu.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: grafana
port:
number: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
labels:
app: prometheus
prometheus: k8s
name: prometheus-k8s
namespace: pixiu-system
spec:
ingressClassName: nginx
rules:
- host: k8s-prom.pixiu.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: prometheus-server
port:
number: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
labels:
app: alertmanager
prometheus: k8s
name: alertmanager
namespace: pixiu-system
spec:
ingressClassName: nginx
rules:
- host: k8s-alertm.pixiu.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: prometheus-alertmanager
port:
number: 80
kubectl apply -f 3.monitoring-ingress.yaml
[root@k8s-151 ~]# kubectl get ing -A
NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE
pixiu-system alertmanager nginx k8s-alertm.pixiu.com 10.0.0.115 80 13h
pixiu-system grafana nginx k8s-grafana.pixiu.com 10.0.0.115 80 13h
pixiu-system prometheus-k8s nginx k8s-prom.pixiu.com 10.0.0.115 80 13h
kubectl get secret -n pixiu-system grafana -o yaml |grep password | awk '{ print $2 }' | base64 -d