knative - 如何在 Knative 中从一个服务向另一个服务发出集群本地请求?
问题描述
我已按照本指南https://knative.dev/docs/serving/cluster-local-route/使服务集群本地化。
我正在尝试使用 curl 命令从群集内的另一个服务访问该服务,但我总是遇到无法解决主机错误。
我尝试使用 curl helloworld-default.svc.cluster和curl -H "Host: helloworld-go.default.svc.cluster " http://< cluster_ip > 命令发出请求。
我错过了什么?我是否需要对 Istio virtualService 进行任何配置才能使其正常工作?(我在 GKE 中运行 Knative)
解决方案
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.
推荐阅读
- javascript - 我应该声明什么值类型的对象变量
- java - JAXB:从绑定文件生成 javadoc
- python - 如何用python转置和自动填充数据框?
- php - open_basedir | ISPManager 试图将其关闭或将其设置为“无”
- dart - 更改 DataTable 行和列的颜色
- php - CakePHP:数据库连接“Mysql”丢失,或无法创建
- javascript - 我想从后端呈现动态内容,该后端在本机反应中具有 html 标签
- c# - 列出存储在 C# 中 System.Security.Claims.ClaimTypes 中的所有声明类型
- c# - C# Regex - match a substring in a filename
- java - 在 tasklet 中退出 Spring Batch Job