apiVersion: apps/v1
kind: Deployment
metadata:
  name: message-service-mysql-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      component: message-service-mysql
  template:
    metadata:
      labels:
        component: message-service-mysql
    spec:
      volumes:
        - name: message-service-mysql-storage
          persistentVolumeClaim:
            claimName: persistent-volume-claim
      containers:
        - name: mysql
          image: mysql:8.0
          ports:
            - containerPort: 3306
          volumeMounts:
            - name: message-service-mysql-storage
              mountPath: /var/lib/mysql
              subPath: message-service-mysql
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: 'secret'
            - name: MYSQL_DATABASE
              value: 'message_service'
            - name: MYSQL_USER
              value: 'user'
            - name: MYSQL_PASSWORD
              value: 'secret'
