Kubernetes Ingress Path Kubernetes Ingress Path kubernetes kubernetes

Kubernetes Ingress Path


You need to change the regex for graphql path like the following:

apiVersion: networking.k8s.io/v1beta1kind: Ingressmetadata:  name: polls-ingress  annotations:    kubernetes.io/ingress.class: "nginx"    nginx.ingress.kubernetes.io/rewrite-target: /$1    nginx.ingress.kubernetes.io/service-upstream: "true"    cert-manager.io/cluster-issuer: "letsencrypt-prod"spec:  tls:  - hosts:    - example.com    secretName: polls-tls  rules:  - host: example.com    http:      paths:      - path: /(.*)        backend:          serviceName: frontend          servicePort: 3000      - path: /graphql/?(.*)   # <- HERE add "?"        backend:          serviceName: polls          servicePort: 8000

From docs on regex:

The question mark indicates zero or one occurrences of the preceding element. For example, colou?r matches both "color" and "colour".