我是Kubernetes的新手。我想在Prometheus Operator中创建Service Monitor。我已经安装了普罗米修斯操作员和Grafana。我有运行中的pod,如下所示:

documentation of Prometheus Operator提供了以下代码来创建服务监视器。
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
name: prometheus
spec:
serviceAccountName: prometheus
serviceMonitorSelector:
matchLabels:
team: frontend
resources:
requests:
memory: 400Mi
enableAdminAPI: false我知道这是一个yaml文件,但是我不明白如何运行这个文件?换句话说,我应该把这段代码放在哪里?我正在学习创建普罗米修斯监视器。我能得到一些帮助吗?
谢谢!
发布于 2020-10-30 20:33:01
您可以像Kubernetes集群中的任何其他清单一样部署它,例如,通过运行kubectl apply -f servicemonitor.yaml。
您可以通过简单地运行kubectl get prometheus来检查是否部署了它
$ kubectl get prometheus
NAME VERSION REPLICAS AGE
prometheus 5s当您启用RBAC授权时,您应该使用另一个yaml:
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
name: prometheus
labels:
prometheus: prometheus
spec:
replicas: 2
serviceAccountName: prometheus
serviceMonitorSelector:
matchLabels:
team: frontend
alerting:
alertmanagers:
- namespace: default
name: alertmanager
port: webhttps://stackoverflow.com/questions/64598476
复制相似问题