kubernetes - 无法访问用完 istio 服务网格的 api
问题描述
我正在使用 minikube 运行服务网格,并尝试使用 fortio 访问在 minikube 之外运行的 api:
kubectl exec "$FORTIO_POD" -c fortio -- /usr/bin/fortio load -c 1 -qps 0 -n 1 -loglevel debug http://localhost:3000
但这给了我错误:
dial tcp 127.0.0.1:3000: connect: connection refused
下面是我创建的服务入口和destinationRule 对象:
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
name: localhost
spec:
hosts:
- localhost
location: MESH_EXTERNAL
ports:
- number: 3000
name: http
protocol: HTTP
resolution: STATIC
endpoints:
- address: 127.0.0.1
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: localhost
spec:
host: localhost
trafficPolicy:
tls:
mode: DISABLE
sni: localhost.local
解决方案
我相信您在这里尝试的是从 Minikube 中访问托管在主机系统中的 API。您不能期望仅通过在 istio 中创建 localhost 服务条目来连接到主机系统。对于 minikube 主机访问,您需要使用host.minikube.internal
参考这个链接: https ://minikube.sigs.k8s.io/docs/handbook/host-access/
推荐阅读
- mysql - MySQL 每小时百分比
- plot - Julia - 使用 GraphPlots 绘制最小生成树
- react-native - 如何使用 Wix React Native Navigation 在 RCTRootView 中设置 initialProperties?
- javascript - 仅适用于三个元素中的两个
- c++ - 如何定义模板类模板友元函数,其参数之一是模板类主体之外的依赖名称?
- .net-core - 添加 NuGet 源时,Gitlab 管道遇到错误
- bash - 自动响应 npm/npx 命令行安装中的提示
- python - tkinter 居中两个或多个小部件
- javascript - 向下滚动网站后显示 div
- php - 如何在 bash / php 脚本中执行命令?