k8s环境下搭建prometheus

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

前言

啥都不说,直接开造!

开造

首先在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:
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值