apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: ospos
    instance: pos.lib.unb.ca
    tier: pos
    uri: dev-pos.lib.unb.ca
  name: pos-lib-unb-ca
  namespace: dev
spec:
  selector:
    matchLabels:
      uri: dev-pos.lib.unb.ca
  replicas: 1
  revisionHistoryLimit: 2
  minReadySeconds: 30
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  template:
    metadata:
      labels:
        app: ospos
        instance: pos.lib.unb.ca
        tier: pos
        uri: dev-pos.lib.unb.ca
    spec:
      nodeSelector:
        deployenv: dev
      containers:
        -
          env:
            -
              name: DEPLOY_ENV
              value: dev
            -
              name: MYSQL_HOSTNAME
              value: ospos-mysql-lib-unb-ca
            -
              name: MYSQL_PORT
              value: "3306"
            -
              name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mysql
                  key: root-password
            -
              name: MYSQL_DATABASE
              valueFrom:
                secretKeyRef:
                  name: ospos
                  key: db
            -
              name: MYSQL_DATABASE_HIL
              valueFrom:
                secretKeyRef:
                  name: ospos
                  key: hil-db
            -
              name: MYSQL_DATABASE_HWKC
              valueFrom:
                secretKeyRef:
                  name: ospos
                  key: hwkc-db
            -
              name: MYSQL_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: ospos
                  key: pass
            -
              name: MYSQL_USERNAME
              valueFrom:
                secretKeyRef:
                  name: ospos
                  key: user
            -
              name: NR_INSTALL_KEY
              valueFrom:
                secretKeyRef:
                  name: newrelic
                  key: install-key
          image: "||DEPLOYMENTIMAGE||"
          imagePullPolicy: Always
          name: pos-lib-unb-ca
          ports:
            -
              containerPort: 80
          volumeMounts:
            -
              mountPath: /app/html/public/uploads
              name: ospos-persistent-storage
            -
              mountPath: /app/hil/public/uploads
              name: hil-ospos-persistent-storage
            -
              mountPath: /app/hwkc/public/uploads
              name: hwkc-ospos-persistent-storage
            -
              name: ospos-spreadsheet
              mountPath: "/reporting/pos-template.xlsx"
              subPath: "pos-template.xlsx"
              readOnly: true
            -
              name: ospos-spreadsheet-hwkc
              mountPath: "/reporting/pos-template-hwkc.xlsx"
              subPath: "pos-template-hwkc.xlsx"
              readOnly: true
      priorityClassName: dev-high-priority-services
      imagePullSecrets:
        -
          name: github-container-registry-auth
      restartPolicy: Always
      volumes:
        -
          name: ospos-persistent-storage
          persistentVolumeClaim:
            claimName: pos-lib-unb-ca
        -
          name: hil-ospos-persistent-storage
          persistentVolumeClaim:
            claimName: hil-pos-lib-unb-ca
        -
          name: hwkc-ospos-persistent-storage
          persistentVolumeClaim:
            claimName: hwkc-pos-lib-unb-ca
        - name: ospos-spreadsheet
          secret:
            secretName: pos-xls
            items:
              - key: pos-template.xlsx
                path: pos-template.xlsx
        - name: ospos-spreadsheet-hwkc
          secret:
            secretName: pos-xls-hwkc
            items:
              - key: pos-template-hwkc.xlsx
                path: pos-template-hwkc.xlsx
