[TOC]
普罗米修斯容器化就是在kubernetes中安装。
[root@k8s-master-01 ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master-01 Ready control-plane,master 16d v1.20.5
k8s-node-01 Ready <none> 16d v1.20.5
k8s-node-02 Ready <none> 16d v1.20.5
[root@k8s-master-01 ~]# git clone -b release-0.7 --single-branch https://github.com/prometheus-operator/kube-prometheus.git
# 或者
[root@k8s-master-01 ~]# wget https://github.com/prometheus-operator/kube-prometheus/archive/refs/tags/v0.7.0.tar.gz
[root@k8s-master-01 ~]# tar xf kube-prometheus-0.7.0.tar.gz
[root@k8s-master-01 ~]# cd kube-prometheus-0.7.0/manifests/setup
[root@k8s-master-01 ~/kube-prometheus-0.7.0/manifests/setup]# kubectl apply -f ./
# 部署普罗米修斯
[root@k8s-master-01 ~/kube-prometheus-0.7.0/manifests/setup]# cd ..
[root@k8s-master-01 ~/kube-prometheus-0.7.0/manifests]# kubectl apply -f ./
[root@k8s-master-01 ~/kube-prometheus-0.7.0/manifests]# mkdir ingress
[root@k8s-master-01 ~/kube-prometheus-0.7.0/manifests]# cd ingress/
[root@k8s-master-01 ~/kube-prometheus-0.7.0/manifests/ingress]# cat ingress.yaml
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: prom-ingress
namespace: monitoring
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: linux.alert.com
http:
paths:
- backend:
serviceName: alertmanager-main
servicePort: 9093
path: /
- host: linux.grafana.com
http:
paths:
- backend:
serviceName: grafana
servicePort: 3000
path: /
- host: linux.prometheus.com
http:
paths:
- backend:
serviceName: prometheus-k8s
servicePort: 9090
path: /
# 启动
[root@k8s-master-01 ~/kube-prometheus-0.7.0/manifests/ingress]# kubectl apply -f ingress.yaml
[root@k8s-master-01 ~/kube-prometheus-0.7.0/manifests/ingress]# kubectl get svc -n ingress-nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ingress-nginx-controller NodePort 10.108.202.150 <none> 80:31197/TCP,443:30826/TCP 12d
ingress-nginx-controller-admission ClusterIP 10.97.217.170 <none> 443/TCP 12d
192.168.15.31 linux.alert.com linux.grafana.com linux.prometheus.com
linux.alert.com:31197
linux.grafana.com:31197
linux.prometheus.com:31197