apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
spec:
  selector:
    matchLabels:
      app: mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
        - image: mysql:latest
          name: mysql
#          command:
#            - bash
#          args:
#            - -c
#            - source ~/.bashrc
          env:
            - name: MYSQL_DATABASE
              value: $MYSQL_DATABASE
            - name: MYSQL_USER
              value: $MYSQL_USER
            - name: MYSQL_ROOT_PASSWORD
              value: $MYSQL_ROOT_PASSWORD
            - name: MYSQL_PASSWORD
              value: $MYSQL_PASSWORD
          ports:
            - containerPort: 3306
              name: mysql
          volumeMounts:
            - name: mysql-storage
              mountPath: /var/lib/mysql
            - name: mysql-log
              mountPath: /var/log/mysql
      volumes:
        - name: mysql-storage
          emptyDir: {}
        - name: mysql-log
          emptyDir: {}
