首页 > 解决方案 > 无法访问用完 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

标签: kubernetesproxyistioservicemesh

解决方案


我相信您在这里尝试的是从 Minikube 中访问托管在主机系统中的 API。您不能期望仅通过在 istio 中创建 localhost 服务条目来连接到主机系统。对于 minikube 主机访问,您需要使用host.minikube.internal

参考这个链接: https ://minikube.sigs.k8s.io/docs/handbook/host-access/


推荐阅读