apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: wordpress-mysql
  namespace: test
  labels:
    app: wordpress
spec:
  serviceName: wordpress-mysql
  replicas: 1
  selector:
    matchLabels:
      app: wordpress
      tier: mysql

  template:
    metadata:
      labels:
        app: wordpress
        tier: mysql
    spec:
      containers:
      - image: mysql:5.6
        name: mysql
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-pass
              key: password
        ports:
        - containerPort: 3306
          name: mysql
        volumeMounts:
        - name: mysql-pv-claim
          mountPath: /var/lib/mysql
  volumeClaimTemplates:
  - metadata:
      name: mysql-pv-claim
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: fast
      resources:
        requests:
          storage: 20Gi