修改config文件,在里面添加一行.
完整的实例,更新完成之后,记得apply一下.
[root@VM-64-25-centos manifests]# cat prometheus-prometheus.yaml
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
labels:
prometheus: k8s
name: k8s
namespace: monitoring
spec:
alerting:
alertmanagers:
- name: alertmanager-main
namespace: monitoring
port: web
image: quay.io/prometheus/prometheus:v2.17.2
nodeSelector:
kubernetes.io/os: linux
podMonitorNamespaceSelector: {}
podMonitorSelector: {}
replicas: 2
resources:
requests:
memory: 500Mi
ruleSelector:
matchLabels:
prometheus: k8s
role: alert-rules
securityContext:
fsGroup: 2000
runAsNonRoot: true
runAsUser: 1000
additionalScrapeConfigs:
name: additional-configs
key: prometheus-additional.yaml
retention: 7d #添加一行,持久化7天
storage:
volumeClaimTemplate:
spec:
storageClassName: prometheus-cfs
resources:
requests:
storage: 100Gi
serviceAccountName: prometheus-k8s
serviceMonitorNamespaceSelector: {}
serviceMonitorSelector: {}
version: v2.17.2
[root@VM-64-25-centos manifests]#
apply刚更改的文件
[root@VM-64-25-centos manifests]# kubectl apply -f prometheus-prometheus.yaml
[root@VM-64-25-centos manifests]#
See also