Ingress not showing up in namespace - kubernetes

I have used the official Kubernetes-dashboard and was trying to setup an ingress for the dashboard. I have tried to put the ingress into the Kubernetes-dashboard namespace, but the ingress won't show up when I tried kubectl get all -n kubernetes-dashboard. I could still describe the ingress in the same namespace using kubectl get ingress -n kubernetes-dashboard, but the annotations shown up <none>. Can anyone please help me?
Here is my yaml file for the ingress:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: dashborad-ingress
namespace: kubernetes-dashboard
spec:
rules:
- host: dashboard.com
http:
paths:
- path: /testpath
pathType: Prefix
backend:
service:
name: kubernetes-dashboard
port:
number: 443
And the output of kubectl desribe ingress -n kubernetes-dashboard
Name: dashborad-ingress
Namespace: kubernetes-dashboard
Address: 192.168.49.2
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
Host Path Backends
---- ---- --------
dashboard.com
kubernetes-dashboard:443 (172.17.0.6:8443)
Annotations: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Sync 4m7s (x5 over 24m) nginx-ingress-controller Scheduled for sync
Any helps would be appreciated.

Annotations displayed as <none> appear to correct behaviour. You haven't defined any in the attached yaml file, so <none> should be displayed.
I have create simple ingress with one annotation to show you how it works. Look at my metadata section:
metadata:
name: my-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
When I describe my ingress by using command: kubectl describe ingress I have this line in the output:
Annotations: nginx.ingress.kubernetes.io/rewrite-target: /$1
However, I see the problem in a completely different place. When you describe ingress you have this line:
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
The default-backend is responsible to deliver the 404-page-not-found error page when you are trying to access a Service that does not have a rule defined or a Service that has not been configured correctly.
Depending on how you set up the cluster, the solutions may be different. However, if you are using bare metal and Minikube you can try to enable ingress addon:
minikube addons enable ingress
or
minikube addons enable ingress --alsologtostderr
Another solution to this addons:
kubectl apply -f https://raw.githubusercontent.com/roelal/minikube/5093d8b21c0931a6c63fa448538761b4bf100ee0/deploy/addons/ingress/ingress-rc.yaml
kubectl apply -f https://raw.githubusercontent.com/roelal/minikube/5093d8b21c0931a6c63fa448538761b4bf100ee0/deploy/addons/ingress/ingress-svc.yaml
You can also 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
See also:
question on StackOverflow about default http backed
same problem on github
another one
similar topic on linuxfoundation.org
troubleshoouting guide from official documentation

Related

Access kubernetes-dashboard using ingess ( 404 Not Found )

I'm relatively new to k8s and was following an tutorial to get familiar with it. There was a example on exposing kubernetes-dashboard via ingress and I tried to try it.
Configured kubernetes-dashboard by running following. As per its documentation.
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.1/aio/deploy/recommended.yaml
But different from the tutorial kubernetes-dashboard was exposed via port 443
service/dashboard-metrics-scraper ClusterIP 10.108.119.138 <none> 8000/TCP 50m
service/kubernetes-dashboard ClusterIP 10.100.58.17 <none> 443/TCP 50m
So I changed the ingress configuration yaml accordingly.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
name: ingress-dashboard
namespace: kubernetes-dashboard
spec:
rules:
- host: k8s-dashboard.com
http:
paths:
- pathType: Prefix
path: /
backend:
service:
name: kubernetes-dashboard
port:
number: 443
Then I describe the ingress and get the ip and added an entry in /etc/hosts for it
kubectl describe ingress ingress-dashboard -n kubernetes-dashboard
Name: ingress-dashboard
Labels: <none>
Namespace: kubernetes-dashboard
Address: 192.168.49.2
Ingress Class: <none>
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
k8s-dashboard.com
/ kubernetes-dashboard:443 (172.17.0.6:8443)
Annotations: kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/backend-protocol: HTTPS
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Sync 24m (x2 over 25m) nginx-ingress-controller Scheduled for sync
/etc/hosts change
192.168.49.2 k8s-dashbaord.com
When tried to access k8s-dashbaord.com. I get a 404 Not Found from nginx. So it seems like ingress is running but it cannot reach the service.
The ip mapped to ingress rule seems to be wrong though. (172.17.0.6:8443). Because that is not the ip of the service.
What am I doing wrong here?
P.S
If I just to a proxy ( kubectl proxy ) and access dashboard it works fine.

Application not accessible using ingress but works with LoadBalancer GKE

I am trying to configure a hello world application using ingress in GKE. I have been referring a GCP official documentation to deploy an application using Ingress.
Deploying an app using ingress
But this does not work i have tried to refer several documents but none of those work. I have installed the ingress controller in my kubernetes cluster.
kubectl get svc -n ingress-nginx returns below output
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)
AGE
ingress-nginx-controller LoadBalancer 10.125.177.232 35.232.139.102 80:31835/TCP,443:31583/TCP 7h24m
kubectl get pods-n ingress-nginx returns
NAME READY STATUS RESTARTS AGE
ingress-nginx-admission-create-jj72r 0/1 Completed 0 7h24m
ingress-nginx-admission-patch-pktz6 0/1 Completed 0 7h24m
ingress-nginx-controller-5cb8d9c6dd-vptkh 1/1 Running 0 7h24m
kubectl get ingress returns below output
NAME CLASS HOSTS ADDRESS PORTS AGE
ingress-resource <none> 35.232.139.102.nip.io 34.69.2.173 80 7h48m
kubectl get pods returns below output
NAME READY STATUS RESTARTS AGE
hello-app-6d7bb985fd-x5qpn 1/1 Running 0 43m
kubect get svc returns below output
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-app ClusterIP 10.125.187.239 <none> 8080/TCP 43m
Ingress resource yml file used
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-resource
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- host: 35.232.139.102.nip.io
http:
paths:
- pathType: Prefix
path: "/hello"
backend:
service:
name: hello-app
port:
number: 8080
Can someone tell me what i am doing wrong ? When i try to reach the application its not working.
So I have installed Ingress-controller and used ingress controller ip as the host in my ingress file.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-resource
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- host: "35.232.139.102.nip.io"
http:
paths:
- pathType: Prefix
path: "/hello"
backend:
service:
name: hello-app
port:
number: 8080
Issue here was I forgot to add the IP from which I was accessing the application. When you create a GKE cluster there will be a firewall with the cluster-name-all in this firewall you will need to add your IP address of the machine from which you are trying to access the application. Also ensure that the port number is also exposed in my case both were not provided hence it was failing.

the ingress resource stop to sync? what event indicates there?

I run the ingress controller and put one annotation for round_robin algorithm to run. but seems there is no event run there. is it ok if no event in my ingress description? what event indicates there?
# kubectl describe ingress -n ingress
Name: nginx-ingress
Namespace: ingress
Address: 192.168.10.10,192.168.10.45
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
Host Path Backends
---- ---- --------
website.com
/ website1:80 (10.42.0.139:80,10.42.1.223:80,10.42.2.98:80 + 1 more...)
/website2 website2:80 (10.42.0.140:80,10.42.1.232:80,10.42.2.74:80 + 1 more...)
/website3 website3:80 (10.42.0.141:80,10.42.1.215:80,10.42.2.58:80 + 1 more...)
Annotations: nginx.ingress.kubernetes.io/load-balance: round_robin
Events: <none>
I deploy my ingress with this bro, and I have my ingress class. update 1.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress
namespace: ingress
annotations:
nginx.ingress.kubernetes.io/load-balance: ewma
spec:
ingressClassName: nginx
rules:
- host: service.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: service1
port:
number: 80
- path: /service2
pathType: Prefix
backend:
service:
name: service2
port:
number: 80
- path: /service3
pathType: Prefix
backend:
service:
name: service3
port:
number: 80
with another annotation i get the event in my ingress
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Sync 25m (x4 over 113m) nginx-ingress-controller Scheduled for sync
Normal Sync 22m (x39 over 7d2h) nginx-ingress-controller Scheduled for sync
Normal Sync 22m (x41 over 7d2h) nginx-ingress-controller Scheduled for sync
Normal Sync 22m (x22 over 5d10h) nginx-ingress-controller Scheduled for sync
Normal Sync 8m42s (x2 over 9m21s) nginx-ingress-controller Scheduled for sync
# kubectl describe ingress -n ingress
Name: nginx-ingress
Namespace: ingress
Address: 192.168.10.10,192.168.10.45
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
Host Path Backends
---- ---- --------
website1.com
/ nginx-deployment:80 (10.42.0.222:80,10.42.1.32:80,10.42.2.155:80 + 1 more...)
/website2 nginx-video:80 (10.42.0.220:80,10.42.1.30:80,10.42.2.153:80 + 1 more...)
/website3 nginx-document:80 (10.42.0.221:80,10.42.1.31:80,10.42.2.154:80 + 1 more...)
Annotations: nginx.ingress.kubernetes.io/affinity: cookie
nginx.ingress.kubernetes.io/affinity-mode: persistent
nginx.ingress.kubernetes.io/session-cookie-expires: 172800
nginx.ingress.kubernetes.io/session-cookie-max-age: 172800
nginx.ingress.kubernetes.io/session-cookie-name: route
nginx.ingress.kubernetes.io/upstream-hash-by: ewma
Events: <none>
This means your cluster has no ingress controller installed. When there's a ingress controller (such as ingress-nginx) installed in your cluster, a series of events will triggered to process your ingress request. These events will show in your describe command.
If you do have ingress controller but it is not registered as the default ingress class for your cluster, you can add the annotation kubernetes.io/ingress.class: <name of your IngressClass, example "nginx"> to your ingress spec or:
apiVersion: networking.k8s.io/v1
kind: Ingress
...
spec:
ingressClassName: <name of your IngressClass, example "nginx">
...
in fact, the sync is not always displayed. when we do changes at the beginning the ingress controller does sync. However, after some time the sync will stop automatically.

Kubernetes: Route Kubernetes dashboard through Ingress with out host and without proxy

Cluster information:
Installation Method: kubeadm
Kubernetes: 1.19.2
Master & Nodes: Ubuntu 20.04.1 (Oracle Virutalbox)
Docker: 19.03.12
Calico: 3.16.1
Ingress : Bare-metal - 0.40.1
I want to access the Kubernetes dashboard from my laptop using ingress without proxy?
Can anyone help me with the steps... ( I tried multiple ways with the help of the internet... not sure where I am missing?)
Note: As per discussion forums I have added "hostNetwork: true" under the deployment section in ingress YAML to resolve "not working without host parameter" and commented "type: NodePort".
Updated info:
I have created ingress-controller as daemon instead of deployments/pod - this helps in accessing directly with worker IPs. (this is what I am expecting - but unable to access kubernetes dashboard as it is in different namespace)
Ingress yaml: this is running in default namespace
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: kdash-in-ns
port:
number: 443
kdash-in-ns yaml - svc with External Name
kind: Service
apiVersion: v1
metadata:
name: kdash-in-ns
namespace: default
spec:
type: ExternalName
externalName: kubernetes-dashboard.kubernetes-dashboard.svc.cluster.local
ports:
- name: https
port: 443
Below details about kdash-in-ns svc with ExternalName
dockeras#ubuntu3:~/simplek8s/kubernetes/yamls/ingress-demo$ kubectl describe svc kdash-in-ns
Name: kdash-in-ns
Namespace: default
Labels: <none>
Annotations: <none>
Selector: <none>
Type: ExternalName
IP:
External Name: kubernetes-dashboard.kubernetes-dashboard.svc.cluster.local
Port: https 443/TCP
TargetPort: 443/TCP
Endpoints: <none>
Session Affinity: None
Events: <none>
kubectl describe for the updated ingress route: in this i have ngnix - which is working fine (i guess both ingress and nginx are in same namespace.. getting error for dashboard - as it in different namespace (kubernetes-dasbhoard))
dockeras#ubuntu3:~$ kubectl describe ing nginx-ingress
Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
Name: nginx-ingress
Namespace: default
Address: 192.168.1.31,192.168.1.32
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
Host Path Backends
---- ---- --------
*
/nginx nginx-deploy-main:80 )
/foo kubernetes-dashboard:443 (<error: endpoints "kubernetes-dashboard" not found>)
/dashboard kdash-in-ns:443 (<error: endpoints "kdash-in-ns" not found>)
Annotations: kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /$2
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal CREATE 4m40s nginx-ingress-controller Ingress default/nginx-ingress
When I tried the same URLs in browser below are the responses (One of my worker iP - 192.168.1.31)
192.168.1.31/nginx - responds with nginx default page (pod - nginx-deploy-main)
192.168.1.31/foo - error page - 503 service temporarily Unavailable (default nginx)
192.168.1.31/dashboard - 504 Gateway Time-out (default nginx)
running svc, pods:
All Pods and svcs
If I understand correctly, you want to access kubernetes service (dashboard) from outside cluster. You may deploy metallb LoadBalancer and manage a pull of IPs from external cluster network, assigned to your cluster.
So, you can assign an IP and a LoadBalancer through which you will access your service. Below is an example for mssql server, but you can easily adapt it to your needs with dashboard:
apiVersion: v1
kind: Service
metadata:
name: sql-server-lb
namespace: database-server
annotations:
metallb.universe.tf/address-pool: default
spec:
selector:
app: sql-server
ports:
- port: 1433
targetPort: 1433
type: LoadBalancer
https://metallb.universe.tf/

endpoints “default-http-backend” not found in Ingress resource

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
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
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.
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
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>)
I tried following this doc steps and it worked fine:
https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/
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.
Create default-http-backend service in kube-system namespace and error will be gone.
See more: ngress-nginx-troubleshooting.