Reputation: 26182
I have simple ingress for virtual hosting:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-access
spec:
rules:
- host: service1.domain.com
http:
paths:
- backend:
serviceName: service1
servicePort: 80
- host: service2.domain.com
http:
paths:
- backend:
serviceName: service2
servicePort: 80
Services service1 and servcie2 have definitions like:
apiVersion: v1
kind: Service
metadata:
name: service1
labels:
chart: "chart"
spec:
type: ClusterIP # LoadBalancer
ports:
- port: 80
targetPort: 80
protocol: TCP
name: web
selector:
app: service1
If I deploy services with type ClusterIP
they don't work, ingress responds with error:
Error: Server Error
The server encountered a temporary error and could not complete your request.
Please try again in 30 seconds.
Then I change type of one of the services to LoadBalancer
, it gets external IP and I can access it using this external IP, and also I can access it though ingress (using host name service1.domain.com
)
If I try to access service2 (service2.domain.com - which still has type ClusterIP
) ingress responds with:
default backend - 404
If I change servcice2 type to LoadBalancer
it starts to work through ingress.
I think that ingress should work with ClusterIP
services, because LoadBalancer service type assigns external IP, which is not needed at all, and if I get it correctly gcloud ingress resource by default should use its own load loadbalancer.
So what is wrong with the setup?
Upvotes: 1
Views: 349
Reputation: 26182
https://github.com/kubernetes/ingress-gce/blob/master/docs/faq/gce.md
It seems that the correct answer is that Ingress requires NodePort to work with, so services should have NodePort
type for this case.
Upvotes: 2