k8s安装prometheus
- 2022-06-27 19:46:30
- 运维
- 810
- shevechco
k8s安装prometheus
我本地安装的k8s是1.19.9这个版本,需要找到对应的安装版本
kube-prometheus stack | Kubernetes 1.19 | Kubernetes 1.20 | Kubernetes 1.21 | Kubernetes 1.22 | Kubernetes 1.23 |
release-0.7 | ✔ | ✔ | ✗ | ✗ | ✗ |
release-0.8 | ✗ | ✔ | ✔ | ✗ | ✗ |
release-0.9 | ✗ | ✗ | ✔ | ✔ | ✗ |
release-1.0 | ✗ | ✗ | ✗ | ✔ | ✔ |
main | ✗ | ✗ | ✗ | ✔ | ✔ |
目前我这个版本对应的是prometheus release-0.7这个版本,那么我们就直接打开
https://github.com/prometheus-operator/kube-prometheus/tree/release-0.7
克隆代码
git clone https://github.com/prometheus-operator/kube-prometheus.git cd kube-prometheus
我们做一些简单的修改来配置可以直接访问prometheus
vi manifests/prometheus-service.yaml
主要是添加一个nodeport端口,最后整个yaml大概如下:
apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/component: prometheus app.kubernetes.io/instance: k8s app.kubernetes.io/name: prometheus app.kubernetes.io/part-of: kube-prometheus app.kubernetes.io/version: 2.36.2 name: prometheus-k8s namespace: monitoring spec: ports: - name: web port: 9090 targetPort: web nodePort: 30090 - name: reloader-web port: 8080 targetPort: reloader-web selector: app.kubernetes.io/component: prometheus app.kubernetes.io/instance: k8s app.kubernetes.io/name: prometheus app.kubernetes.io/part-of: kube-prometheus sessionAffinity: ClientIP
接着我们修改报警管理
vi manifests/alertmanager-service.yaml apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/component: alert-router app.kubernetes.io/instance: main app.kubernetes.io/name: alertmanager app.kubernetes.io/part-of: kube-prometheus app.kubernetes.io/version: 0.24.0 name: alertmanager-main namespace: monitoring spec: ports: - name: web port: 9093 targetPort: web nodePort: 30093 - name: reloader-web port: 8080 targetPort: reloader-web selector: app.kubernetes.io/component: alert-router app.kubernetes.io/instance: main app.kubernetes.io/name: alertmanager app.kubernetes.io/part-of: kube-prometheus sessionAffinity: ClientIP
然后我们修改下grafana的yaml文件
vi manifests/grafana-service.yaml apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/component: grafana app.kubernetes.io/name: grafana app.kubernetes.io/part-of: kube-prometheus app.kubernetes.io/version: 9.0.1 name: grafana namespace: monitoring spec: ports: - name: http port: 3000 targetPort: http nodePort: 30099 selector: app.kubernetes.io/component: grafana app.kubernetes.io/name: grafana app.kubernetes.io/part-of: kube-prometheus
改好以后我们就开始安装了
kubectl create -f manifests/setup until kubectl get servicemonitors --all-namespaces; do date; sleep 1; echo ""; done kubectl create -f manifests/
然后我们观察相关pod,全部启动就可以直接使用节点IP加30099端口访问prometheus
-
标签
- prometheus
- k8s
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.sulao.cn/post/850
相关推荐
- k8s集群中mongdb、etcd、prometheus数据bash一键备份脚本
- k8s业务pod端口检测和日志采集bash脚本
- python获取k8s中使用物理卡pod列表脚本
- k8s基于clusterrole生成集群级别只读用户bash脚本
- k8s存储pv/pvc中的subPath的使用详解
- k8s容器退出码详细信息介绍
- k8s调度GPU节点并挂载GPU设备
- centos7二进制部署prometheus+alertmanager+grafana
- k8s使用nfs报错selfLink was empty, can't make reference
- centos7使用haproxy部署k8s高可用集群