apiVersion: networking.k8s.io/v1
# UPDATE API
kind: Ingress
metadata:
  name: {{ .Values.appName }}
  annotations:
    # want to create nginx controller based on nginx project
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: "true"
    # ADD ANNOTATION
    # how our copy of nginx behaves
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-body-size: "200m"    
    # UPDATE ANNOTATION
    # https added annotatiosn
    # cert-manager.io/cluster-issuer: {{ .Values.appName }}-letsencrypt-prod
    nginx.ingress.kubernetes.io/ssl-redirect: 'true'
spec:
  tls:
    - hosts:
        - mettacare.life
        - www.mettacare.life
      secretName: {{ .Values.appName }}-ingress-tls      
  rules:
    - host: mettacare.life
      http:
        paths:
          - path: /?(.*)
            # UPDATE PATH
            pathType: Prefix
            # ADD PATHTYPE
            backend:
              service:
                # UPDATE SERVICE FIELDS
                name: {{ .Values.web.serviceName }}
                port:
                  number: {{ .Values.web.port }}
          - path: /(?:odataAPI|api|upload)/?(.*)
            # UPDATE PATH
            pathType: Prefix
            # ADD PATHTYPE
            backend:
              service:
                # UPDATE SERVICE FIELDS
                name: {{ .Values.api.serviceName }}
                port:
                  number: {{ .Values.api.port }}
    - host: www.mettacare.life
      http:
        paths:
          - path: /?(.*)
            # UPDATE PATH
            pathType: Prefix
            # ADD PATHTYPE
            backend:
              service:
                # UPDATE SERVICE FIELDS
                name: {{ .Values.web.serviceName }}
                port:
                  number: {{ .Values.web.port }}
          - path: /(?:odataAPI|api|upload)/?(.*)
            # UPDATE PATH
            pathType: Prefix
            # ADD PATHTYPE
            backend:
              service:
                # UPDATE SERVICE FIELDS
                name: {{ .Values.api.serviceName }}
                port:
                  number: {{ .Values.api.port }}
