0
votes

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 )

Question: How can i access nginx on my A dns record under the path /test Thank you in advancee

2

2 Answers

0
votes

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
0
votes

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