From ec4d9a2de8a24e4601e40caec0c59ed134832bfa Mon Sep 17 00:00:00 2001 From: "Javier J. Salmeron Garcia" Date: Wed, 31 Oct 2018 13:17:20 +0100 Subject: [PATCH] [bitnami/tensorflow-inception] Add prometheus exporter --- bitnami/tensorflow-inception/Chart.yaml | 2 +- bitnami/tensorflow-inception/README.md | 9 +++++ .../templates/_helpers.tpl | 10 ++++++ .../templates/deployment.yaml | 34 ++++++++++++++++++- bitnami/tensorflow-inception/values.yaml | 29 ++++++++++++++++ 5 files changed, 82 insertions(+), 2 deletions(-) diff --git a/bitnami/tensorflow-inception/Chart.yaml b/bitnami/tensorflow-inception/Chart.yaml index e24a0fb06..171d5e0b4 100755 --- a/bitnami/tensorflow-inception/Chart.yaml +++ b/bitnami/tensorflow-inception/Chart.yaml @@ -1,5 +1,5 @@ name: tensorflow-inception -version: 3.0.1 +version: 3.1.0 appVersion: 1.11.1 description: Open-source software library for serving machine learning models keywords: diff --git a/bitnami/tensorflow-inception/README.md b/bitnami/tensorflow-inception/README.md index 3c539a656..09e194606 100755 --- a/bitnami/tensorflow-inception/README.md +++ b/bitnami/tensorflow-inception/README.md @@ -76,6 +76,15 @@ The following tables lists the configurable parameters of the TensorFlow Incepti | `client.image.pullPolicy` | TensorFlow Inception image pull policy | `Always` if `imageTag` is `latest`, else `IfNotPresent` | | `client.image.pullSecrets` | Specify image pull secrets | `nil` (does not add image pull secrets to deployed pods) | | `imagePullPolicy` | Image pull policy | `Always` if `image` tag is `latest`, else `IfNotPresent` | +| `podAnnotations` | Pod annotations | `{}` | +| `metrics.enabled` | Start a side-car Tensorflow prometheus exporter | `false` | +| `metrics.image.registry` | Tensorflow exporter image registry | `docker.io` | +| `metrics.image.repository` | Tensorflow exporter image name | `ynqa/tensorflow-serving-exporter` | +| `metrics.image.tag` | Tensorflow exporter image tag | `latest` | +| `metrics.image.pullPolicy` | Image pull policy | `IfNotPresent` | +| `metrics.image.pullSecrets` | Specify docker-registry secret names as an array | `nil` | +| `metrics.podAnnotations` | Additional annotations for Metrics exporter pod | `{prometheus.io/scrape: "true", prometheus.io/port: "9118"}` | +| `metrics.resources` | Exporter resource requests/limit | Memory: `256Mi`, CPU: `100m` | Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, diff --git a/bitnami/tensorflow-inception/templates/_helpers.tpl b/bitnami/tensorflow-inception/templates/_helpers.tpl index 7985f440c..eea84fd0b 100644 --- a/bitnami/tensorflow-inception/templates/_helpers.tpl +++ b/bitnami/tensorflow-inception/templates/_helpers.tpl @@ -60,3 +60,13 @@ Also, we can't use a single if because lazy evaluation is not an option {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} {{- end -}} {{- end -}} + +{{/* +Return the proper image name (for the metrics image) +*/}} +{{- define "metrics.image" -}} +{{- $registryName := .Values.metrics.image.registry -}} +{{- $repositoryName := .Values.metrics.image.repository -}} +{{- $tag := .Values.metrics.image.tag | toString -}} +{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} +{{- end -}} diff --git a/bitnami/tensorflow-inception/templates/deployment.yaml b/bitnami/tensorflow-inception/templates/deployment.yaml index 289d133d6..5c827c9fd 100644 --- a/bitnami/tensorflow-inception/templates/deployment.yaml +++ b/bitnami/tensorflow-inception/templates/deployment.yaml @@ -19,6 +19,15 @@ spec: app: {{ template "fullname" . }} chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" release: "{{ .Release.Name }}" +{{- if or .Values.podAnnotations .Values.metrics.enabled }} + annotations: + {{- if .Values.podAnnotations }} +{{ toYaml .Values.podAnnotations | indent 8 }} + {{- end }} + {{- if .Values.metrics.podAnnotations }} +{{ toYaml .Values.metrics.podAnnotations | indent 8 }} + {{- end }} +{{- end }} spec: {{- if .Values.server.image.pullSecrets }} imagePullSecrets: @@ -48,7 +57,7 @@ spec: - name: seed mountPath: /seed containers: - - name: {{ template "fullname" . }} + - name: serving image: "{{ template "tensorflow-inception.server.image" . }}" imagePullPolicy: {{ .Values.server.image.pullPolicy | quote }} readinessProbe: @@ -64,6 +73,29 @@ spec: volumeMounts: - name: seed mountPath: "/bitnami/model-data" +{{- if .Values.metrics.enabled }} + - name: metrics + image: {{ template "metrics.image" . }} + imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }} + command: ['python', 'tf_serving_exporter.py', '--tf_port', '{{ .Values.server.port }}', '--port', '9118', '--model_name', 'inception-v3'] + ports: + - name: metrics + containerPort: 9118 + livenessProbe: + httpGet: + path: /metrics + port: metrics + initialDelaySeconds: 15 + timeoutSeconds: 5 + readinessProbe: + httpGet: + path: /metrics + port: metrics + initialDelaySeconds: 5 + timeoutSeconds: 1 + resources: + {{ toYaml .Values.metrics.resources | indent 10 }} +{{- end }} volumes: - name: seed emptyDir: {} diff --git a/bitnami/tensorflow-inception/values.yaml b/bitnami/tensorflow-inception/values.yaml index bda283242..ae374eb93 100755 --- a/bitnami/tensorflow-inception/values.yaml +++ b/bitnami/tensorflow-inception/values.yaml @@ -57,3 +57,32 @@ imagePullPolicy: IfNotPresent ## For minikube, set this to NodePort, elsewhere use LoadBalancer ## serviceType: LoadBalancer + +## Pod annotations +## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +## +podAnnotations: {} + +## Prometheus Exporter / Metrics +## +metrics: + enabled: false + image: + registry: docker.io + repository: ynqa/tensorflow-serving-exporter + tag: latest + pullPolicy: IfNotPresent + ## Optionally specify an array of imagePullSecrets. + ## Secrets must be manually created in the namespace. + ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ + ## + # pullSecrets: + # - myRegistrKeySecretName + ## Metrics exporter pod Annotation and Labels + podAnnotations: + prometheus.io/scrape: "true" + prometheus.io/port: "9118" + ## Metrics exporter resource requests and limits + ## ref: http://kubernetes.io/docs/user-guide/compute-resources/ + ## + # resources: {}