apiVersion: apps/v1
kind: Deployment
metadata:
  name: drupal-mysql
  labels:
    app: drupal-mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: drupal-mysql
  template:
    metadata:
      labels:
        app: drupal-mysql
    spec:
      volumes:
        - name: mysql-pvc
          persistentVolumeClaim:
            claimName: drupal-mysql-pvc
      containers:
        - name: drupal-mysql
          image: mysql:5.7
          ports:
            - containerPort: 5321
          env:
            - name: MYSQL_DATABASE
              valueFrom:
                secretKeyRef:
                  name: drupal-mysql-secret
                  key: MYSQL_DATABASE
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: drupal-mysql-secret
                  key: MYSQL_ROOT_PASSWORD
            - name: MYSQL_USER
              valueFrom:
                secretKeyRef:
                  name: drupal-mysql-secret
                  key: MYSQL_USER
          volumeMounts:
            - mountPath: /var/lib/mysql
              name: mysql-pvc
              subPath: dbdata
