Ingress return 404

11/17/2021

Rancher ingress return 404 to service.

Setup: I have 6 VMs, one Rancher server x.x.x.51 (where dns domain.company is pointing to, TLS), and 5 VMs (one master and 4 worker x.x.x.52-56).

My service, gvm-gsad running in gvm namespace:

   apiVersion: v1
kind: Service
metadata:
 annotations:
   field.cattle.io/publicEndpoints: "null"
   meta.helm.sh/release-name: gvm
   meta.helm.sh/release-namespace: gvm
 creationTimestamp: "2021-11-15T21:14:21Z"
 labels:
   app.kubernetes.io/instance: gvm-gvm
   app.kubernetes.io/managed-by: Helm
   app.kubernetes.io/name: gvm-gsad
   app.kubernetes.io/version: "21.04"
   helm.sh/chart: gvm-1.3.0
 name: gvm-gsad
 namespace: gvm
 resourceVersion: "3488107"
 uid: c1ddfdfa-3799-4945-841d-b6aa9a89f93a
spec:
 clusterIP: 10.43.195.239
 clusterIPs:
 - 10.43.195.239
 ipFamilies:
 - IPv4
 ipFamilyPolicy: SingleStack
 ports:
 - name: gsad
   port: 80
   protocol: TCP
   targetPort: gsad
 selector:
   app.kubernetes.io/instance: gvm-gvm
   app.kubernetes.io/name: gvm-gsad
 sessionAffinity: None
 type: ClusterIP
status:
 loadBalancer: {}

My ingress configure: Ingress controller is default one from rancher.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    field.cattle.io/publicEndpoints: '[{"addresses":["172.16.12.53"],"port":443,"protocol":"HTTPS","serviceName":"gvm:gvm-gsad","ingressName":"gvm:gvm","hostname":"dtl.miproad.ad","path":"/gvm","allNodes":true}]'
  creationTimestamp: "2021-11-16T19:22:45Z"
  generation: 10
  name: gvm
  namespace: gvm
  resourceVersion: "3508472"
  uid: e99271a8-8553-45c8-b027-b259a453793c
spec:
  rules:
  - host: domain.company
    http:
      paths:
      - backend:
          service:
            name: gvm-gsad
            port:
              number: 80
        path: /gvm
        pathType: Prefix
  tls:
  - hosts:
    - domain.company
status:
  loadBalancer:
    ingress:
    - ip: x.x.x.53
    - ip: x.x.x.54
    - ip: x.x.x.55
    - ip: x.x.x.56

When i access it with https://domain.company/gvm then i get 404.

However, when i change the service to NodePort, i could access it with x.x.x.52:PORT normally. Meaning the deployment is running fine, just some configuration issue in ingress.

I checked this one: https://stackoverflow.com/questions/52442868/rancher-2-x-thru-ingress-controller-returns-404 but it does not help.

Thank you in advance!

-- Viet Nguyen
kubernetes
kubernetes-ingress
nginx-ingress
rancher
service

1 Answer

11/22/2021

Figured out the solution.

The domain.company is pointing to rancher (x.x.x.51). Where the ingress is running on (x.x.x.53,.54,.55,.56).

So, the solution is to create a new DNS called gvm.domain.company pointing to any ingress (x.x.x.53,.54,.55,.56) (you can have LoadBalancer here or use round robin DNS).

Then, the ingress definition is gvm.domain.company and path is "/".

Hope it helps others!

-- Viet Nguyen
Source: StackOverflow