0

There is a kubernetes baremetal cluster which has 7 nodes. Installed is helm and added a helm repo added

What works: https://matthewpalmer.net/kubernetes-app-developer/articles/kubernetes-ingress-guide-nginx-example.html

I am able to access the apple and the banana location on the dns A record mentioned before.

When i deploy a default nginx image with a service with port 80 and of type cluster-ip the following nginx-ingress resource does not work

kubectl run nginx --image=nginx ; kubectl exposed pod nginx --port=80 
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-test
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: kubernetes.somename.lan
    http:
      paths:
        - path: /test
          pathType: Prefix
          backend:
            serviceName: nginx
            servicePort: 80

I am seeing in the logs that the file is being deployed in the nginx-ingress image, not seeing anything strange in comparison to the apple and banana ingress entry. Only difference I can come up with is that ingress controller and nginx image are bot using port 80

So what I need is that when I access http://somelan.lan/test, I will end up at the placeholder of the nginx server (which is accessible by nginx service )


How can I access nginx on my A dns record under the path /test?

2 Answers 2

0

The provided apple / banana example was working because the pod is path insensitive. It does not react to path changes (ignores paths). While for nginx it is exactly opposite.

The blog has a mistake with annotation and its missing the nginx prefix. This is the one that you used:

ingress.kubernetes.io/rewrite-target

And this is the correct one as per docs:

nginx.ingress.kubernetes.io/rewrite-target
1
  • Thank you for posting an answer, i have trouble getting a working ingress yaml definition would appreciate some help. So what i need is that when i access somelan.lan/test i will end up at the placeholder of the nginx server (which is accessible by nginx service )
    – Arch
    Commented Oct 21, 2020 at 5:56
0

Ok, after research i found out how to solve this. Hope this helps anyone https://www.reddit.com/r/kubernetes/comments/j2neuf/nginxingress_path_routing/

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-precious
  annotations:
    nginx.org/rewrites: "serviceName=nginx-ingress rewrite=/;"
spec:
  rules:
  - host: kubernetes.somelan.lan
    http:
      paths:
      - path: /test1
        backend:
          serviceName: nginx-ingress
          servicePort: 80

Not the answer you're looking for? Browse other questions tagged or ask your own question.