如何在GKE上访问端口转发服务

时间:2019-01-02 08:02:19

标签: kubernetes google-cloud-platform google-kubernetes-engine istio

我是gke / gcp的新手,这是我的第一个项目。 我正在使用https://istio.io/docs/setup/kubernetes/quick-start-gke-dm/教程设置istio。

我使用以下内容公开了grafana,如帖子中所示:
kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=grafana -o jsonpath='{.items[0].metadata.name}') 3000:3000 &

卷曲http://localhost:3000/dashboard/db/istio-dashboard 在终端上给我http页面,以便通过执行kubectl cluster-info后获得的主ip从浏览器访问它。

http:// {master-ip}:3000 / dashboard / db / istio-dashboard无法访问。

如何在gke上使用port-forward访问服务?

2 个答案:

答案 0 :(得分:2)

首先获取Pod的名称

$ kubectl get pod

,然后使用port-forward命令。

$ kubectl port-forward <pod-name> 3000:3000

它对我有用,我已经从这个nice网站上找到了它,并详细说明了如何进行。希望它会有用。

答案 1 :(得分:0)

curl命令返回什么(确切的)http页面?这两个文档[1]&[2]都建议在设置通往Grafana的隧道后在浏览器中使用url(带有localhost):http://localhost:3000/dashboard/db/istio-dashboard

或者,您是否尝试过使用istio-ingressgateway IP地址?

[1] https://github.com/GoogleCloudPlatform/gke-istio-telemetry-demo#view-grafana-ui

[2] https://istio.io/docs/setup/kubernetes/quick-start-gke-dm/#grafana