apiVersion: apps/v1
kind: Deployment
metadata:
  name: mariadb
  labels:
    app: clase11
  namespace: clase11
spec:
  selector:
    matchLabels:
      app: clase11
      tier: mariadb
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: clase11
        tier: mariadb
    spec:
      containers:
      - image: mariadb:10.6
        name: mariadb
        resources:
          requests:
            cpu: 200m
            memory: 200Mi
          limits:
            cpu: 500m
            memory: 500Mi
        env:
        - name: MARIADB_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mariadb-secrets
              key: root_password
        - name: MARIADB_USER
          value: user
        - name: MARIADB_USER_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mariadb-secrets
              key: user_password
        - name: MARIADB_DATABASE
          value: 'aws101'
        ports:
        - containerPort: 3306
          name: mariadb
        volumeMounts:
        - name: mariadb-persistent-storage
          mountPath: /var/lib/mysql
      volumes:
      - name: mariadb-persistent-storage
        persistentVolumeClaim:
          claimName: mariadb-data-disk
