apiVersion: v1
kind: Service
metadata:
  name: mariadb
  namespace: mariadb
  labels:
    app: mariadb
spec:
  ports:
  - port: 3306
    name: mariadb-port
  clusterIP: None
  selector:
    app: mariadb
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mariadb-sts
  namespace: mariadb
spec:
  serviceName: "mariadb"
  replicas: 1
  selector:
    matchLabels:
      app: mariadb
  template:
    metadata:
      labels:
        app: mariadb
    spec:
      containers:
      - name: mariadb
        image: mariadb:10.11.4
        ports:
        - containerPort: 3306
          name: mariadb-port
        env:
        - name: MARIADB_ROOT_PASSWORD
          value: "jamesbrown"
        - name: innodb_force_recovery
          value: "1"
        volumeMounts:
        - name: datadir
          mountPath: /var/lib/mysql/
      volumes:
      - name: datadir
        persistentVolumeClaim:
          claimName: mariadb-pvc
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: mariadb-pv
  labels:
    type: local
spec:
  storageClassName: ""
  capacity:
    storage: 4Gi
  accessModes:
    - ReadWriteMany
  nfs:
    server: 192.168.2.110
    path: /mnt/nfs_share/mariadb/dev/
    readOnly: false
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mariadb-pvc
  namespace: mariadb
spec:
  storageClassName: ""
  volumeName: mariadb-pv
  accessModes:
    - ReadWriteMany
  volumeMode: Filesystem
  resources:
    requests:
      storage: 4Gi
