Kubernetes Ingress not resolving the service with hostname

4,952 views
Skip to first unread message

igu...@thoughtworks.com

unread,
Jul 2, 2018, 10:26:48 PM7/2/18
to Kubernetes user discussion and Q&A
Hi guys...
we are using https://kubernetes.github.io/ingress-nginx/ to setup the ingress controller and the ingress resource in our k8s cluster. But somehow the host is not pointing to our service. Can anyone help us with this? What are we missing here? Below is our app service and our ingress resource.

---
#My app service
---
apiVersion: v1
kind: Service
metadata:
name: app-svc
spec:
ports:
- port: 80
targetPort: 8000
protocol: TCP
name: http
selector:
app: app1

---
#My app Ingress resource
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: app-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: foo.bar.com
http:
paths:
- path: /
backend:
serviceName: app-svc
servicePort: 80

---
#Ingress controller service
---
kind: Service
apiVersion: v1
metadata:
name: ingress-nginx
labels:
app: ingress-nginx
spec:
externalTrafficPolicy: Local
type: LoadBalancer
selector:
app: ingress-nginx
ports:
- name: http
port: 80
targetPort: http
- name: https
port: 443
targetPort: https

---
#Ingress controller deployment
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-ingress-controller

spec:
replicas: 1
selector:
matchLabels:
app: ingress-nginx
template:
metadata:
labels:
app: ingress-nginx
annotations:
prometheus.io/port: '10254'
prometheus.io/scrape: 'true'
spec:
serviceAccountName: nginx-ingress-serviceaccount
containers:
- name: nginx-ingress-controller
image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.16.2
args:
- /nginx-ingress-controller
- --default-backend-service=$(POD_NAMESPACE)/default-http-backend
- --configmap=$(POD_NAMESPACE)/nginx-configuration
- --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services
- --udp-services-configmap=$(POD_NAMESPACE)/udp-services
- --publish-service=$(POD_NAMESPACE)/ingress-nginx
- --annotations-prefix=nginx.ingress.kubernetes.io
securityContext:
capabilities:
drop:
- ALL
add:
- NET_BIND_SERVICE
# www-data -> 33
runAsUser: 33
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
ports:
- name: http
containerPort: 80
- name: https
containerPort: 443
livenessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
readinessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 10254
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
---

Nginx Ingress Controller logs
----

203.14.59.150 - [203.14.59.150] - - [03/Jul/2018:01:11:30 +0000] "GET /healthz HTTP/1.1" 400 674 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36" 410 0.000 [] - - - - d0972809e3f7e250c78ea7abfb698361
203.14.59.150 - [203.14.59.150] - - [03/Jul/2018:01:11:30 +0000] "GET /favicon.ico HTTP/1.1" 400 674 "http://104.210.68.45:443/healthz" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36" 381 0.000 [] - - - - 3a92efee238219176f9f46750377dab7
203.14.59.150 - [203.14.59.150] - - [03/Jul/2018:01:12:05 +0000] "GET /healthz HTTP/1.1" 400 674 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36" 436 0.000 [] - - - - c5ffacbe48524412474ce4477f62aad3
203.14.59.150 - [203.14.59.150] - - [03/Jul/2018:01:12:05 +0000] "GET /favicon.ico HTTP/1.1" 400 674 "http://104.210.68.45:443/healthz" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36" 381 0.000 [] - - - - 4d66274f141ddd1e61b6598b975cefa8
66.240.205.34 - [66.240.205.34] - - [03/Jul/2018:01:26:54 +0000] "Gh0st\xAD\x00\x00\x00\xE0\x00\x00\x00x\x9CKS``\x98\xC3\xC0\xC0\xC0\x06\xC4\x8C@\xBCQ\x96\x81\x81\x09H\x07\xA7\x16\x95e&\xA7*\x04$&g+\x182\x94\xF6\xB000\xAC\xA8rc\x00\x01\x11\xA0\x82\x1F\x5C`&\x83\xC7K7\x86\x19\xE5n\x0C9\x95n\x0C;\x84\x0F3\xAC\xE8sch\xA8^\xCF4'J\x97\xA9\x82\xE30\xC3\x91h]&\x90\xF8\xCE\x97S\xCBA4L?2=\xE1\xC4\x92\x86\x0B@\xF5`\x0CT\x1F\xAE\xAF]" 400 174 "-" "-" 0 0.153 [] - - - - 2b33f216f091deaf25ed112ebb3aaa59
I0703 01:44:14.073004 5 controller.go:169] Configuration changes detected, backend reload required.
I0703 01:44:14.074615 5 event.go:218] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"bowerbird-ingress", UID:"9703bd3c-7e62-11e8-be8f-cabd38a493e4", APIVersion:"extensions", ResourceVersion:"440519", FieldPath:""}): type: 'Normal' reason: 'CREATE' Ingress default/bowerbird-ingress
I0703 01:44:14.176205 5 controller.go:179] Backend successfully reloaded.
I0703 01:44:23.453848 5 controller.go:169] Configuration changes detected, backend reload required.
I0703 01:44:23.629718 5 controller.go:179] Backend successfully reloaded.
I0703 01:44:26.787343 5 controller.go:169] Configuration changes detected, backend reload required.
I0703 01:44:26.889738 5 controller.go:179] Backend successfully reloaded.
I0703 01:44:41.931901 5 status.go:362] updating Ingress default/bowerbird-ingress status to [{104.210.68.45 }]
I0703 01:44:41.944368 5 event.go:218] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"bowerbird-ingress", UID:"9703bd3c-7e62-11e8-be8f-cabd38a493e4", APIVersion:"extensions", ResourceVersion:"440594", FieldPath:""}): type: 'Normal' reason: 'UPDATE' Ingress default/bowerbird-ingress
I0703 01:53:09.131272 5 controller.go:169] Configuration changes detected, backend reload required.
I0703 01:53:09.310406 5 controller.go:179] Backend successfully reloaded.
I0703 01:53:12.464746 5 controller.go:169] Configuration changes detected, backend reload required.
I0703 01:53:12.553642 5 controller.go:179] Backend successfully reloaded.

ale...@gmail.com

unread,
Jul 2, 2018, 10:55:07 PM7/2/18
to Kubernetes user discussion and Q&A
It seems you are sending https traffic to http port

igu...@thoughtworks.com

unread,
Jul 2, 2018, 11:01:25 PM7/2/18
to Kubernetes user discussion and Q&A
Thanks for your reply. Can you point out where do you this?

igu...@thoughtworks.com

unread,
Jul 2, 2018, 11:03:58 PM7/2/18
to Kubernetes user discussion and Q&A
On Tuesday, July 3, 2018 at 1:01:25 PM UTC+10, igu...@thoughtworks.com wrote:
> Thanks for your reply. Can you point out where do you this?

Sorry I mean where do you see this in the above configuration?

igu...@thoughtworks.com

unread,
Jul 3, 2018, 3:25:39 AM7/3/18
to Kubernetes user discussion and Q&A

I was able to solve it. I just needed to make an dns entry for the hostname in the hosts file. This did the trick. Rest everything was fine.

Reply all
Reply to author
Forward
0 new messages