apiVersion: apps/v1
kind: Deployment
metadata:
  name: sugar-mysql
  labels:
    app: sugar-mysql
spec:
  selector:
    matchLabels:
      app: sugar-mysql
      tier: database
  template:
    metadata:
      labels:
        app: sugar-mysql
        tier: database
    spec:
      containers:
      - name: sugar-mysql
        image: mysql:5.7
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: root
        - name: MYSQL_DATABASE
          value: sugarcrm
        - name: MYSQL_USER
          value: devuser
        - name: MYSQL_PASSWORD
          value: devpass
        # mysql can't start unless the volume is empty, ext4 has some default folders
        args: ["--ignore-db-dir=lost+found"]
        ports:
        - containerPort: 3306
          name: sugar-mysql
        volumeMounts:
        - mountPath: /var/lib/mysql
          name: database
      volumes:
      - name: database
        persistentVolumeClaim:
          claimName: mysql-pv-claim
