# helm_charts_tensorflow-inception.yaml
apiVersion: v1
kind: Service
metadata:
  name: {{ template "tensorflow-inception.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: apps/v1
kind: Deployment
metadata:
  name: {{ template "tensorflow-inception.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 "tensorflow-inception.fullname" . }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: "{{ .Values.image.pullPolicy }}"
          command:
          - "/bin/sh"
          - "-c"
          args:
          - "tensorflow_model_server --port={{ .Values.containerPort }} --model_name=inception --model_base_path=/serving/inception-export"
{{- if .Values.env.ldLibraryPath  }}
          env:
          - name: LD_LIBRARY_PATH
            value: {{ .Values.env.ldLibraryPath }}
{{ end }}
          ports:
            - containerPort: {{ .Values.containerPort }}
          readinessProbe:
            tcpSocket:
              port: {{ .Values.containerPort }}
            initialDelaySeconds: 15
            timeoutSeconds: 1
          resources:
{{ toYaml .Values.resources | indent 12 }}