Question

Typhon - can't configure ingress to work, always end up with default-backend and 404

Hi Folks,

I have created ingrees controller using documentation provided by the Typhoon distribution.

kubectl create -R -f typhoon/addons/nginx-ingress/digital-ocean/

Next using deployment:

kubectl run nginx --image=nginx --replicas=2 --port=80

Exposing by service:

kubectl expose  deployment nginx --name=nginx --port=80 --target-port=80

and next configuring ingress using configuration below:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nginx
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: in.cloud.example.com
    http:
      paths:
      - path: /
        backend:
          serviceName: nginx
          servicePort: 80

When I tried to access page using browser or curl always end up with:

default backend - 404

Please help.

Subscribe
Share

Output from ingress name space:


root@core:~/nextcloud# kubectl get all --namespace=ingress
NAME                              READY     STATUS    RESTARTS   AGE
default-backend-99ff6fb5f-gh45b   1/1       Running   0          4h
nginx-ingress-controller-cg4c5    1/1       Running   7          4h
nginx-ingress-controller-wp9wb    1/1       Running   7          4h

NAME                       TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
default-backend            ClusterIP   10.3.164.90    <none>        80/TCP           4h
nginx-ingress-controller   ClusterIP   10.3.230.155   <none>        80/TCP,443/TCP   4h

NAME                       DESIRED   CURRENT   READY     UP-TO-DATE   AVAILABLE   NODE SELECTOR                   AGE
nginx-ingress-controller   2         2         2         2            2           node-role.kubernetes.io/node=   4h

NAME              DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
default-backend   1         1         1            1           4h

NAME                        DESIRED   CURRENT   READY     AGE
default-backend-99ff6fb5f   1         1         1         4h
root@core:~/nextcloud#


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

@velimattiahod6eb232fc97763 wow I’ve been beating my head against this particular wall for over 3 hours! Thank you so much!

I had the same problem, solution was to add kubernetes.io/ingress.class: "public" to your ingress? Typhoon nginx-ingress addon says on startup

W0415 06:05:49.439051       5 flags.go:164] only Ingress with class "public" will be processed by this ingress controller

Your ingress ->

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nginx
  annotations:
    kubernetes.io/ingress.class: "public"
spec:
  rules:
  - host: in.cloud.example.com
    http:
      paths:
      - path: /
        backend:
          serviceName: nginx
          servicePort: 80

Hey. Since I am no Kubernetes expert (yet :) ) I reached out to some of our engineers to take a look at your question. One of our engineers has suggested the following:

The ingress they posted specifies a service name nginx

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nginx
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: in.cloud.example.com
    http:
      paths:
      - path: /
        backend:
          serviceName: nginx
          servicePort: 80

but the kubectl get all output doesn’t have nginx service listed which seems like the issue

NAME                       TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
default-backend            ClusterIP   10.3.164.90    <none>        80/TCP           4h
nginx-ingress-controller   ClusterIP   10.3.230.155   <none>        80/TCP,443/TCP   4h

the default backend - 404 response is from the pod default-backend which the ingress controller falls back to if the ingress is misconfigured or there’s no matching hosts on the controller.

So it sounds like you need to specify nginx-ingress-controller instead of nginx in your configuration or create an nginx deployment frontend by an nginx service like this:

kind: Service
apiVersion: v1
metadata:
  name: nginx
spec:
  selector:
    app: nginx
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        resources:
          requests:
            cpu: 10m
        ports:
        - containerPort: 80