# Copyright 2017 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
apiVersion: v1
kind: Service
metadata:
  name: tf-notebook
  labels:
    app: tf-notebook
spec:
  type: LoadBalancer
  ports:
  - port: 80
    name: http
    targetPort: 8888
  selector:
    app: tf-notebook
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: tf-notebook
spec:
  serviceName: "tf-notebook"
  replicas: 1
  template:
    metadata:
      labels:
        app: tf-notebook
    spec:
      tolerations:
      - key: nvidia.com/gpu
        effect: NoSchedule
      securityContext:
        fsGroup: 0
      containers:
      - name: tf-notebook
        image: gcr.io/kubeflow/tensorflow-notebook-cpu:v1
        resources:
#          limits:
 #           nvidia.com/gpu: 1 # Number of GPUs
          requests:
            cpu: 1
            memory: 1Gi
        ports:
        - containerPort: 8888
          name: notebook
        volumeMounts:
        - name: stateful
          mountPath: /home/jovyan/stateful
  volumeClaimTemplates:
  - metadata:
      name: stateful
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 1Gi
