From 49cfb489930c814190db3310bfd7b5d6fe3f61eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=85=E8=BF=9B=E8=B6=85?= Date: Wed, 29 Dec 2021 19:45:36 +0800 Subject: [PATCH] [zh] synchronize translate local-debugging.md (#31111) * [zh] synchronize translate local-debugging.md * [zh] fix local-debugging.md chinese syntax --- .../local-debugging.md | 98 ++++++++++++------- 1 file changed, 61 insertions(+), 37 deletions(-) diff --git a/content/zh/docs/tasks/debug-application-cluster/local-debugging.md b/content/zh/docs/tasks/debug-application-cluster/local-debugging.md index 99bb4fc56f..aca2f2e7e8 100644 --- a/content/zh/docs/tasks/debug-application-cluster/local-debugging.md +++ b/content/zh/docs/tasks/debug-application-cluster/local-debugging.md @@ -10,21 +10,26 @@ content_type: task +{{% thirdparty-content %}} + + Kubernetes 应用程序通常由多个独立的服务组成,每个服务都在自己的容器中运行。 在远端的 Kubernetes 集群上开发和调试这些服务可能很麻烦,需要 [在运行的容器上打开 Shell](/zh/docs/tasks/debug-application-cluster/get-shell-running-container/), -然后在远端 Shell 中运行你所需的工具。 +以运行调试工具。 -`telepresence` 是一种工具,用于在本地轻松开发和调试服务,同时将服务代理到远程 Kubernetes 集群。 -使用 `telepresence` 可以为本地服务使用自定义工具(如调试器和 IDE), + +`telepresence` 是一个工具,用于简化本地开发和调试服务的过程,同时可以将服务代理到远程 Kubernetes 集群。 +`telepresence` 允许你使用使用自定义工具(例如:调试器 和 IDE)调式服务, 并提供对 Configmap、Secret 和远程集群上运行的服务的完全访问。 + @@ -35,31 +40,38 @@ This document describes using `telepresence` to develop and debug services runni * Kubernetes 集群安装完毕 * 配置好 `kubectl` 与集群交互 -* [Telepresence](https://www.telepresence.io/reference/install) 安装完毕 +* [Telepresence](https://www.telepresence.io/docs/latest/install/) 安装完毕 -打开终端,不带参数运行 `telepresence`,以打开 `telepresence` Shell。 -这个 Shell 在本地运行,使你可以完全访问本地文件系统。 + +## 从本机连接到远程 Kubernetes 集群 + +安装 `telepresence` 后,运行 `telepresence connect` 来启动它的守护进程并将本地工作站连接到远程 Kubernetes 集群。 + +``` +$ telepresence connect + +Launching Telepresence Daemon +... +Connected to context default (https://) +``` -`telepresence` Shell 的使用方式多种多样。 -例如,在你的笔记本电脑上写一个 Shell 脚本,然后直接在 Shell 中实时运行它。 -你也可以在远端 Shell 上执行此操作,但这样可能无法使用首选的代码编辑器,并且在容器终止时脚本将被删除。 + +你可以通过 curl 使用 Kubernetes 语法访问服务,例如:`curl -ik https://kubernetes.default` -使用 `--swap-deployment` 选项将现有部署与 Telepresence 代理交换。 -交换允许你在本地运行服务并能够连接到远端的 Kubernetes 集群。 -远端集群中的服务现在就可以访问本地运行的实例。 -要运行 telepresence 并带有 `--swap-deployment` 选项,请输入: +使用 `telepresence intercept $SERVICE_NAME --port $LOCAL_PORT:REMOTE_PORT` 命令创建一个 "拦截器" 用于重新路由远程服务流量。 -`telepresence --swap-deployment $DEPLOYMENT_NAME` +环境变量: + +- `$SERVICE_NAME` 是本地服务名称 +- `$LOCAL_PORT` 是服务在本地工作站上运行的端口 +- `$REMOTE_PORT` 是服务在集群中侦听的端口 -这里的 `$DEPLOYMENT_NAME` 是你现有的部署名称。 -运行此命令将生成 Shell。在该 Shell 中,启动你的服务。 -然后,你就可以在本地对源代码进行编辑、保存并能看到更改立即生效。 -你还可以在调试器或任何其他本地开发工具中运行服务。 +运行此命令会告诉 Telepresence 将远程流量发送到的本地服务,而不是远程 Kubernetes 集群中的服务中。 +在本地编辑保存服务源代码,并在访问远程应用时查看相应变更会立即生效。 +还可以使用调试器或任何其他本地开发工具运行本地服务。 + + + +## Telepresence 是如何工作的? + +Telepresence 会在远程集群中运行的现有应用程序容器旁边安装流量代理 sidecar。 +当它捕获进入 Pod 的所有流量请求时,不是将其转发到远程集群中的应用程序, +而是路由所有流量(当创建[全局拦截器](https://www.getambassador.io/docs/telepresence/latest/concepts/intercepts/#global-intercept)时) +或流量的一个子集(当创建[自定义拦截器](https://www.getambassador.io/docs/telepresence/latest/concepts/intercepts/#personal-intercept)时) +到本地开发环境。 ## {{% heading "whatsnext" %}} @@ -104,11 +132,7 @@ If you're interested in a hands-on tutorial, check out [this tutorial](https://c 如果你对实践教程感兴趣,请查看[本教程](https://cloud.google.com/community/tutorials/developing-services-with-k8s),其中介绍了在 Google Kubernetes Engine 上本地开发 Guestbook 应用程序。 -Telepresence 有[多种代理选项](https://www.telepresence.io/reference/methods),以满足你的各种情况。 - -要了解更多信息,请访问 [Telepresence 网站](https://www.telepresence.io)。 +如需进一步了解,请访问 [Telepresence 官方网站](https://www.telepresence.io)。