Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PodMonitor #304

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions deploy/charts/trust-manager/templates/metrics-podmonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{- if and .Values.app.metrics.podmonitor.enabled .Values.app.metrics.service.servicemonitor.enabled }}
{{- fail "Either .Values.app.metrics.podmonitor.enabled or .Values.app.metrics.service.servicemonitor.enabled can be enabled at a time, but not both." }}
{{- else if .Values.app.metrics.podmonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ include "trust-manager.name" . }}
namespace: {{ include "trust-manager.namespace" . }}
labels:
app: {{ include "trust-manager.name" . }}
{{ include "trust-manager.labels" . | indent 4 }}
prometheus: {{ .Values.app.metrics.podmonitor.prometheusInstance }}
{{- if .Values.app.metrics.podmonitor.labels }}
{{ toYaml .Values.app.metrics.podmonitor.labels | indent 4}}
{{- end }}
{{- if .Values.app.metrics.podmonitor.annotations }}
annotations:
{{- with .Values.app.metrics.podmonitor.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
spec:
jobLabel: {{ include "trust-manager.name" . }}
selector:
matchLabels:
app: {{ include "trust-manager.name" . }}
namespaceSelector:
matchNames:
- {{ include "trust-manager.namespace" . }}
podMetricsEndpoints:
- port: {{ .Values.app.metrics.port }}
path: "/metrics"
interval: {{ .Values.app.metrics.podmonitor.interval }}
scrapeTimeout: {{ .Values.app.metrics.podmonitor.scrapeTimeout }}
{{- end }}
57 changes: 57 additions & 0 deletions deploy/charts/trust-manager/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
"helm-values.app.metrics": {
"type": "object",
"properties": {
"podmonitor": {
"$ref": "#/$defs/helm-values.app.metrics.podmonitor"
},
"port": {
"$ref": "#/$defs/helm-values.app.metrics.port"
},
Expand All @@ -117,6 +120,60 @@
},
"additionalProperties": false
},
"helm-values.app.metrics.podmonitor": {
"type": "object",
"properties": {
"annotations": {
"$ref": "#/$defs/helm-values.app.metrics.podmonitor.annotations"
},
"enabled": {
"$ref": "#/$defs/helm-values.app.metrics.podmonitor.enabled"
},
"interval": {
"$ref": "#/$defs/helm-values.app.metrics.podmonitor.interval"
},
"labels": {
"$ref": "#/$defs/helm-values.app.metrics.podmonitor.labels"
},
"prometheusInstance": {
"$ref": "#/$defs/helm-values.app.metrics.podmonitor.prometheusInstance"
},
"scrapeTimeout": {
"$ref": "#/$defs/helm-values.app.metrics.podmonitor.scrapeTimeout"
}
},
"additionalProperties": false
},
"helm-values.app.metrics.podmonitor.annotations": {
"description": "Additional annotations to add to the PodMonitor.",
"type": "object",
"default": {}
},
"helm-values.app.metrics.podmonitor.enabled": {
"description": "The PodMonitor resource for this Service.",
"type": "boolean",
"default": false
},
"helm-values.app.metrics.podmonitor.interval": {
"description": "The interval to scrape metrics.",
"type": "string",
"default": "10s"
},
"helm-values.app.metrics.podmonitor.labels": {
"description": "Additional labels to add to the PodMonitor.",
"type": "object",
"default": {}
},
"helm-values.app.metrics.podmonitor.prometheusInstance": {
"description": "Specifies the `prometheus` label on the created PodMonitor. This is used when different Prometheus instances have label selectors matching different PodMonitors.",
"type": "string",
"default": "default"
},
"helm-values.app.metrics.podmonitor.scrapeTimeout": {
"description": "The timeout before a metrics scrape fails.",
"type": "string",
"default": "5s"
},
"helm-values.app.metrics.port": {
"description": "The port for exposing Prometheus metrics on 0.0.0.0 on path '/metrics'.",
"type": "number",
Expand Down
16 changes: 16 additions & 0 deletions deploy/charts/trust-manager/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,22 @@ app:
scrapeTimeout: 5s
# Additional labels to add to the ServiceMonitor.
labels: {}
# Note that you can not enable both PodMonitor and ServiceMonitor as they are mutually exclusive. Enabling both will result in a error.
podmonitor:
# The PodMonitor resource for this Service.
enabled: false
# Specifies the `prometheus` label on the created PodMonitor. This is
# used when different Prometheus instances have label selectors matching
# different PodMonitors.
prometheusInstance: default
# The interval to scrape metrics.
interval: 10s
# The timeout before a metrics scrape fails.
scrapeTimeout: 5s
# Additional labels to add to the PodMonitor.
labels: {}
# Additional annotations to add to the PodMonitor.
annotations: {}

podDisruptionBudget:
# Enable or disable the PodDisruptionBudget resource.
Expand Down