apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    k8s-app: stashcache
  name: stashcache-ny
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: stashcache
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        k8s-app: stashcache
    spec:
      tolerations:
      - effect: NoSchedule
        key: nautilus.io/stashcache
        operator: Exists
      containers:
      - env:
        - name: XC_ROOTDIR
          value: /xcache/namespace
        - name: SITENAME
          value: NY-Kubernetes-PRP
        - name: REDIRECTOR
          value: osg.newy32aoa.nrp.internet2.edu:9004
        - name: XRDHTTPPORT
          value: "8000"
        - name: CACHE_FQDN
          value: "osg.newy32aoa.nrp.internet2.edu"
        - name: XC_SPACE_LOW_WM
          value: '0.88'
        - name: XC_SPACE_HIGH_WM
          value: '0.9'
        image: opensciencegrid/stash-cache:stable
        imagePullPolicy: Always
        name: stashcache
        ports:
         - containerPort: 1094
           hostPort: 1094
         - containerPort: 8000
           hostPort: 8000
         - containerPort: 8443
           hostPort: 8444
        resources:
          limits:
            cpu: 8
            memory: 38Gi
          requests:
            cpu: 6
            memory: 28Gi
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /etc/grid-security/hostcert.pem
          name: certificate
          readOnly: true
          subPath: hostcert.pem
        - mountPath: /etc/grid-security/hostkey.pem
          name: hostkey
          readOnly: true
          subPath: hostkey.pem
        - mountPath: /xcache
          name: datavol
#      initContainers:
#      - command: ["sh", "-c", "chown -R 10940:10940 /data/stash/stashcache"]
#        image: busybox
#        imagePullPolicy: Always
#        name: chowndata
#        volumeMounts:
#        - mountPath: /data/stash
#          name: datavol
#        resources:
#          limits:
#            cpu: 3
#            memory: 25Gi
#          requests:
#            cpu: 2
#            memory: 20Gi
      nodeSelector:
        kubernetes.io/hostname: osg.newy32aoa.nrp.internet2.edu
      restartPolicy: Always
      schedulerName: default-scheduler
      terminationGracePeriodSeconds: 30
      volumes:
      - name: certificate
        secret:
          secretName: newyork-certs
          items:
          - key: hostcert
            path: hostcert.pem
          defaultMode: 0600
      - name: hostkey
        secret:
          secretName: newyork-certs
          items:
          - key: hostkey
            path: hostkey.pem
          defaultMode: 0600
      - name: datavol
        persistentVolumeClaim:
          claimName: pvc-osg.newy32aoa.nrp.internet2.edu-1
