diff --git a/charts/flyte-binary/README.md b/charts/flyte-binary/README.md index b2c5c39e746..0198b645794 100644 --- a/charts/flyte-binary/README.md +++ b/charts/flyte-binary/README.md @@ -172,4 +172,8 @@ Chart for basic single Flyte executable deployment | serviceAccount.imagePullSecrets | list | `[]` | | | serviceAccount.labels | object | `{}` | | | serviceAccount.name | string | `""` | | +| serviceMonitor.enabled | bool | `false` | | +| serviceMonitor.interval | string | `"60s"` | | +| serviceMonitor.labels | object | `{}` | | +| serviceMonitor.scrapeTimeout | string | `"30s"` | | diff --git a/charts/flyte-binary/templates/service-monitor.yaml b/charts/flyte-binary/templates/service-monitor.yaml new file mode 100644 index 00000000000..13ccc54a9b2 --- /dev/null +++ b/charts/flyte-binary/templates/service-monitor.yaml @@ -0,0 +1,25 @@ +{{- if .Values.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "flyte-binary.fullname" . }} + namespace: {{ .Release.Namespace | quote }} + labels: {{- include "flyte-binary.labels" . | nindent 4 }} + {{- if .Values.commonLabels }} + {{- tpl ( .Values.commonLabels | toYaml ) . | nindent 4 }} + {{- end }} + {{- if .Values.serviceMonitor.labels }} + {{- tpl ( .Values.serviceMonitor.labels | toYaml ) . | nindent 4 }} + {{- end }} + {{- if .Values.commonAnnotations }} + annotations: {{- tpl ( .Values.commonAnnotations | toYaml ) . | nindent 4 }} + {{- end }} +spec: + endpoints: + - port: http-metrics + path: /metrics + interval: {{ .Values.serviceMonitor.interval }} + scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }} + selector: + matchLabels: {{- include "flyte-binary.baseLabels" . | nindent 6 }} +{{- end }} diff --git a/charts/flyte-binary/values.yaml b/charts/flyte-binary/values.yaml index 32370c2e14d..a49d4fb0063 100644 --- a/charts/flyte-binary/values.yaml +++ b/charts/flyte-binary/values.yaml @@ -343,6 +343,18 @@ service: # extraPorts Additional ports to add to Flyte service extraPorts: [] +# serviceMonitor Configure a Prometheus Operator ServiceMonitor for Flyte +# Requires the ServiceMonitor CRD and an `http-metrics` port on the http service (see `service.extraPorts`) +serviceMonitor: + # enabled Create a ServiceMonitor for Flyte + enabled: false + # interval Interval at which Prometheus scrapes metrics + interval: 60s + # scrapeTimeout Timeout for each scrape request + scrapeTimeout: 30s + # labels Add labels to the ServiceMonitor, e.g. those required by your Prometheus to discover it + labels: {} + # ingress Configure ingress for Flyte ingress: # create Create ingress resources diff --git a/docs/deployment/configuration/monitoring.rst b/docs/deployment/configuration/monitoring.rst index 1e9e26763e2..1e98786d52d 100644 --- a/docs/deployment/configuration/monitoring.rst +++ b/docs/deployment/configuration/monitoring.rst @@ -156,8 +156,11 @@ Once the prerequisites are in place, follow the instructions in this section to - name: http-metrics protocol: TCP port: 10254 + serviceMonitor: + enabled: true The above configuration enables the ``serviceMonitor`` that Prometheus can then use to automatically discover services and scrape metrics from them. + If your Prometheus only selects ``ServiceMonitor`` objects with specific labels, add them under ``serviceMonitor.labels``. .. note::