$telepresence intercept lsh-mcp-idp-cd --port 9090:9090--http-match=all --env-file ~/lsh-mcp-idp-cd-intercept.env
Flag--http-match has been deprecated,use--http-header
UsingDeployment lsh-mcp-idp-cd
intercepted
Intercept name : lsh-mcp-idp-cd
State:ACTIVEWorkload kind :DeploymentDestination:127.0.0.1:9090ServicePortIdentifier:9090VolumeMountError: sshfs is not installed on your local machine
Intercepting: matching all HTTP requests
PreviewURL: https://sad-thompson-7927.preview.edgestack.me
Layer5Hostname: lsh-mcp-idp-cd.default.svc.cluster.local
增加了一个名为 traffic-agent 的容器,正是该容器,负责拦截发送到该 pod 的流量,并负责转发。在 k8s 集群内执行以下命令,请求 lsh-mcp-idp-cd 服务:
$curl20.102.1.158:9090/version
再看本地代码,发现已经收到了请求:
以上就是全局拦截的实践部分,个人拦截 gan 兴趣的同学自己实践吧,另外关于个人拦截,似乎每个账号存在使用次数限制,超过次数后创建个人拦截器时会报错:
telepresence: error:Failed to establish intercept: intercept in error state AGENT_ERROR:You’ve reached your limit of personal intercepts available for your subscription.See usage and available plans at https://app.getambassador.io/cloud/subscriptions
See logs fordetails(1 error found):"/Users/xxx/Library/Logs/telepresence/daemon.log"See logs fordetails(13609 errors found):"/Users/xxx/Library/Logs/telepresence/connector.log"If you think you have encountered a bug, please run `telepresence gather-logs` and attach the telepresence_logs.zip to your github issue or create a new one: https://github.com/telepresenceio/telepresence/issues/new?template=Bug_report.md .
六、卸载
删除拦截器:执行后,会删除注入工作负载的 sidecar:
$telepresence leave lsh-mcp-idp-cd
删除 telepresence agents and manager,执行后清除所有 sidecar,以及 traffic-manager 控制器,并关闭本地 telepresence 的后台进程: