2

我已按照本指南https://knative.dev/docs/serving/cluster-local-route/使服务集群本地化。

我正在尝试使用 curl 命令从群集内的另一个服务访问该服务,但我总是遇到无法解决主机错误。

我尝试使用 curl helloworld-default.svc.clustercurl -H "Host: helloworld-go.default.svc.cluster " http://< cluster_ip > 命令发出请求。

我错过了什么?我是否需要对 Istio virtualService 进行任何配置才能使其正常工作?(我在 GKE 中运行 Knative)

4

1 回答 1

1

I think you are missing the .local and it should work.

curl -H "Host: helloworld-go.default.svc.cluster.local" http://< cluster_ip > 

But you should be able to drop the ClusterIP entirely as you are making the request from within the cluster. Basically execute:

curl helloworld-go.default.svc.cluster.local

The DNS helloworld-go.default.svc.cluster.local will be resolved by the Kubernetes DNS resolution mechanism.


It's important to specify the HOST header only on ingress traffic (public traffic entering into private traffic).

Details: The Knative Service creates a Route CRD, which creates a ClusterIngress which will be picked up by a controller (by default istio-network) to configure the Ingress Gateway (using another CRD in istio's case VirtualService). Ingress Gateways routing is based on the HOST header.

于 2019-10-07T10:56:43.610 回答