I would like to know, which are the endpoints correctly configured for a certain ingress.
For instance I have the following ingress:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: dictionary
spec:
tls:
- hosts:
- dictionary.juan.com
secretName: microsyn-secret
backend:
serviceName: microsyn
servicePort: 8080
rules:
- host: dictionary.juan.com
http:
paths:
- path: /synonyms/*
backend:
serviceName: microsyn
servicePort: 8080
that is working the following service:
apiVersion: v1
kind: Service
metadata:
name: microsyn
spec:
ports:
- port: 8080
targetPort: 8080
protocol: TCP
name: http
selector:
app: microsyn
This service is exposing this deployment:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: microsyn
spec:
replicas: 1
selector:
matchLabels:
app: microsyn
template:
metadata:
labels:
app: microsyn
spec:
containers:
- name: microsyn
image: microsynonyms
imagePullPolicy: Never
ports:
- containerPort: 8080
The application is a nodejs app listening on port 8080, that says hello for path '/', in a docker image I just created locally, that's the reason it has a imagePullPolicy: Never, it is just for testing purposes and learn how to create an ingress.
So I created the ingress from nginx-ingress and it is up and running with a nodeport for local environment test, later I will take it to a deployment with load balancer:
https://github.com/nginxinc/kubernetes-ingress/tree/master/examples/complete-example
So I do the following:
minikube service list
|---------------|----------------------|--------------------------------| | NAMESPACE | NAME | URL | |---------------|----------------------|--------------------------------| | default | kubernetes | No node port | | default | microsyn | No node port | | kube-system | default-http-backend | http://192.168.99.100:30001 | | kube-system | kube-dns | No node port | | kube-system | kubernetes-dashboard | http://192.168.99.100:30000 | | nginx-ingress | nginx-ingress | http://192.168.99.100:31253 | | | | http://192.168.99.100:31229 | |---------------|----------------------|--------------------------------|
Brilliant I can do:
curl http://192.168.99.100:31253/synonyms
But then I get a:
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.15.2</center>
</body>
</html>
So the only nginx I have is the one from this minikube, and it is working fine. But I cannot see which are the endpoints configured for this ingress...
I see the logs that says:
2018/08/11 16:07:05 [notice] 117#117: signal process started
I0811 16:07:05.313037 1 event.go:218] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"dictionary", UID:"9728e826-9d80-11e8-9caa-0800270091d8", APIVersion:"extensions", ResourceVersion:"57014", FieldPath:""}): type: 'Normal' reason: 'AddedOrUpdated' Configuration for default/dictionary was added or updated
W0811 16:15:05.826537 1 reflector.go:341] github.com/nginxinc/kubernetes-ingress/nginx-controller/controller/controller.go:413: watch of *v1.ConfigMap ended with: too old resource version: 56348 (56655)
So that means that the dictionary ingress has being processed without errors.
But then Why I get a 404?
Where can I see the endpoints that are configured for this ingress??
I would like to run a command that says nginx --> which endpoints are you listening to?
But then Why I get a 404?
Ingress resources -- or certainly the one you showed in your question -- use virtual-host routing, so one must set the host:
header when interacting with that URL:
curl -H 'host: dictionary.juan.com' http://192.168.99.100:31253/synonyms/something
I would have to look up the path:
syntax to know if /synonyms/*
matches /synonyms
, which is why I included the slash and extra content in curl
.
For interacting with it in a non-curl
way, you can either change the host:
in the Ingress
to temporarily be 192.168.99.100 or use dnsmasq to create a local nameserver where you can override dictionary.juan.com
to always return 192.168.99.100
, and then Chrome will send the correct host:
header by itself.
Where can I see the endpoints that are configured for this ingress??
The question is slightly inaccurate in that Endpoint
is a formal resource, and not related to an Ingress
, but the answer is:
kubectl get endpoints microsyn
I would like to run a command that says nginx --> which endpoints are you listening to?
First, look up the name of the nginx-ingress Pod (any one of them should do, if you have multiple), and then look at the nginx.conf
from the Pod to know exactly what rules it has converted the Ingress
resource into:
kubectl exec $ingress_pod cat /etc/nginx/nginx.conf