controller-servicemonitor.yaml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. {{- if and .Values.controller.metrics.enabled .Values.controller.metrics.serviceMonitor.enabled -}}
  2. apiVersion: monitoring.coreos.com/v1
  3. kind: ServiceMonitor
  4. metadata:
  5. name: {{ include "ingress-nginx.controller.fullname" . }}
  6. {{- if .Values.controller.metrics.serviceMonitor.namespace }}
  7. namespace: {{ .Values.controller.metrics.serviceMonitor.namespace | quote }}
  8. {{- end }}
  9. labels:
  10. {{- include "ingress-nginx.labels" . | nindent 4 }}
  11. app.kubernetes.io/component: controller
  12. {{- if .Values.controller.metrics.serviceMonitor.additionalLabels }}
  13. {{- toYaml .Values.controller.metrics.serviceMonitor.additionalLabels | nindent 4 }}
  14. {{- end }}
  15. spec:
  16. endpoints:
  17. - port: {{ .Values.controller.metrics.portName }}
  18. interval: {{ .Values.controller.metrics.serviceMonitor.scrapeInterval }}
  19. {{- if .Values.controller.metrics.serviceMonitor.honorLabels }}
  20. honorLabels: true
  21. {{- end }}
  22. {{- if .Values.controller.metrics.serviceMonitor.relabelings }}
  23. relabelings: {{ toYaml .Values.controller.metrics.serviceMonitor.relabelings | nindent 8 }}
  24. {{- end }}
  25. {{- if .Values.controller.metrics.serviceMonitor.metricRelabelings }}
  26. metricRelabelings: {{ toYaml .Values.controller.metrics.serviceMonitor.metricRelabelings | nindent 8 }}
  27. {{- end }}
  28. {{- if .Values.controller.metrics.serviceMonitor.jobLabel }}
  29. jobLabel: {{ .Values.controller.metrics.serviceMonitor.jobLabel | quote }}
  30. {{- end }}
  31. {{- if .Values.controller.metrics.serviceMonitor.namespaceSelector }}
  32. namespaceSelector: {{ toYaml .Values.controller.metrics.serviceMonitor.namespaceSelector | nindent 4 }}
  33. {{- else }}
  34. namespaceSelector:
  35. matchNames:
  36. - {{ .Release.Namespace }}
  37. {{- end }}
  38. {{- if .Values.controller.metrics.serviceMonitor.targetLabels }}
  39. targetLabels:
  40. {{- range .Values.controller.metrics.serviceMonitor.targetLabels }}
  41. - {{ . }}
  42. {{- end }}
  43. {{- end }}
  44. selector:
  45. matchLabels:
  46. {{- include "ingress-nginx.selectorLabels" . | nindent 6 }}
  47. app.kubernetes.io/component: controller
  48. {{- end }}