apiVersion: apps/v1
kind: Deployment
metadata:
  name: jl-rasa # {"$kpt-set":"name"}
  namespace: label-bot-dev # {"$kpt-set":"namespace"}
spec:
  replicas: 1
  selector:
    matchLabels:
      statefulset: jl-rasa # {"$kpt-set":"name"}
  template:
    metadata:
      annotations:
        # Do we need the istio side car for virtual service reverse proxy
        sidecar.istio.io/inject: "false"
      labels:
        app: jl-rasa # {"$kpt-set":"name"}
        code-server: jl-rasa # {"$kpt-set":"name"}
        statefulset: jl-rasa # {"$kpt-set":"name"}
    spec:
      #securityContext:
      # 1000 = jovyan
      #  runAsUser: 1000
      #  runAsGroup: 100
      # Mount the PVC as a group that the user belongs to.
      #  fsGroup: 100
      containers:
      # - name: echo
      #   image: gcr.io/kubeflow-images-staging/echo-server:latest        
      - env:
        - name: NB_USER
          value: jovyan
        - name: TRANSFORMERS_CACHE # TODO(jlewi): I got an error: 
          value: /home/jovyan/.cache
        - name: HOME # Set the home directory explicitly to ensure it matches the PVC. Otherwise our home
          value: /home/jovyan
        #image: tensorflow/tensorflow:2.3.1-jupyter
        image: gcr.io/issue-label-bot-dev/jl-rasa:83da840-dirty@sha256:24df139fcd6b218039ff0a861666736942942bc9debc7190483de16de83722b9 # {"$kpt-set":"image"}
        name: vscode
        # Explicitly set the command so we can use off the shelf notebook images.
        command:
        - code-server
        - --auth=none
        #- --bind-addr=jlewicodeserver-0:8080
        - --bind-addr=0.0.0.0:8080
        # TODO(jlewi): How do we want to set this
        - --user-data-dir=/home/jovyan/data
        - --verbose
        # command:
        #  - tail
        #  - -f
        #  - /dev/null
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8080
        readinessProbe:
          httpGet:
            path: /healthz
            port: 8080
        resources:
          limits:
            nvidia.com/gpu: 0 # {"$kpt-set":"numGpus"}
            cpu: "16"
            memory: 32Gi
          requests:
            cpu: "4"
            memory: 4Gi
        volumeMounts:
        - mountPath: /home/jovyan
          name: workspace
        - mountPath: /dev/shm
          name: dshm
        - mountPath: /secret/ssh-key
          name: ssh
          readOnly: true
      serviceAccountName: default-editor # {"$kpt-set":"serviceAccount"}
      volumes:
      - name: workspace
        persistentVolumeClaim:
          claimName: workspace-jl-rasa # {"$kpt-set":"pvc-name"}
      - name: ssh
        secret:
          secretName: git-creds # {"$kpt-set":"gitSecret"}
          # See https://www.jannikarndt.de/blog/2018/03/ssh_key_as_kubernetes_secret/
          defaultMode: 256
      - emptyDir:
          medium: Memory
        name: dshm
