Below given the config, I am trying to deploy on Google Kubernetes Engine. But after deployment, I can't access the service on the ingress external IP.
I can access the service if I do:
$ kubectl exec POD_NAME
# curl GET localhost:6078/todos
But I can't access it through ingress. GKE UI show errors like:
OR
Even though the backend pod is up and running.
I believe there is something wrong with the service.
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: todo
labels:
app: todo
spec:
replicas: 1
selector:
matchLabels:
app: todo
template:
metadata:
labels:
app: todo
spec:
containers:
- image: eu.gcr.io/xxxxx/todo
name: todo
ports:
- containerPort: 6078
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: todo
labels:
app: todo
spec:
type: NodePort
ports:
- port: 6078
selector:
app: todo
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: todo-ingress
spec:
rules:
- http:
paths:
- path: /*
backend:
serviceName: todo
servicePort: 6078
Hard to tell without knowing what 'todo' does, but there's a few things:
There's an indentation error on the Ingress definition. I'm not sure if it's typo or it didn't get applied:
Instead, it should be something:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: todo-ingress
spec:
rules:
- http:
paths:
- path: /*
backend:
serviceName: todo
servicePort: 6078
If you really want /*
with no host
then the default backend is overriding you, since it's the last rule in the nginx.conf
, so you might as well configure:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: todo-ingress
spec:
backend:
serviceName: todo
servicePort: 6078
Is your service binding to 0.0.0.0
and not 127.0.0.1
. Listening to on 127.0.0.1
will cause it to serve locally in the pod but not to any service outside.