Knative pod http 请求

Knative pod http request

当我请求这个启动的服务器时:https://gist.github.com/Rasarts/1180479de480d7e36d6d7aef08babe59#file-server

我得到正确的回应:

{
  "args": {}, 
  "headers": {
    "Accept-Encoding": "gzip", 
    "Connection": "close", 
    "Host": "httpbin.org", 
    "User-Agent": "Go-http-client/1.1"
  }, 
  "origin": "", 
  "url": "https://httpbin.org/get"
}

但是当我向以这种方式创建的 minikube 上的服务器发出请求时: https://gist.github.com/Rasarts/1180479de480d7e36d6d7aef08babe59#file-serve-yaml

我收到错误:

ERROR: Get https://httpbin.org/get: EOF<nil>

如何从 kubernetes pod 发出 http 请求?

Knative 使用 Istio 而 Istio 默认情况下不允许出站流量到外部主机,例如 httpbin.org。这就是您的请求失败的原因。

关注this document to learn how to configure Knative (so that it configures Istio correctly) to make outbound connections. Or, you can directly configure the Istio by adding an egress policy: https://istio.io/docs/tasks/traffic-management/egress/