Implemented Juan's suggested changes

This commit is contained in:
tompizmor
2018-12-19 11:04:40 +01:00
parent 4165112763
commit 5c2221227d
5 changed files with 141 additions and 46 deletions
+28 -3
View File
@@ -10,7 +10,7 @@ $ helm install bitnami/tensorflow-resnet
## Introduction
This chart bootstraps a TensorFlow Serving ResNet pod on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
This chart bootstraps a TensorFlow Serving ResNet deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
Bitnami charts can be used with [Kubeapps](https://kubeapps.com/) for deployment and management of Helm Charts in clusters.
@@ -61,14 +61,14 @@ The command removes all the Kubernetes components associated with the chart and
The following tables lists the configurable parameters of the TensorFlow ResNet chart and their default values.
| Parameter | Description | Default |
| ------------------------------- | -------------------------------------------------| -------------------------------------------------------------|
| ------------------------------------------ | -----------------------------------------------------| -------------------------------------------------------------|
| `global.imageRegistry` | Global Docker image registry | `nil` |
| `replicaCount` | Desired number of pods | `1` |
| `server.image.registry` | TensorFlow Serving image registry | `docker.io` |
| `server.image.repository` | TensorFlow Serving Image name | `bitnami/tensorflow-serving` |
| `server.image.tag` | TensorFlow Serving Image tag | `{VERSION}` |
| `server.image.pullPolicy` | TensorFlow Serving image pull policy | `Always` if `imageTag` is `latest`, else `IfNotPresent` |
| `server.image.pullSecrets` | Specify image pull secrets | `nil` (does not add image pull secrets to deployed pods) |
| `replicaCount` | Desired number of pods | `1` |
| `server.port` | Tensorflow server port | `8500` |
| `client.image.registry` | TensorFlow ResNet image registry | `docker.io` |
| `client.image.repository` | TensorFlow ResNet Image name | `bitnami/tensorflow-resnet` |
@@ -77,12 +77,37 @@ The following tables lists the configurable parameters of the TensorFlow ResNet
| `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 | `{}` |
| `livenessProbe.enabled` | Would you like a livessProbed to be enabled | `true` |
| `livenessProbe.initialDelaySeconds` | Delay before liveness probe is initiated | 30 |
| `livenessProbe.periodSeconds` | How often to perform the probe | 5 |
| `livenessProbe.timeoutSeconds` | When the probe times out | 5 |
| `livenessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded | 6 |
| `livenessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed | 1 |
| `readinessProbe.enabled` | Would you like a readinessProbe to be enabled | `true` |
| `readinessProbe.initialDelaySeconds` | Delay before liveness probe is initiated | 15 |
| `readinessProbe.periodSeconds` | How often to perform the probe | 5 |
| `readinessProbe.timeoutSeconds` | When the probe times out | 5 |
| `readinessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded | 6 |
| `readinessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed | 1 |
| `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.port` | TensorFlow Exporter port | `9118` |
| `metrics.livenessProbe.enabled` | Would you like a livessProbed to be enabled (metrics) | `true` |
| `metrics.livenessProbe.initialDelaySeconds` | Delay before liveness probe is initiated (metrics) | 30 |
| `metrics.livenessProbe.periodSeconds` | How often to perform the probe (metrics) | 5 |
| `metrics.livenessProbe.timeoutSeconds` | When the probe times out (metrics) | 5 |
| `metrics.livenessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded (metrics) | 6 |
| `metrics.livenessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed (metrics) | 1 |
| `metrics.readinessProbe.enabled` | Would you like a readinessProbe to be enabled (metrics) | `true` |
| `metrics.readinessProbe.initialDelaySeconds` | Delay before liveness probe is initiated (metrics) | 15 |
| `metrics.readinessProbe.periodSeconds` | How often to perform the probe (metrics) | 5 |
| `metrics.readinessProbe.timeoutSeconds` | When the probe times out (metrics) | 5 |
| `metrics.readinessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded (metrics) | 6 |
| `metrics.readinessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed (metrics) | 1 |
| `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` |
@@ -1,3 +1,7 @@
*******************************************************************
*** Please be patient while the chart is being deployed. ***
*******************************************************************
1. Get the TensorFlow Serving URL by running:
{{- if contains "NodePort" .Values.serviceType }}
@@ -12,6 +16,13 @@
export APP_HOST=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
export APP_PORT=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath="{.spec.ports[0].port}")
{{- else if contains "ClusterIP" .Values.serviceType }}
export APP_HOST=127.0.0.1
export APP_PORT=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath="{.spec.ports[0].port}")
kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "tensorflow-resnet.fullname" . }} $APP_PORT:$APP_PORT &
{{- end }}
2. Test the server with a sample image.
@@ -3,20 +3,20 @@ kind: Deployment
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "fullname" . }}
app: {{ template "name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
selector:
matchLabels:
app: {{ template "fullname" . }}
app: {{ template "name" . }}
release: "{{ .Release.Name }}"
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels:
app: {{ template "fullname" . }}
app: {{ template "name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
{{- if or .Values.podAnnotations .Values.metrics.enabled }}
@@ -58,16 +58,29 @@ spec:
- name: serving
image: "{{ template "tensorflow-resnet.server.image" . }}"
imagePullPolicy: {{ .Values.server.image.pullPolicy | quote }}
readinessProbe:
tcpSocket:
port: {{ .Values.server.port }}
timeoutSeconds: 5
ports:
- name: tf-serving
containerPort: {{ .Values.server.port }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
tcpSocket:
port: {{ .Values.server.port }}
initialDelaySeconds: 30
timeoutSeconds: 5
failureThreshold: 6
port: tf-serving
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
tcpSocket:
port: tf-serving
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- end }}
env:
- name: TENSORFLOW_SERVING_MODEL_NAME
value: "resnet"
@@ -78,22 +91,32 @@ spec:
- 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', 'resnet']
command: ['python', 'tf_serving_exporter.py', '--tf_port', '{{ .Values.server.port }}', '--port', {{ .Values.metrics.port }}, '--model_name', 'resnet']
ports:
- name: metrics
containerPort: 9118
containerPort: {{ .Values.metrics.port }}
{{- if .Values.metrics.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: /metrics
port: metrics
initialDelaySeconds: 15
timeoutSeconds: 5
initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.metrics.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: /metrics
port: metrics
initialDelaySeconds: 5
timeoutSeconds: 1
initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
{{- end }}
resources:
{{ toYaml .Values.metrics.resources | indent 10 }}
{{- end }}
+2 -2
View File
@@ -3,7 +3,7 @@ kind: Service
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "fullname" . }}
app: {{ template "name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
@@ -13,4 +13,4 @@ spec:
- port: {{ .Values.server.port }}
protocol: TCP
selector:
app: {{ template "fullname" . }}
app: {{ template "name" . }}
+36
View File
@@ -63,6 +63,24 @@ serviceType: LoadBalancer
##
podAnnotations: {}
## Configure extra options for liveness and readiness probes
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes)
livenessProbe:
enabled: true
initialDelaySeconds: 30
periodSeconds: 5
timeoutSeconds: 5
failureThreshold: 6
successThreshold: 1
readinessProbe:
enabled: true
initialDelaySeconds: 15
periodSeconds: 5
timeoutSeconds: 5
failureThreshold: 6
successThreshold: 1
## Prometheus Exporter / Metrics
##
metrics:
@@ -78,6 +96,24 @@ metrics:
##
# pullSecrets:
# - myRegistrKeySecretName
port: 9118
## Configure extra options for liveness and readiness probes
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes)
livenessProbe:
enabled: true
initialDelaySeconds: 15
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 2
successThreshold: 1
readinessProbe:
enabled: true
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 6
successThreshold: 1
## Metrics exporter pod Annotation and Labels
podAnnotations:
prometheus.io/scrape: "true"