apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: postfacto-routes
  namespace: ingress
  labels:
    app.kubernetes.io/name: 'postfacto'
    app.kubernetes.io/instance: 'postfacto'
    app.kubernetes.io/component: 'ingress'
    app.kubernetes.io/part-of: 'postfacto'
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: 'true'
    nginx.ingress.kubernetes.io/configuration-snippet: |
      if ( $http_x_postfacto_version = "4.1.0" ){
      proxy_pass http://postfacto-v1.postfacto.svc.cluster.local:80;
      }

      if ( $http_x_postfacto_version = "4.2.0" ){
      proxy_pass http://postfacto-v2.postfacto.svc.cluster.local:80;
      }
      
spec:
  rules:
    - host: postfacto.api0.live
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: postfacto-v2-external-service
                port:
                  number: 80
  tls:
    - secretName: postfacto.api0.live-tls.secret
      hosts:
        - postfacto.api0.live
