前言
啥都不说,直接开造!
开造
首先在k8s集群创建命名空间monitoring
kubectl create namespace monitoring
服务账户(prometheus-sa.yaml)
apiVersion: v1
kind: ServiceAccount
metadata:
name: prometheus
namespace: monitoring
集群角色(prometheus-clusterRole.yaml)
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: prometheus
rules:
- apiGroups: [""]
resources:
- nodes
- nodes/proxy
- services
- endpoints
- pods
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources:
- configmaps
verbs: ["get"]
- nonResourceURLs: ["/metrics"]
verbs: ["get"]
服务账户与集群角色绑定,完成授权(prometheus-clusterRoleBinding.yaml)
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: prometheus
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: prometheus
subjects:
- kind:

本文详细介绍了在Kubernetes环境中搭建Prometheus监控系统的全过程,包括创建命名空间、服务账户、集群角色及绑定,配置文件的创建与挂载,以及通过Deployment创建Pod,并设置NodePort类型的服务供外部访问。
最低0.47元/天 解锁文章
655

被折叠的 条评论
为什么被折叠?



