-1

inside my ingress config i changed default backend.

spec:
  defaultBackend:
    service:
      name: navigation-service
      port:
        number: 80

When I describe ingress i have got

Name:             ingress-nginx
Namespace:        default
Address:          127.0.0.1
Default backend:  navigation-service:80 (10.1.173.59:80)

I trying to access it via localhost and i have got 404. However when i curl 10.1.173.59, i have got my static page. So my navigation-service its ok and something is wrong with defaultbacked? Even if i trying

          - pathType: Prefix
            path: /
            backend:
              service:
                name: navigation-service
                port:
                  number: 80

I have got 500 error. What im doing wrong?

Edit: Works via NodePort but I need to access it via ingress.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: navigation-deployment
spec:
  selector:
    matchLabels:
      app: navigation-deployment
  template:
    metadata:
      labels:
        app: navigation-deployment
    spec:
      containers:
        - name: nginx
          image: nginx:1.13.3-alpine
          ports:
            - containerPort: 80
          volumeMounts:
            - mountPath: /usr/share/nginx/html/index.html
              name: nginx-html
            - mountPath: /etc/nginx/conf.d/default.conf
              name: nginx-default
      volumes:
        - name: nginx-html
          hostPath:
            path: /home/x/navigation/index.html
        - name: nginx-default
          hostPath:
            path: /home/x/navigation/default.conf
apiVersion: v1
kind: Service
metadata:
  name: navigation-service
spec:
  type: ClusterIP
  selector:
    app: navigation-deployment
  ports:
    - name: "http"
      port: 80
      targetPort: 80
Sekru
  • 515
  • 2
  • 11
  • Path `/` returns 404 - it is default backend - https://kubernetes.github.io/ingress-nginx/user-guide/default-backend/ Have you tried to specify another path like /example and then access app using http://localhost/example (of course add ingress.kubernetes.io/rewrite-target: / annotation to ingress config)? – Malgorzata Jan 12 '21 at 12:50
  • Yes it's working on another path. I also have annotation to rewrite. But why i can't change default backend? – Sekru Jan 12 '21 at 13:04
  • Default backend is not configurable. Did you also take a look https://stackoverflow.com/questions/62917095/microk8s-ingress-ingressed-service-always-resolves-to-127-0-0-1-and-not-pod-i ? – Malgorzata Jan 12 '21 at 15:30

1 Answers1

2

If someone have this problem then you need to run ingress controller with args - --default-backend-service=namespace/service_name

Sekru
  • 515
  • 2
  • 11