首页 > 解决方案 > 使用 Istio sidecar 从多容器 pod 调用服务

问题描述

我有两个带有两个容器的豆荚。在每个 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 服务helloworld-deployment-7dfc7db54d-d4ddf。我想从helloserver-744bf7487-m426tpod 调用该服务。

$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

如何调用该服务?

标签: dockerproxykubernetesistioenvoyproxy

解决方案


只需使用以下命令:

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

推荐阅读