apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-serv
  annotations:
    kubernetes.io/ingress.class: nginx # tells the ingress controller to expect routing rules
    nginx.ingress.kubernetes.io/use-regex: 'true' # allow for regex
spec:
  rules:
    - host: posts.com # in etc/hosts have this url route to minikube IP or 127.0.0.1 if not
      http:
        paths:
          - path: /posts/create
            pathType: Prefix
            backend:
              service:
                name: posts-serv-clusterip
                port:
                  number: 8000
          - path: /posts
            pathType: Prefix
            backend:
              service:
                name: query-serv
                port:
                  number: 8010
          - path: /posts/?(.*)/comments # no :id syntax so use regex wildcard
            pathType: Prefix
            backend:
              service:
                name: comments-serv
                port:
                  number: 8001
          - path: /?(.*) # match any other path
            pathType: Prefix
            backend:
              service:
                name: client-serv
                port:
                  number: 3000

# notes
# these paths are top to bottom, so a regex wildcard for the react app must be last
