apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql-php-deployment
  labels:
    app: mysql-phpmyadmin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql-phpmyadmin
  template:
    metadata:
      labels:
        app: mysql-phpmyadmin
    spec:
      containers:
        - name: mysql
          image: tobi312/rpi-mysql
          ports:
          - containerPort: 3306
          env:
          - name: MYSQL_ROOT_PASSWORD
            valueFrom:
                secretKeyRef:
                  name: mysql-credentials
                  key: ROOT_PASSWORD
          volumeMounts:
          - name: mysql-storage
            mountPath: /var/lib/mysql
        - name: myadmin
          image: ebspace/armhf-phpmyadmin:latest
          ports:
          - containerPort: 80
          env:
          - name: PMA_HOST
            value: 127.0.0.1
          - name: PMA_PORT
            value: "3306"
          - name: PMA_USER
            value: root
          - name: PMA_PASSWORD
            valueFrom:
                secretKeyRef:
                  name: mysql-credentials
                  key: ROOT_PASSWORD
          - name: MYSQL_ROOT_PASSWORD
            valueFrom:
                secretKeyRef:
                  name: mysql-credentials
                  key: ROOT_PASSWORD
      volumes:
        - name: mysql-storage
          persistentVolumeClaim:
            claimName: mysql-pv-claim
