apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: gerrit-ingress
  namespace: gerrit
  annotations:
    nginx.ingress.kubernetes.io/use-regex: true
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/affinity: cookie
    nginx.ingress.kubernetes.io/session-cookie-name: Gerrit_Session
    nginx.ingress.kubernetes.io/session-cookie-path: /
    nginx.ingress.kubernetes.io/session-cookie-max-age: 60
    nginx.ingress.kubernetes.io/session-cookie-expires: 60
    nginx.ingress.kubernetes.io/configuration-snippet: |-
      if ($args ~ service=git-receive-pack){
        set $proxy_upstream_name "gerrit-receiver-http";
        set $proxy_host $proxy_upstream_name;
        set $service_name "receiver";
      }
spec:
  rules:
  - host: example.com
    http:
      paths:
      - pathType: Prefix
        path: "/a/projects"
        backend:
          service:
            name: receiver
            port:
              name: http
      - pathType: Prefix
        path: "/.*/git-receive-pack"
        backend:
          service:
            name: receiver
            port:
              name: http
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: replica
            port:
              name: http
