---
apiVersion: apps/v1
kind: Deployment

metadata:
  name: mysql

spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      labels:
        app: mysql

    spec:
#     nodeSelector:
#       kubernetes.io/hostname: "dev"
      containers:
      - name: mysql
        image: mysql:5.7
#       command: ["/bin/sh"]
#       args: ["-c","echo here;sleep 300"]
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-pass
              key: password
        ports:
        - name: mysql
          containerPort: 3306
        volumeMounts:
        - name: data-mysql
          mountPath: /var/lib/mysql
        - name: mysql-conf
          mountPath: /etc/mysql/mysql.conf.d/mysqld.cnf

        resources:
          requests:
            cpu: 500m
            memory: 1Gi

#       livenessProbe:
#         exec:
#           command: ["mysqladmin", "ping"]
#         initialDelaySeconds: 30
#         periodSeconds: 10
#         timeoutSeconds: 5
#       readinessProbe:
#         exec:
#           # Check we can execute queries over TCP (skip-networking is off).
#           command: ["mysql", "-h", "127.0.0.1", "-e", "SELECT 1"]
#         initialDelaySeconds: 5
#         periodSeconds: 2
#         timeoutSeconds: 1

      volumes:
      - name: data-mysql
        hostPath:
          path: /data/kube/mysql
          type: DirectoryOrCreate
      - name: mysql-conf
        hostPath:
          path: /data/etc/50-server.cnf
#       persistentVolumeClaim:
#         claimName: mysql-pvc
