kind: Pod
apiVersion: v1
metadata:
  name: xcache-pod
  labels:
    app: xcache
spec:

  nodeSelector:
    xcache-capable: "true"

  volumes:
  - name: x509-data
    emptyDir: {}
  - name: x509-certs-volume
    secret:
      secretName: xcache-cert-secret
      items:
      - key: userkey
        path: userkey.pem
        mode: 256 
      - key: usercert
        path: usercert.pem
  - name: xcache-data-1
    hostPath:
      path: /scratch_1
  - name: xcache-data-2
    hostPath:
      path: /scratch_2
  - name: xcache-meta
    hostPath:
      path: /scratch

  containers:
  - name: xcache
    image: slateci/xcache:latest
    env:
    - name: XC_SPACE_HIGH_WM
      value: "0.95"
    - name: XC_SPACE_LOW_WM
      value: "0.90"
    - name: XC_PORT
      value: "1094"
    - name: XC_RAMSIZE
      value: "16g"
    - name: XC_BLOCKSIZE
      value: "1M"
    - name: XC_PREFETCH
      value: "0"
    - name: AGIS_PROTOCOL_ID
      value: "433"
    volumeMounts:
    - name: x509-data
      mountPath: "/etc/proxy/"
      readOnly: false
    - name: x509-certs-volume
      mountPath: "/etc/grid-certs/"
      readOnly: true
    - name: xcache-data-1
      mountPath: "/xcache-data_1"
    - name: xcache-data-2
      mountPath: "/xcache-data_2"
    - name: xcache-meta
      mountPath: "/xcache-meta"
    livenessProbe:
      tcpSocket:
        port: 1094
      initialDelaySeconds: 180
      periodSeconds: 60
    lifecycle:
      preStop:
        exec:
          command: ["./updateAGISstatus.sh","433","DISABLED"]
    ports:
      - containerPort: 1094

  - name: x509
    image: slateci/xcache:latest
    command: ["/run_x509_updater.sh"]
    volumeMounts:
    - name: x509-data
      mountPath: "/etc/proxy/"
      readOnly: false
    - name: x509-certs-volume
      mountPath: "/etc/grid-certs/"
      readOnly: true

  - name: reporter
    image: slateci/xcache:latest
    command: ["/run_cache_reporter.sh"]
    env:
    - name: XC_SITE
      value: "MWT2"
    - name: XC_REPORT_COLLECTOR
      value: "http://uct2-collectd.mwt2.org:8080"
    volumeMounts:
    - name: xcache-meta
      mountPath: "/xcache-meta"
      readOnly: true
      
  restartPolicy: Never