apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mm-pv-claim
  namespace: mattermost
  labels:
    app: mattermost
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ""
  resources:
    requests:
      storage: 15Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mattermost
  namespace: mattermost
  labels:
    app: mattermost
spec:
  selector:
    matchLabels:
      app: mattermost
      tier: frontend
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mattermost
        tier: frontend
    spec:
      containers:
      #- image: "mattermost/mattermost-team-edition:6.3.2"
      - image: "mattermost/mattermost-team-edition:7.9.1"
        name: mattermost
        env:
        - name: DB_TYPE
          value: mariadb
        - name: DB_HOST
          value: mattermost-mariadb
        - name: DB_PORT_NUMBER
          value: "3306"
        - name: MM_USERNAME
          valueFrom:
            secretKeyRef:
              name: mattermost.env
              key: USER
        - name: MM_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mattermost.env
              key: PASSWORD
        - name: MM_DBNAME
          valueFrom:
            secretKeyRef:
              name: mattermost.env
              key: DATABASE
        - name: MM_SQLSETTINGS_DATASOURCE
          value: "mattermost:Dsa-0213@tcp(mattermost-mariadb:3306)/mattermost?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s"
        - name: MM_SQLSETTINGS_DRIVERNAME
          value: "mysql"
        ports:
        - containerPort: 8065
          name: mattermost
        volumeMounts:
        - name: mattermost-persistent-storage
          mountPath: /mattermost/data
        - name: etclocaltime
          mountPath: /etc/localtime
          readOnly: true
      imagePullSecrets:
      - name: reg-cred-secret
      volumes:
      - name: mattermost-persistent-storage
        persistentVolumeClaim:
          claimName: mm-pv-claim
      - name: etclocaltime
        hostPath:
          path: /etc/localtime
