# Copyright 2019 Google LLC
#
# 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: apps/v1
kind: StatefulSet
metadata:
  name: jupyter
spec:
  selector:
    matchLabels:
      app: jupyter
  replicas: 1
  serviceName: jupyter
  updateStrategy:
    type: RollingUpdate
  volumeClaimTemplates: []
  template:
    metadata:
      labels:
        app: jupyter
    spec:
      serviceAccountName: default
      containers:
        - name: jupyter
          image: gcr.io/kubeflow/jupyterhub:1.0
          ports:
            - containerPort: 8888
          command: ["/bin/bash"]
          args:
            - "-exc"
            - |
              groupadd jupyter --gid 1000
              useradd jupyter --uid 1000 --gid 1000 --shell /bin/bash
              [[ ! -d /home/jupyter ]] && mkdir -p /home/jupyter && chown jupyter:jupyter /home/jupyter
              cd /home/jupyter
              su -c "/usr/local/bin/jupyter-notebook --ip=0.0.0.0 --port 8888 --NotebookApp.token='' --NotebookApp.password='' --NotebookApp.base_url='/jupyter-notebook/' --no-browser" jupyter
