K8s部署Prometheus yaml 文件
时间: 2023-06-21 17:10:28 浏览: 132
以下是一个示例的Prometheus部署yaml文件:
```yaml
apiVersion: v1
kind: Service
metadata:
name: prometheus
labels:
app: prometheus
spec:
type: NodePort
selector:
app: prometheus
ports:
- name: web
port: 9090
targetPort: web
nodePort: 30090
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus
spec:
replicas: 1
selector:
matchLabels:
app: prometheus
template:
metadata:
labels:
app: prometheus
spec:
containers:
- name: prometheus
image: prom/prometheus:v2.19.3
args:
- "--config.file=/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus/data"
ports:
- name: web
containerPort: 9090
volumeMounts:
- name: prometheus-config-volume
mountPath: /prometheus
volumes:
- name: prometheus-config-volume
configMap:
name: prometheus-config
```
这个yaml文件包含了一个Service和一个Deployment。Service暴露了Prometheus的端口,使得用户可以通过NodePort来访问Prometheus。Deployment定义了一个Pod,使用Prometheus的官方镜像,并挂载了配置文件的ConfigMap和数据卷。这个Deployment只有一个副本。同时,这个yaml文件也定义了Prometheus的配置文件的ConfigMap,可以在这个ConfigMap中配置Prometheus的监控目标。
阅读全文