Paths in Kubernetes Ingress Specs

10/5/2018

I have the following ingress resource for one of my apps

apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name:""
    annotations:
      ingress.kubernetes.io..
  spec:
    rules:
    - host: my-app
      http:
        paths:
        - path: /path/to/service
          backend:
            serviceName: my-service
            servicePort: 80

This works as expected and I can access my service at http://my-app/path/to/service. However the service in my app takes query parameters that dont seem to correctly get redirected for eg:

http://my-app/path/to/service/more/paths

This brings me back to http://my-app/path/to/service

How can I maintain this path structure ?

-- user_mda
kubernetes
kubernetes-ingress
path

1 Answer

10/6/2018

I believe you need to use wildcards on your path:

apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name:""
    annotations:
      ingress.kubernetes.io..
  spec:
    rules:
    - host: my-app
      http:
        paths:
        - path: /path/to/service/*
          backend:
            serviceName: my-service
            servicePort: 80

More information here. Seems like it's hard to find any docs with wildcard examples. Not that this is specific to nginx, it may not work with other ingress controllers.

-- Rico
Source: StackOverflow