apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: {{ template "tensorflow-notebook.fullname" . }}
  labels:
    app: {{ template "tensorflow-notebook.name" . }}
    chart: {{ template "tensorflow-notebook.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  selector:
    matchLabels:
      app: {{ template "tensorflow-notebook.name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ template "tensorflow-notebook.name" . }}
        release: {{ .Release.Name }}
    spec:
      containers:
        - name: jupyter
          image: "{{ .Values.jupyter.image.repository }}:{{ .Values.jupyter.image.tag }}"
          imagePullPolicy: {{ .Values.jupyter.image.pullPolicy }}
          ports:
            - containerPort: 8888
              name: jupyter
          command:
            - jupyter
          args:
            - notebook
            - --allow-root      
          env:
            - name: PASSWORD
              valueFrom:
                secretKeyRef:
                  name: {{ template "tensorflow-notebook.fullname" . }}
                  key: password
          livenessProbe:
            httpGet:
              path: /
              port: 8888
          readinessProbe:
            httpGet:
              path: /
              port: 8888
          volumeMounts:
            - mountPath: /output/training_logs
              name: training-logs-volume
        - name: tensorboard
          image: "{{ .Values.tensorboard.image.repository }}:{{ .Values.tensorboard.image.tag }}"
          imagePullPolicy: {{ .Values.tensorboard.image.pullPolicy }}
          ports:
            - containerPort: 6006
              name: tensorboard
          command:
            - tensorboard
          args:
            - --logdir
            - /output/training_logs
            - --host
            - 0.0.0.0
          livenessProbe:
            httpGet:
              path: /
              port: 6006
          readinessProbe:
            httpGet:
              path: /
              port: 6006
          volumeMounts:
            - mountPath: /output/training_logs
              name: training-logs-volume
      volumes:
        - name: training-logs-volume
          emptyDir: {}