kind: Deployment
apiVersion: apps/v1
metadata:
  namespace: wordpress
  name: wordpress
  labels:
    app.kubernetes.io/name: wordpress
spec:
  replicas: 2
  selector:
    matchLabels:
      app.kubernetes.io/name: wordpress
  template:
    metadata:
      labels:
        app.kubernetes.io/name: wordpress
    spec:
      containers:
        - name: nginx
          image: nginx:1.17.8-alpine
          ports:
            - name: http
              containerPort: 80
          resources:
            limits:
              cpu: 1000m
              memory: 128Mi
            requests:
              cpu: 100m
              memory: 128Mi
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /-/ping
              port: 80
              scheme: HTTP
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 10
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /-/ping
              port: 80
              scheme: HTTP
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 10
          volumeMounts:
          - name: nginx-config
            mountPath: /etc/nginx/nginx.conf
            subPath: nginx.conf
          - name: wordpress-data
            mountPath: /var/www/html
          - name: run
            mountPath: /run
        - name: php-fpm
          image: rascal/php-fpm:v7.4.3
          resources:
            limits:
              cpu: 1000m
              memory: 512Mi
            requests:
              cpu: 500m
              memory: 512Mi
          volumeMounts:
          - name: php-fpm-config
            mountPath: /usr/local/etc/php-fpm.d
          - name: wordpress-data
            mountPath: /var/www/html
          - name: run
            mountPath: /run
        - name: php-fpm-exporter
          image: rascal/php-fpm-exporter:v0.6.1
          imagePullPolicy: Always
          args:
          - --addr
          - 0.0.0.0:8080
          - --fastcgi
          - unix:///run/php-fpm.sock
          ports:
            - name: php-metrics
              containerPort: 8080
          resources:
            limits:
              cpu: 50m
              memory: 32Mi
            requests:
              cpu: 10m
              memory: 32Mi
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /healthz
              port: php-metrics
              scheme: HTTP
            initialDelaySeconds: 30
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 30
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /healthz
              port: php-metrics
              scheme: HTTP
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 30
          volumeMounts:
          - name: run
            mountPath: /run
      volumes:
       - name: run
         emptyDir: {}
       - name: php-fpm-config
         configMap:
           name: php-fpm-config
       - name: nginx-config
         configMap:
          name: nginx-config
          items:
          - key: nginx.conf
            path: nginx.conf
       - name: wordpress-data
         persistentVolumeClaim:
           claimName: wordpress-data-pvc
      dnsConfig:
        options:
        - name: ndots
          value: "1"
