---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: wordpress
  labels:
    app: wordpress
spec:
  replicas: 1
  selector:
    matchLabels:
      app: wordpress
      tier: frontend
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: wordpress
        tier: frontend
    spec:
      containers:
        - image: wordpress:latest
          name: wordpress
          env:
            # Annoyingly repetitive -- envFrom: is a nicer way to do this with a ConfigMap or Secret
            - name: WORDPRESS_DB_HOST
              value: private-gltd-8ah-prd-db-cluster-do-user-916868-0.db.ondigitalocean.com:25060
            - name: WORDPRESS_DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: wp-db-secrets
                  key: MYSQL_PASSWORD
            - name: WORDPRESS_DB_USER
              valueFrom:
                secretKeyRef:
                  name: wp-db-secrets
                  key: MYSQL_USER
            - name: WORDPRESS_DB_NAME
              valueFrom:
                secretKeyRef:
                  name: wp-db-secrets
                  key: MYSQL_DATABASE
          ports:
          - containerPort: 80
            name: wordpress
          volumeMounts:
            - name: wordpress-persistent-storage
              mountPath: /var/www/html
      volumes:
        - name: wordpress-persistent-storage
          persistentVolumeClaim:
            claimName: wordpress-prd-pv-claim