---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app.kubernetes.io/name: phpfpm
    app.kubernetes.io/version: 22.0.0
    app.kubernetes.io/part-of: nextcloud
    app.kubernetes.io/component: server
  name: nextcloud
  namespace: nextcloud
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: phpfpm
      app.kubernetes.io/part-of: nextcloud
  replicas: 1
  revisionHistoryLimit: 3
  serviceName: nextcloud
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/default-container: nextcloud
      labels:
        app.kubernetes.io/name: phpfpm
        app.kubernetes.io/version: 22.0.0
        app.kubernetes.io/part-of: nextcloud
        app.kubernetes.io/component: server
    spec:
      containers:
      - envFrom:
        - configMapRef:
            name: nextcloud-envs
        - secretRef:
            name: mysql-creds
        - secretRef:
            name: redis-password
        - secretRef:
            name: smtp
        image: nextcloud:22.0.0-fpm
        # imagePullPolicy: Always
        name: nextcloud
        ports:
        - containerPort: 9000
          name: phpfpm
        readinessProbe:
          tcpSocket:
            port: phpfpm
        volumeMounts:
        - name: phpfpm-config
          mountPath: /usr/local/etc/php-fpm.d/zzz-custom.conf
          subPath: zzz-custom.conf
        - name: php-config
          mountPath: /etc/php/conf.d
        - name: web
          mountPath: /var/www/html
        - name: apps
          mountPath: /var/www/html/custom_apps
        - name: theme
          mountPath: /var/www/html/themes/mytheme
        - name: config
          mountPath: /var/www/html/config
        - name: data
          mountPath: /var/www/html/data
        resources:
          requests:
            cpu: 200m
            memory: 300Mi
      - env:
        - name: PHP_FPM_SCRAPE_URI
          value: "tcp://127.0.0.1:9000/status"
        image: hipages/php-fpm_exporter:latest
        imagePullPolicy: IfNotPresent
        name: phpfpm-exporter
        ports:
        - containerPort: 9253
          name: phpfpm-metrics
        resources:
          requests:
            cpu: 1m
            memory: 12Mi
          limits:
            memory: 20Mi
      restartPolicy: Always
      volumes:
      - name: phpfpm-config
        configMap:
          name: phpfpm-config
      - name: php-config
        configMap:
          name: php-config
      - name: data
        persistentVolumeClaim:
          claimName: nextcloud-data
      - name: web
        persistentVolumeClaim:
          claimName: nextcloud-files
      - name: apps
        persistentVolumeClaim:
          claimName: nextcloud-apps
      - name: theme
        persistentVolumeClaim:
          claimName: nextcloud-theme
      - name: config
        persistentVolumeClaim:
          claimName: nextcloud-config
      nodeSelector:
        kubernetes.io/arch: "amd64"

