Kubernetes Ingress routing

12/6/2020

I would like to be able to reach main page located at /usr/share/nginx/html/index.html of my pod. I want to use URL http://myexternalclusterIP/web Instead of redirecting to the main page my query tries to find the /web path inside the pod. If I use DNS hostname, this all works fine, why doesn't it work with IP address?

My ingress config:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-my
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - pathType: Prefix
        path: /web
        backend:
          service:
            name: newsite
            port:
              number: 1856

My svc config:

Name:              newsite
Namespace:         default
Labels:            app=newsite
Annotations:       <none>
Selector:          app=newsite
Type:              ClusterIP
IP:                10.108.204.71
Port:              <unset>  1856/TCP
TargetPort:        80/TCP
Endpoints:         10.244.0.126:80
Session Affinity:  None
Events:            <none>
-- mzv
kubernetes
kubernetes-ingress

0 Answers