From 165bcd134a36f8d43596dd685a80887f2c9d67e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20de=20Saint=20Martin?= Date: Wed, 22 Jan 2025 13:43:59 +0100 Subject: [PATCH] feat(pythie): add metrics support. (#638) --- charts/pythie/Chart.yaml | 3 +-- charts/pythie/ci/default-values.yaml | 0 charts/pythie/ci/metrics-values.yaml | 4 ++++ charts/pythie/templates/podmonitor.yaml | 21 +++++++++++++++++++ .../templates/pythie-serving-deployment.yaml | 3 ++- charts/pythie/values.yaml | 11 ++++++++++ 6 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 charts/pythie/ci/default-values.yaml create mode 100644 charts/pythie/ci/metrics-values.yaml create mode 100644 charts/pythie/templates/podmonitor.yaml diff --git a/charts/pythie/Chart.yaml b/charts/pythie/Chart.yaml index 10d2d0dd..7c2849f6 100644 --- a/charts/pythie/Chart.yaml +++ b/charts/pythie/Chart.yaml @@ -1,7 +1,6 @@ apiVersion: v2 name: pythie -version: 0.7.2 -appVersion: "1.0" +version: 0.8.0 description: Serve machine learning models with tensorflow and pythie keywords: - pythie diff --git a/charts/pythie/ci/default-values.yaml b/charts/pythie/ci/default-values.yaml new file mode 100644 index 00000000..e69de29b diff --git a/charts/pythie/ci/metrics-values.yaml b/charts/pythie/ci/metrics-values.yaml new file mode 100644 index 00000000..cab64809 --- /dev/null +++ b/charts/pythie/ci/metrics-values.yaml @@ -0,0 +1,4 @@ +pythieServing: + metrics: + podMonitor: + enabled: true diff --git a/charts/pythie/templates/podmonitor.yaml b/charts/pythie/templates/podmonitor.yaml new file mode 100644 index 00000000..f8b127d9 --- /dev/null +++ b/charts/pythie/templates/podmonitor.yaml @@ -0,0 +1,21 @@ +{{- if .Values.pythieServing.metrics.podMonitor.enabled }} + +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: {{ include "pythie.fullname" . }} + labels: + {{- include "pythie.labels" . | nindent 4 }} +spec: + podMetricsEndpoints: + - interval: {{ .Values.pythieServing.metrics.podMonitor.interval }} + port: {{ .Values.pythieServing.metrics.podMonitor.port }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + {{- include "pythie.matchLabels" . | nindent 6 }} + serving-kind: pythie + +{{- end }} diff --git a/charts/pythie/templates/pythie-serving-deployment.yaml b/charts/pythie/templates/pythie-serving-deployment.yaml index 451243fc..0a2e5620 100644 --- a/charts/pythie/templates/pythie-serving-deployment.yaml +++ b/charts/pythie/templates/pythie-serving-deployment.yaml @@ -23,6 +23,7 @@ spec: labels: {{ include "pythie.labels" $ | indent 8 }} {{ include "pythie.modelLabels" $servingValue | indent 8 }} + serving-kind: pythie serving/hash: {{ $servingHash }} annotations: cluster-autoscaler.kubernetes.io/safe-to-evict: "true" @@ -43,7 +44,7 @@ spec: priorityClassName: {{ $.Values.priorityClassName }} {{- end }} {{- if $.Values.pythieServing.pullSecret }} - imagePullSecrets: + imagePullSecrets: - name: {{ $.Values.pythieServing.pullSecret }} {{- end }} initContainers: diff --git a/charts/pythie/values.yaml b/charts/pythie/values.yaml index 7ca82bc2..1cd9974e 100644 --- a/charts/pythie/values.yaml +++ b/charts/pythie/values.yaml @@ -3,7 +3,18 @@ pythieServing: repository: "ghcr.io/wiremind/pythie-serving" tag: "v3.4.2" pullPolicy: IfNotPresent + ## Add custom ports to expose customPorts: [] + # - name: metrics + # containerPort: 9191 + # protocol: TCP + ## Enable optional metrics scraping through prometheus operator + ## Note that you'll need to expose a new port in your code and in pythieServing.customPorts + metrics: + podMonitor: + enabled: false + port: metrics + interval: 30s ## Specify image pull secret # pullSecret: my-secret istio: