apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    k8s-app: cms-xcache
  name: cms-xcache-esnet-xcache-01
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: cms-xcache
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        k8s-app: cms-xcache
    spec:
      hostname: esnet-xcache-01
      tolerations:
      - effect: NoSchedule
        key: nautilus.io/stashcache
        operator: Exists
      initContainers:
      - command: ["sh", "-c", "chown -R 10940:10940 /xcache/* "]
        image: busybox
        imagePullPolicy: Always
        name: chowndata
        volumeMounts:
        - mountPath: /xcache
          name: localroot
        - mountPath: /var/log/xrootd
          name: cachelogs
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - esnet-xcache-01.t2.ucsd.edu
      containers:
      - env:
        - name: XC_NUM_LOGROTATE
          value: '15'
        - name: XC_RESOURCENAME
          value: UCSD-XCACHE-ESNET
        - name: XC_RESOURCENAME
          value: UCSD-XCACHE-ESNET
        - name: XC_RAMSIZE
          value: 15g
        - name: XC_SPACE_LOW_WM
          value: '0.95'
        - name: XC_SPACE_HIGH_WM
          value: '0.97'
        - name: XC_FULL_DEBUG
          value: 'true'
        - name: XC_ROOTDIR
          value: /xcache/namespace
        - name: XC_LOCAL_REDIRECTORS
          value: xcache-redirector-real.t2.ucsd.edu:2041,xcache-real.ultralight.org:2041
        image: opensciencegrid/cms-xcache:fresh
        ports:
         - containerPort: 1094
           hostPort: 1094
         - containerPort: 1095
           hostPort: 1095
        imagePullPolicy: Always
        name: cms-xcache-esnet-xcache-01
        resources:
           limits:
              memory: 30Gi
              cpu: 4
           requests:
              memory: 20Gi
              cpu: 4
        volumeMounts:
        - mountPath: /etc/xrootd/config.d/95-local-ucsd.cfg
          name: config95
          subPath: 95-local-ucsd.cfg
        - 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: localroot
        - mountPath: /var/log/xrootd
          name: cachelogs
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      terminationGracePeriodSeconds: 30
      volumes:
      - configMap:
          defaultMode: 420
          items:
          - key: 95-local-ucsd.cfg
            path: 95-local-ucsd.cfg
          name: cms-xcache-bcache-1-ucsd
        name: config95
      - name: certificate
        secret:
          secretName: esnet-certs
          items:
          - key: hostcert
            path: hostcert.pem
          defaultMode: 0600
      - name: hostkey
        secret:
          secretName: esnet-certs
          items:
          - key: hostkey
            path: hostkey.pem
          defaultMode: 0600
      - name: localroot
        persistentVolumeClaim:
          claimName: pvc-esnet-xcache-01-t2-ucsd-edu-persistent-1
      - name: cachelogs
        persistentVolumeClaim:
          claimName: pvc-esnet-xcache-01-t2-ucsd-edu-persistent-2
