详情:在使用 additionalScrapeConfigs 字段之后更新 yaml 文件一直没有创建 pod 以及 StatefulSet。yaml 文件如下
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
name: inst
namespace: monitoring
spec:
serviceAccountName: prometheus
serviceMonitorSelector:
matchLabels:
team: frontend
ruleSelector:
matchLabels:
role: alert-rules
prometheus: example
alerting:
alertmanagers:
- name: alertmanager-example
namespace: monitoring
port: web
additionalScrapeConfigs:
name: additional-scrape-configs
key: prometheus-additional.yaml
resources:
requests:
memory: 400Mi
随后查看 prometheus operator 发现错误日志
level=error ts=2021-01-05T14:43:55.626242695Z caller=klog.go:96 component=k8s_client_runtime func=ErrorDepth msg="Sync \"monitoring/inst\" failed: creating config failed: generating config failed: unmarshalling additional scrape configs failed: yaml: unmarshal errors:\n line 1: cannot unmarshal !!map into []yaml.MapSlice"
确认问题之后发现,是我的 prometheus-additional.yaml 最上方多写了一行…很尴尬。
删除之后重新创建 Secret 修复。