apiVersion: apps/v1 
kind: Deployment
metadata:
  namespace: wordpress-stack
  name: wordpress
  labels:
    app.kubernetes.io/name: wordpress
    app.kubernetes.io/creator: hossein-yousefi
    app.kubernetes.io/stack: wordpress
    app.kubernetes.io/env: production
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: wordpress
      app.kubernetes.io/creator: hossein-yousefi
      app.kubernetes.io/stack: wordpress
      app.kubernetes.io/env: production
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: wordpress
      app.kubernetes.io/creator: hossein-yousefi
      app.kubernetes.io/stack: wordpress
      app.kubernetes.io/env: production
  template:
    metadata:
      labels:
        app.kubernetes.io/name: wordpress
        app.kubernetes.io/creator: hossein-yousefi
        app.kubernetes.io/stack: wordpress
        app.kubernetes.io/env: production
    spec:
      containers:
      - image: wordpress:5
        name: wordpress
        env:
        - name: WORDPRESS_DB_HOST
          value: mysql
        - name: WORDPRESS_DB_USER
          value: root
        - name: WORDPRESS_DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-pass
              key: password
        envFrom:
        - configMapRef:
            name: wordpress-custom-options           
        ports:
        - containerPort: 80
          name: wordpress
        volumeMounts:
        - name: wordpress-persistent-storage
          mountPath: /var/www/html
        - name: wordpress-custom
          mountPath: /usr/local/etc/php/conf.d/uploads.ini
          subPath: uploads.ini
        - name: wordpress-custom
          mountPath: /var/www/html/.htaccess
          subPath: .htaccess         
      volumes:
      - name: wordpress-custom
        configMap:
          name: wordpress-custom-options
          items:
          - key: ".htaccess"
            path: ".htaccess"
          - key: "uploads.ini"
            path: "uploads.ini"
      - name: wordpress-persistent-storage
        persistentVolumeClaim:
          claimName: wp-pv-claim
