apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    k8s-app: stashcache
  name: stashcache-sunnyvale
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
        - name: XC_RESOURCENAME
          value: Sunnyvale-I2-PRP
        - name: XRDHTTPPORT
          value: "8000"
        - name: CACHE_FQDN
          value: "osg-houston-stashcache.nrp.internet2.edu"
        - name: XRDDEBUG
          value: "True"
        image: opensciencegrid/stash-cache:stable
        ports:
         - containerPort: 1094
           hostPort: 1094
         - containerPort: 8000
           hostPort: 8000
         - containerPort: 8443
           hostPort: 8444
        imagePullPolicy: Always
        name: stashcache
        resources:
          limits:
            memory: 20Gi
            cpu: 4
          requests:
            memory: 10Gi
            cpu: 3
        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: data1
        - mountPath: /xcache/data1
          name: data1
        - mountPath: /xcache/data2
          name: data2
      dnsPolicy: ClusterFirst
      initContainers:
      - command: ["sh", "-c", "chown -R 10940:10940 /xcache"]
        image: busybox
        imagePullPolicy: Always
        name: chowndata
        volumeMounts:
        - mountPath: /xcache
          name: data1
        - mountPath: /xcache/data1
          name: data1
        - mountPath: /xcache/data2
          name: data2
        resources:
          limits:
            cpu: 3
            memory: 25Gi
          requests:
            cpu: 2
            memory: 20Gi
      nodeSelector:
        kubernetes.io/hostname: osg-sunnyvale-stashcache.nrp.internet2.edu
      restartPolicy: Always
      schedulerName: default-scheduler
      terminationGracePeriodSeconds: 30
      volumes:
      - name: certificate
        secret:
          secretName: sunnyvale-certs
          items:
          - key: hostcert
            path: hostcert.pem
          defaultMode: 0600 
      - name: hostkey
        secret:
          secretName: sunnyvale-certs
          items:
          - key: hostkey
            path: hostkey.pem
          defaultMode: 0600
      - name: data1
        persistentVolumeClaim:
          claimName: pvc-osg-sunnyvale-stashcache.nrp.internet2.edu-1
      - name: data2
        persistentVolumeClaim:
          claimName: pvc-osg-sunnyvale-stashcache.nrp.internet2.edu-2


