apiVersion: apps/v1
kind: Deployment
metadata:
  name: budget-service-database-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      component: budget-service-database
  template:
    metadata:
      labels:
        component: budget-service-database
    spec:
      containers:
        - name: budget-service-database
          image: mysql
          env:
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: budget-service-database-password
                  key: PASSWORD
            - name: MYSQL_DATABASE
              value: monetize-budget
          args: ["--default-authentication-plugin=mysql_native_password"]
          ports:
            - containerPort: 3306
          volumeMounts:
            - name: budget-service-database-storage
              mountPath: /var/lib/mysql
      volumes:
        - name: budget-service-database-storage
          persistentVolumeClaim:
            claimName: budget-service-database-persistent-volume-claim
