I created the following ingress for my service on GKE (it's part of a helm chart with variables)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: TestIngress
annotations:
kubernetes.io/ingress.class: "gce"
kubernetes.io/ingress.global-static-ip-name: {{ $ingressExternalStaticIpName }}
spec:
rules:
- host: "web.frontend.com"
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: {{ $webServiceName }}
port:
number: 80
- host: "grpc.frontend.com"
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: {{ $grpcServiceName }}
port:
number: 80
defaultBackend:
service:
name: {{ $grpcServiceName }}
port:
number: 80
I modified the /etc/hosts to make web.frontend.com point to the static ip. then I ran
curl web.frontend.com
I realize the grpc service was responding to my request. I read this doc https://kubernetes.io/docs/concepts/services-networking/ingress/ and it saids it routes based on the Host header?? that sounds a bit weird since I assumed host meant the url. so I tried
curl -H "Host:web.frontend.com:80" web.frontend.com
and still got response from grpc server
How exactly does ingress host work, or am I doing something wrong?
Tried it the next day and it's working. The issue might be due to google caching