From 345b47c8680302ab23ee05bfd2d3ea182cc46afe Mon Sep 17 00:00:00 2001 From: Lachlan Evenson Date: Fri, 3 Feb 2017 11:23:41 -0800 Subject: [PATCH] [WIP] Add tensorflow inception model to incubator (#165) * initial commit * update chart home * add resource limits and readinessProbe --- incubator/tensorflow-inception/.helmignore | 21 +++++ incubator/tensorflow-inception/Chart.yaml | 10 ++ incubator/tensorflow-inception/README.md | 93 +++++++++++++++++++ .../tensorflow-inception/templates/NOTES.txt | 9 ++ .../templates/_helpers.tpl | 16 ++++ .../templates/tensorflow-inception.yaml | 64 +++++++++++++ incubator/tensorflow-inception/values.yaml | 20 ++++ 7 files changed, 233 insertions(+) create mode 100644 incubator/tensorflow-inception/.helmignore create mode 100755 incubator/tensorflow-inception/Chart.yaml create mode 100644 incubator/tensorflow-inception/README.md create mode 100644 incubator/tensorflow-inception/templates/NOTES.txt create mode 100644 incubator/tensorflow-inception/templates/_helpers.tpl create mode 100644 incubator/tensorflow-inception/templates/tensorflow-inception.yaml create mode 100644 incubator/tensorflow-inception/values.yaml diff --git a/incubator/tensorflow-inception/.helmignore b/incubator/tensorflow-inception/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/incubator/tensorflow-inception/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/incubator/tensorflow-inception/Chart.yaml b/incubator/tensorflow-inception/Chart.yaml new file mode 100755 index 0000000000..9c8016a893 --- /dev/null +++ b/incubator/tensorflow-inception/Chart.yaml @@ -0,0 +1,10 @@ +name: tensorflow-inception +home: https://github.com/kubernetes/charts +version: 0.1.0 +description: A Helm chart for Kubernetes +sources: + - https://github.com/tensorflow/ + - https://tensorflow.github.io/serving/serving_inception.html +maintainers: + - name: Lachlan Evenson + email: lachlan.evenson@gmail.com diff --git a/incubator/tensorflow-inception/README.md b/incubator/tensorflow-inception/README.md new file mode 100644 index 0000000000..19c7c548d5 --- /dev/null +++ b/incubator/tensorflow-inception/README.md @@ -0,0 +1,93 @@ +# Tensorflow Inception Model Chart + +TensorFlow is an open source software library for numerical computation using data flow graphs. + +* https://www.tensorflow.org/ + +My hope was to make TensorFlow more accessible by simplifying the following document -- https://tensorflow.github.io/serving/serving_inception.html + +## Chart Details +This chart will do the following: + +* 1 x TensorFlow inception model server on an external LoadBalancer + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```bash +$ helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator +$ helm install --name my-release incubator/tensorflow-inception +``` + +## Configuration + +The following tables lists the configurable parameters of the TensorFlow inception chart and their default values. + + +| Parameter | Description | Default | +| ----------------------- | ---------------------------------- | ---------------------------------------------------------- | +| `Image` | Container image name | `quay.io/lachie83/inception_serving` | +| `ImageTag` | Container image tag | `latest` | +| `Replicas` | k8s deployment replicas | `1` | +| `Component` | k8s selector key | `tensorflow-inception` | +| `Cpu` | container requested cpu | `100m` | +| `Memory` | container requested memory | `512Mi` | +| `ServicePort` | k8s service port | `9090` | +| `ContainerPort` | Container listening port | `9090` | + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. + +Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, + +```bash +$ helm install --name my-release -f values.yaml incubator/tensorflow-inception +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) + +## Example +```bash +docker run -v ~/Downloads:/downloads quay.io/lachie83/inception_serving /serving/bazel-bin/tensorflow_serving/example/inception_client --server=$INCEPTION_SERVICE_IP:9090 --image=/downloads/dog.jpg +D1028 17:07:30.650550118 7 ev_posix.c:101] Using polling engine: poll +outputs { + key: "classes" + value { + dtype: DT_STRING + tensor_shape { + dim { + size: 1 + } + dim { + size: 5 + } + } + string_val: "golden retriever" + string_val: "cocker spaniel, English cocker spaniel, cocker" + string_val: "clumber, clumber spaniel" + string_val: "tennis ball" + string_val: "Labrador retriever" + } +} +outputs { + key: "scores" + value { + dtype: DT_FLOAT + tensor_shape { + dim { + size: 1 + } + dim { + size: 5 + } + } + float_val: 9.7533788681 + float_val: 6.67022132874 + float_val: 6.18963956833 + float_val: 5.90754127502 + float_val: 5.4464302063 + } +} + +E1028 17:07:33.565394639 7 chttp2_transport.c:1810] close_transport: {"created":"@1477674453.565348591","description":"FD shutdown","file":"src/core/lib/iomgr/ev_poll_posix.c","file_line":427} +``` \ No newline at end of file diff --git a/incubator/tensorflow-inception/templates/NOTES.txt b/incubator/tensorflow-inception/templates/NOTES.txt new file mode 100644 index 0000000000..94e4817481 --- /dev/null +++ b/incubator/tensorflow-inception/templates/NOTES.txt @@ -0,0 +1,9 @@ +Getting Started: + +1. Use the inception-client in a container to submit an image from a mounted volume on your system to the service by running these commands in the same shell: +**** NOTE: It may take a few minutes for the LoadBalancer IP to be available. **** +**** You can watch the status of by running 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "fullname" . }}' **** + export INCEPTION_SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo docker run -v ~/Downloads:/downloads quay.io/lachie83/inception_serving /serving/bazel-bin/tensorflow_serving/example/inception_client --server=$INCEPTION_SERVICE_IP:9090 --image=/downloads/dog.jpg + + diff --git a/incubator/tensorflow-inception/templates/_helpers.tpl b/incubator/tensorflow-inception/templates/_helpers.tpl new file mode 100644 index 0000000000..92c9f20807 --- /dev/null +++ b/incubator/tensorflow-inception/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 24 -}} +{{- end -}} + +{{/* +Create a fully qualified name. +We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 24 -}} +{{- end -}} \ No newline at end of file diff --git a/incubator/tensorflow-inception/templates/tensorflow-inception.yaml b/incubator/tensorflow-inception/templates/tensorflow-inception.yaml new file mode 100644 index 0000000000..98b17165ad --- /dev/null +++ b/incubator/tensorflow-inception/templates/tensorflow-inception.yaml @@ -0,0 +1,64 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fullname" . }} + labels: + heritage: {{.Release.Service | quote }} + release: {{.Release.Name | quote }} + chart: "{{.Chart.Name}}-{{.Chart.Version}}" + component: "{{.Release.Name}}-{{.Values.Component}}" + annotations: + "helm.sh/created": {{.Release.Time.Seconds | quote }} +spec: + ports: + - port: {{.Values.ServicePort}} + targetPort: {{.Values.ContainerPort}} + selector: + component: "{{.Release.Name}}-{{.Values.Component}}" + type: {{.Values.ServiceType}} + +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "fullname" . }} + labels: + heritage: {{.Release.Service | quote }} + release: {{.Release.Name | quote }} + chart: "{{.Chart.Name}}-{{.Chart.Version}}" + component: "{{.Release.Name}}-{{.Values.Component}}" + annotations: + "helm.sh/created": {{.Release.Time.Seconds | quote }} +spec: + replicas: {{ default 1 .Values.Replicas }} + strategy: + type: RollingUpdate + selector: + matchLabels: + component: "{{.Release.Name}}-{{.Values.Component}}" + template: + metadata: + labels: + heritage: {{.Release.Service | quote }} + release: {{.Release.Name | quote }} + chart: "{{.Chart.Name}}-{{.Chart.Version}}" + component: "{{.Release.Name}}-{{.Values.Component}}" + spec: + containers: + - name: {{ template "fullname" . }} + image: "{{.Values.Image}}:{{.Values.ImageTag}}" + imagePullPolicy: "{{.Values.ImagePullPolicy}}" + command: + - "/bin/sh" + - "-c" + args: + - "/serving/bazel-bin/tensorflow_serving/model_servers/tensorflow_model_server --port={{.Values.ContainerPort}} --model_name=inception --model_base_path=/serving/inception-export" + ports: + - containerPort: {{.Values.ContainerPort}} + readinessProbe: + tcpSocket: + port: {{.Values.ContainerPort}} + initialDelaySeconds: 15 + timeoutSeconds: 1 + resources: +{{ toYaml .Values.Resources | indent 12 }} diff --git a/incubator/tensorflow-inception/values.yaml b/incubator/tensorflow-inception/values.yaml new file mode 100644 index 0000000000..54537c4b9c --- /dev/null +++ b/incubator/tensorflow-inception/values.yaml @@ -0,0 +1,20 @@ +# Default values for tensorflow-inception. +# This is a YAML-formatted file. +# Declare name/value pairs to be passed into your templates. +# name: value + +ServiceType: LoadBalancer +ServicePort: 9090 +ContainerPort: 9090 +Component: "tensorflow-inception" +Replicas: 1 +Image: "quay.io/lachie83/inception_serving" +ImageTag: "latest" +ImagePullPolicy: "IfNotPresent" +Resources: + limits: + cpu: 100m + memory: 256Mi + requests: + cpu: 100m + memory: 256Mi \ No newline at end of file