apiVersion: apps/v1
kind: Deployment
metadata:
  name: mariadb-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      component: mariadb
  template:
    metadata:
      labels:
        component: mariadb
    spec:
      volumes:
        - name: mariadb-storage
          persistentVolumeClaim:
            claimName: database-persistent-volume-claim
      containers:
        - name: mariadb
          image: mariadb:10.2
          ports:
            - containerPort: 3306
          volumeMounts:
            - name: mariadb-storage
              mountPath: /var/lib/mariadb/data
              subPath: mariadb
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: changeme
            - name: MYSQL_DATABASE
              value: books
            - name: MYSQL_USER
              value: book
            - name: MYSQL_PASSWORD
              value: changeme