我正在尝试列出istio内部服务注册表中存在的服务列表。但是,这样做失败,更具体地说,服务条目添加了详细信息。有人知道istioctl
命令列出服务吗?
Ref- article
答案 0 :(得分:2)
有详细的文档page关于执行此操作的命令。
proxy-status命令可让您获得网格的概述。如果您怀疑自己的一辆小轿车没有收到配置或不同步,则代理状态将告诉您。
$ istioctl proxy-status PROXY CDS LDS EDS RDS PILOT VERSION details-v1-6dcc6fbb9d-wsjz4.default SYNCED SYNCED SYNCED SYNCED istio-pilot-75bdf98789-tfdvh 1.1.2 istio-egressgateway-c49694485-l9d5l.istio-system SYNCED SYNCED SYNCED NOT SENT istio-pilot-75bdf98789-tfdvh 1.1.2 istio-ingress-6458b8c98f-7ks48.istio-system SYNCED SYNCED SYNCED NOT SENT istio-pilot-75bdf98789-n2kqh 1.1.2 istio-ingressgateway-7d6874b48f-qxhn5.istio-system SYNCED SYNCED SYNCED SYNCED istio-pilot-75bdf98789-n2kqh 1.1.2 productpage-v1-6c886ff494-hm7zk.default SYNCED SYNCED SYNCED STALE istio-pilot-75bdf98789-n2kqh 1.1.2 ratings-v1-5d9ff497bb-gslng.default SYNCED SYNCED SYNCED SYNCED istio-pilot-75bdf98789-n2kqh 1.1.2 reviews-v1-55d4c455db-zjj2m.default SYNCED SYNCED SYNCED SYNCED istio-pilot-75bdf98789-n2kqh 1.1.2 reviews-v2-686bbb668-99j76.default SYNCED SYNCED SYNCED SYNCED istio-pilot-75bdf98789-tfdvh 1.1.2 reviews-v3-7b9b5fdfd6-4r52s.default SYNCED SYNCED SYNCED SYNCED istio-pilot-75bdf98789-n2kqh 1.1.2
如果此列表中缺少代理,则表示该代理当前未连接到Istiod实例,因此不会接收任何配置。
SYNCED
表示Envoy已确认Istiod已发送给它的最新配置。NOT SENT
表示Istiod尚未发送任何东西给Envoy。这通常是因为Istiod无法发送任何内容。STALE
表示Istiod已将更新发送给Envoy,但尚未收到确认。这通常表示Envoy和Istiod之间存在网络问题,或者Istio本身存在错误。
也有类似的命令istioctl proxy-config
,可用于查看如何配置给定的Envoy实例。有关更多详细信息,请参见同一文档page。
希望有帮助。
更新:
在试验中使用ServiceEntry
的情况下,有一个调试端点:
localhost:8080/debug/registryz
有关如何使用它的更多信息,请查看this文档页面。
示例:
kubectl exec $POD -c istio-proxy -- curl 'localhost:8080/debug/registryz' > service_registry
希望有帮助。
答案 1 :(得分:1)
我没有找到使用istioctl
以方便的形式获取Istio注册表内容的方法,但是可以使用稍微不同的方法来实现。
Piotr Malec是正确的(也请考虑对他的回答进行投票),Pilot的调试界面可以提供您在问题中提到的列表。可以使用任何Pod的特使边车向Istio Pilot发送请求。两个端口对请求均有效:15014和8080,并给出相同的结果。
在此示例中,我使用了飞行员自己的特使边车。我还在我的机器上使用jq从JSON响应中获取服务的名称。
想象一下,集群中有三个ServiceEntry
:
$ kubectl get serviceentry
NAME HOSTS LOCATION RESOLUTION AGE
httpbin [httpbin.org] DNS 18d
httpbin-com-ext [httpbin.org] MESH_EXTERNAL DNS 22d
wikipedia-org-se [wikipedia.org *.wikipedia.org] MESH_EXTERNAL NONE 22d
以下命令序列为我们提供了服务列表,包括ServiceEntry
对象定义的服务:
# create a shortcut to Istio Pilot pod
$ PILOT=$(kubectl get -A pods --selector=istio=pilot -o jsonpath='{.items[*].metadata.name}')
# Create shortcut to Istio Pilot namespace
$ PILOT_NS=$(kubectl get -A pods --selector=istio=pilot -o jsonpath='{.items[*].metadata.namespace}')
# Get the list of services in Istio mesh and filter their names using jq
$ kubectl exec $PILOT -n $PILOT_NS -c discovery -- curl -s 'localhost:15014/debug/registryz' | jq '.[].hostname'
# or
$ kubectl exec $PILOT -n $PILOT_NS -c istio-proxy -- curl -s 'localhost:15014/debug/registryz' | jq '.[].hostname'
输出:
(请注意最后几个条目。)
"ingress-nginx.ingress-nginx.svc.cluster.local"
"istio-citadel.istio-system.svc.cluster.local"
"istio-egressgateway.istio-system.svc.cluster.local"
"istio-galley.istio-system.svc.cluster.local"
"istio-ingressgateway.istio-system.svc.cluster.local"
"istio-pilot.istio-system.svc.cluster.local"
"istio-policy.istio-system.svc.cluster.local"
"istio-sidecar-injector.istio-system.svc.cluster.local"
"istio-telemetry.istio-system.svc.cluster.local"
"kube-dns.kube-system.svc.cluster.local"
"kubernetes.default.svc.cluster.local"
"kubernetes.test.svc.cluster.local"
"metrics-server.metrics.svc.cluster.local"
"productpage.default.svc.cluster.local"
"prometheus.istio-system.svc.cluster.local"
"ratings.default.svc.cluster.local"
"reviews.default.svc.cluster.local"
"httpbin.org"
"httpbin.org"
"wikipedia.org"
"*.wikipedia.org"
您可以在Istio github页面上找到有关调试处理程序的更多信息: