44

When I am trying to create an ingress resource for my Kubernetes cluster(ingress controller is already created), Ingress resource/rules are creating and I am able to see in the kubectl get ing. But when I do kubectl describe, I am seeing a error:

Default backend: default-http-backend:80 (<error: endpoints “default-http-backend” not found>)

Is this expected?? I am not even able to connect to my application using the DNS name (hotel.example.com) which I defined in Ingress resource. Is it due to this http-backend error? If not, any suggestions to make the application connect!!

[dockuser@hostname]$ kubectl describe ing hotel-ingress -n hotel
Name:             hotel-ingress
Namespace:        hotel
Address:
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
  Host         Path  Backends
  ----         ----  --------

  hotel.example.com
               /     hotel-svc:80 (10.36.0.2:80,10.44.0.2:80)
Annotations: 
Events:

deployment files: namespaces.yaml

apiVersion: v1
kind: Namespace
metadata:
  name: hotel

ingress.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: hotel-ingress
  namespace: hotel
spec:
  rules:
  - host: hotel.example.com
    http:
      paths:
      - path: /
        backend:
          serviceName: hotel-svc
          servicePort: 80

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hotel
  namespace: hotel
spec:
  replicas: 2
  selector:
    matchLabels:
      app: hotel
  template:
    metadata:
      labels:
        app: hotel
    spec:
      containers:
      - name: hotel
        image: nginxdemos/hello:plain-text
        ports:
          - containerPort: 80

service.yaml

apiVersion: v1
kind: Service
metadata:
  name: hotel-svc
  namespace: hotel
spec:
  selector:
    app: hotel
  ports:
    - port: 80
      targetPort: 80
trejo08
  • 2,348
  • 1
  • 13
  • 12
Ankit Gulati
  • 477
  • 1
  • 4
  • 3

7 Answers7

21

You may want add defaultBackend as a part of your Ingress definition like so

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: default-backend-ingress-example
spec:
  defaultBackend:
    service:
      name: hotel-svc
      port:
        number: 80

Environment

minikube version: v1.21.0
kubectl version: v1.20.7
nakhodkin
  • 1,327
  • 1
  • 17
  • 27
7

I realize this was answered (adding for posterity,) however in my case I had already ran

minikube addons enable ingress

but system was still missing default-http-backend.

I suspect that at the time there had been a conflicting use of a port or some such and the default-http-backend silently failed to be created.

After many attempts to correct the issue I finally discovered that executing the following commands fixed the issue for me:

[update 2021-12-15]

original resources no longer available, sorry

If I had to do this again today I would probably try to apply a deployment directly from the ingress-nginx project:

kubectl apply -f https://github.com/kubernetes/ingress-nginx/tree/main/deploy/static/provider/baremetal/deploy.yaml

(not tested)

PS: Note that there already were configmaps present for nginx-load-balancer-conf so I didn't add those.

PPS: Secondly, this was just for education on a local laptop so take its trustworthiness with a grain of salt.

Ray
  • 1,324
  • 10
  • 18
5

If you are using Minikube, it may be because you haven't enabled ingress.

Please try the command below:

minikube addons enable ingress

or

minikube addons enable ingress --alsologtostderr
Kamafeather
  • 8,663
  • 14
  • 69
  • 99
1

I think missing default backend can be ignored. At least it is not required for Openshift-style routes with load-balancing work under k8s, as described in this answer.

mirekphd
  • 4,799
  • 3
  • 38
  • 59
1

The answer in my case was found here, which is that the ingress rule needs to be created in the same namespace as the service rule(s) its referencing. Or else, as discussed in the same thread, one must find a way to include the namespace as part of the reference to that service.

Instead of creating the ingress your-ingress-name in ingress-nginx namespace you should create it in the namespace where you have the service...

Possible solution if you're getting this result:

kubectl describe ingress your-ingress-name

...
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Nicholas Petersen
  • 9,104
  • 7
  • 59
  • 69
  • So if I didn't specify any namespace for my services, how to I get the ingress to be in the same namespace as my services? I'm not working on minikube. I'm trying to get it implemented on the Linode cloud. – Nav Aug 21 '21 at 14:18
  • Your services then are probably in the default namespace `default`, but you can find out by examining your services. Your yaml specs might have specified a namespace too. To view all namespaces `kubectl get ns`. Anyway once you find the namespace I think recreate your ingress while specifying a namespace, which can be done in the yaml spec right below service name, or perhaps easiest append to ingress create command `—namespace YOURNS` (I think) – Nicholas Petersen Aug 22 '21 at 15:17
  • Yes. I've been able to add `namespace: default` under the hierarchy of `metadata` for Ingress yaml. Thank you. – Nav Aug 22 '21 at 16:16
0

I tried following this doc steps and it worked fine: https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/

bzani
  • 487
  • 4
  • 5
-14

Create default-http-backend service in kube-system namespace and error will be gone.

See more: ngress-nginx-troubleshooting.

Malgorzata
  • 6,409
  • 1
  • 10
  • 27
  • 10
    The actual command would be nice to have here as well. – rhand Dec 14 '20 at 13:08
  • 7
    This is a perfect example of how not to answer a question. In fact, this is a non-answer. Don't rely on esoteric knowledge or links to external sources that might move or get removed. I haven't the slightest idea what I'm supposed to be looking for in that link you shared. – senfo Jan 28 '21 at 13:46