apiVersion: v1
kind: ReplicationController
metadata:
  name: wordpress-db
spec:
  replicas: 1
  selector:
    app: wordpress-db
  template:
    metadata:
      name: wordpress-db
      labels:
        app: wordpress-db
    spec:
      containers:
        - name: mysql
          image: mysql:5.7
          args:
            - "--ignore-db-dir=lost+found" #command use to ignore default dir created by default while creating mysql5.7, was deprecated in mysql8
          ports:
            - name: mysql-port
              containerPort: 3306
          env:
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: wordpress-secrets
                  key: db-password #using wordpress-secret for password
          volumeMounts:
            - mountPath: "/var/lib/mysql"
              name: mysql-storage
      volumes:
        - name: mysql-storage
          persistentVolumeClaim:
            claimName: mysqldb-storage
