---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/name: nginx
    app.kubernetes.io/part-of: nextcloud
    app.kubernetes.io/component: proxy
  name: nginx
  namespace: nextcloud
spec:
  revisionHistoryLimit: 3
  selector:
    matchLabels:
      app.kubernetes.io/name: nginx
      app.kubernetes.io/part-of: nextcloud
      app.kubernetes.io/component: proxy
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/default-container: nginx
      labels:
        app.kubernetes.io/name: nginx
        app.kubernetes.io/part-of: nextcloud
        app.kubernetes.io/component: proxy
    spec:
      affinity:
         podAntiAffinity:
           preferredDuringSchedulingIgnoredDuringExecution:
           - weight: 100
             podAffinityTerm:
               labelSelector:
                 matchExpressions:
                   - key: app.kubernetes.io/name
                     operator: In
                     values: ["nginx"]
               topologyKey: kubernetes.io/hostname
      containers:
      - image: nginx:1.19
        name: nginx
        imagePullPolicy: Always
        ports:
        - containerPort: 80
          name: http
        volumeMounts:
        - name: config
          mountPath: /etc/nginx/nginx.conf
          subPath: nginx.conf
        #- name: locations
        #  mountPath: /etc/nginx/locations
        - name: web
          mountPath: /var/www/html
          readOnly: true
        #- name: apps
        #  mountPath: /var/www/html/custom_apps
        #  readOnly: true
        resources:
          requests:
            cpu: 5m
            memory: 25Mi
      - image: quay.io/paulfantom/nginx-exporter:0.8.0
        name: nginx-exporter
        args:
        - "-nginx.scrape-uri"
        - "http://127.0.0.1:8080/stub_status"
        ports:
        - containerPort: 9113
          name: metrics
        resources:
          requests:
            cpu: 1m
            memory: 11Mi
          limits:
            memory: 20Mi
      restartPolicy: Always
      volumes:
      - name: config
        configMap:
          name: nginx-config
      #- name: locations
      #  secret:
      #    secretName: nginx-locations
      - name: web
        persistentVolumeClaim:
          claimName: nextcloud-files
      - name: apps
        persistentVolumeClaim:
          claimName: nextcloud-apps
      nodeSelector:
        network.infra/type: "fast"
      tolerations: []
