使用 Istio sidecar 从多容器 pod 调用服务

Invoke a service from a multi container pod with a Istio sidecar

我有两个 pods,有两个容器。在每个 pod 中,一个容器是 Istio sidecar-proxy (Envoy)

$ kubectl get pods
NAME                                     READY   STATUS    RESTARTS   AGE
helloserver-744bf7487-m426t              2/2     Running   0          14h
helloworld-deployment-7dfc7db54d-d4ddf   2/2     Running   0          15h

我在 pod helloworld-deployment-7dfc7db54d-d4ddf 中有一个 helloworld 服务。我想从 helloserver-744bf7487-m426t pod 调用该服务。

$kubectl get services
NAME                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
helloserver          NodePort    10.100.244.253   <none>        9095:30161/TCP   13h
helloworld-service   NodePort    10.111.142.95    <none>        9095:32685/TCP   14h

我用了命令,

$ kubectl exec -it helloserver-744bf7487-m426t -c helloserver -- \bin\sh\
> curl http://helloworld-service:9095/helloworld/

但它给出了一个错误,

OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "exec: \"binshcurl\": executable file not found in $PATH": unknown
command terminated with exit code 126

如何调用此服务?

只需使用以下命令:

kubectl exec -it helloserver-744bf7487-m426t -c helloserver -- curl http://helloworld-service:9095/helloworld/