当前位置: 首页 > 工具软件 > telepresence > 使用案例 >

Manjaro 使用 Telepresence 2.4 版本连接 k8s

淳于新
2023-12-01

Manjaro 使用 Telepresence 2.4 版本连接 k8s

安装:

sudo curl -fL https://app.getambassador.io/download/tel2/linux/amd64/latest/telepresence -o /usr/local/bin/telepresence


sudo chmod a+x /usr/local/bin/telepresence

Telepresence 将您的本地工作站连接到远程 Kubernetes 集群。

$ telepresence connect
Launching Telepresence Root Daemon
Launching Telepresence User Daemon
Connected to context kubernetes-admin@kubernetes-dev (https://192.168.1.50:6443)

状态查看

$ telepresence status
Root Daemon: Running
  Version   : v2.4.2 (api 3)
  DNS       :
    Local IP        : 61.139.2.69
    Remote IP       : <nil>
    Exclude suffixes: [.arpa .com .io .net .org .ru]
    Include suffixes: []
    Timeout         : 4s
  Also Proxy: (0 subnets)
User Daemon: Running
  Version           : v2.4.2 (api 3)
  Ambassador Cloud  : Logged out
  Status            : Connected
  Kubernetes server : https://192.168.1.50:6443
  Kubernetes context: kubernetes-admin@kubernetes-dev
  Telepresence proxy: ON (networking to the cluster is enabled)
  Intercepts        : 0 total

代理服务

​ 多个端口,对于--port参数,请指定您的本地服务实例将在其上运行的端口。

$ telepresence  intercept flowable-api-service  --port 30811:30811
Using Deployment flowable-api-service
intercepted
    Intercept name         : flowable-api-service
    State                  : ACTIVE
    Workload kind          : Deployment
    Destination            : 127.0.0.1:30811
    Service Port Identifier: http
    Volume Mount Point     : /tmp/telfs-678146290
    Intercepting           : all TCP connections
Intercepting all traffic to your service. To route a subset of the traffic instead, use a personal intercept. You can enable personal intercepts by authenticating to the Ambassador Developer Control Plane with "telepresence login".

查看代理

$ telepresence list
flowable-api-service                     : intercepted
    Intercept name         : flowable-api-service
    State                  : ACTIVE
    Workload kind          : Deployment
    Destination            : 127.0.0.1:30811
    Service Port Identifier: http
    Volume Mount Point     : /tmp/telfs-678146290
    Intercepting           : all TCP connections

退出删除代理

$ telepresence leave  flowable-api-service

退出所有代理

 telepresence quit

代理到我的集群的出站流量

telepresence status 状态为Running

[yinxiulong@Manjaro ~]$ telepresence status
Root Daemon: Running
  Version   : v2.4.2 (api 3)
  DNS       :
    Local IP        : 61.139.2.69
    Remote IP       : <nil>
    Exclude suffixes: [.arpa .com .io .net .org .ru]
    Include suffixes: []
    Timeout         : 4s
  Also Proxy: (0 subnets)
User Daemon: Running
  Version           : v2.4.2 (api 3)
  Ambassador Cloud  : Logged in
  Status            : Connected
  Kubernetes server : https://192.168.1.50:6443
  Kubernetes context: kubernetes-admin@kubernetes-dev
  Telepresence proxy: ON (networking to the cluster is enabled)
  Intercepts        : 0 total

​ 我们可以通过k8s service 的服务名称加+ 命名空间+端口访问我们的服务

https://purchase-manage-front.default:30900/

终止客户端telepresence quit并尝试再次访问该服务,它将失败,因为流量不再从您的笔记本电脑代理。

以这种方式使用 Telepresence 时,必须<service name>.<namespace>在开始拦截之前使用命名空间限定的 DNS 名称 ( )访问服务。开始拦截后,只<service name>需要。在此处阅读有关这些 DNS 解析差异的更多信息。

 类似资料: