apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: firefly-iii-data-pvc
  namespace: firefly
  labels:
    app: firefly-iii
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ""
  resources:
    requests:
      storage: 20Gi
---
apiVersion: v1
kind: Service
metadata:
  name: firefly-iii-mysql
  namespace: firefly
  labels:
    app: firefly-iii
spec:
  type: NodePort
  ports:
    - name: mysql
      port: 3306
      nodePort: 30181
      targetPort: mysql
  selector:
    app: firefly-iii
    tier: mysql
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: firefly-iii-mysql
  namespace: firefly
  labels:
    app: firefly-iii
spec:
  selector:
    matchLabels:
      app: firefly-iii
      tier: mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: firefly-iii
        tier: mysql
    spec:
      containers:
      - image: docker-registry:32000/mariadb:1.0
        name: mysql
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: firefly-iii-secrets
              key: db_password
        ports:
        - containerPort: 3306
          name: mysql
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
      imagePullSecrets:
      - name: reg-cred-secret    
      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: firefly-iii-data-pvc
