首页
视频
资源
登录
原
Kubernetes Telepresence 本地上云工具
5571
人阅读
2022/8/4 17:18
总访问:
2645556
评论:
0
收藏:
0
手机
分类:
容器编排
![](https://img.tnblog.net/arcimg/hb/5128661e2e2544be971cf584173a34bf.png) >#Kubernetes Telepresence 本地上云工具 [TOC] tn2>简介:它可以让集群中的环境可以在本地访问。 同样的也可以使本地开发的应用替换某个集群上的应用,使请求流量访问到本地。 ## Windows本地安装 tn2>用管理员打开Powershell ```bash # 下载最新的包 curl -fL https://app.getambassador.io/download/tel2/windows/amd64/latest/telepresence.zip -o telepresence.zip # 解压 Expand-Archive -Path telepresence.zip Remove-Item 'telepresence.zip' cd telepresence # 安装telepresence Set-ExecutionPolicy Bypass -Scope Process .\install-telepresence.ps1 # 删除下载的zip包 cd .. Remove-Item telepresence ``` tn2>然后重新打开一个新的Powershell进行登录,验证安装情况。 ```bash telepresence ``` ![](https://img.tnblog.net/arcimg/hb/7b016977044f418792a799fb575f7da9.png) tn>更多环境安装请参考:https://www.telepresence.io/docs/latest/install/ ##集群环境安装 tn2>接下来我们需要在集群中安装telepresence,方便控制我们的流量。 ```bash helm repo add datawire https://app.getambassador.io helm repo update kubectl create namespace ambassador helm install traffic-manager --namespace ambassador datawire/telepresence ``` tn2>如果想最小化用户管理,可以添加如下的权限进行设置。(如果不想这样也是没关系的,可以跳过下面的步骤) ```bash vim telepresenceRBAC.yaml ``` ```yaml --- apiVersion: v1 kind: ServiceAccount metadata: name: tp-user namespace: ambassador --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: telepresence-role rules: - apiGroups: [""] resources: ["pods/log"] verbs: ["get"] - apiGroups: [""] resources: ["pods"] verbs: ["list"] - apiGroups: ["apps"] resources: ["deployments", "replicasets", "statefulsets"] verbs: ["get", "list", "watch"] - apiGroups: [""] resources: ["namespaces", "services"] verbs: ["get", "list", "watch"] - apiGroups: [""] resources: ["pods/portforward"] verbs: ["create"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: telepresence-rolebinding subjects: - name: tp-user kind: ServiceAccount namespace: ambassador roleRef: apiGroup: rbac.authorization.k8s.io name: telepresence-role kind: ClusterRole ``` ```bash kubectl apply -f telepresenceRBAC.yaml ``` tn2>查看`tp-user`用户token,并创建相关的kubeconfig. ```bash kubectl get secrets -n ambassador kubectl -n ambassador describe secrets tp-user-token-72hkg ``` ![](https://img.tnblog.net/arcimg/hb/6f78c86ab1bb4de193fa016c03b91456.png) ```bash mkdir telepresence cd telepresence cp ~/.kube/config . vim config ``` ```yaml apiVersion: v1 clusters: - cluster: certificate-authority-data: xx server: https://xxxxx:xxxxx name: kubernetes contexts: - context: cluster: kubernetes user: tp-user name: tp-user current-context: tp-user kind: Config preferences: {} users: - name: tp-user user: token: eyJhbGciOiJSUzI1NiIsImtpZCI6IjB2REZjcFF6eW9SSHdid1UtTlRSaG5TUm4teFZMX3h5Y3NqVTJtVkdNMk0ifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJhbWJhc3NhZG9yIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6InRwLXVzZXItdG9rZW4tc2g2dnAiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoidHAtdXNlciIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6ImFhNmFiMzVmLTE1ZDQtNGE3Zi04NGYzLTRkOTkyMmJhODQ0NyIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDphbWJhc3NhZG9yOnRwLXVzZXIifQ.leUMyrh6GZUNUWwYnBf6-jfUDwTb_N5a5jk866Q9sCuBHs8p4jwwRDq6sTdE1MkhiIWpDx-ZTX1ofcoBY2sn-CdzQZ2ifFTApMUT7yA5XJAoMppBWPnAF7E7BYR0n0MKdoQVdN_v6WjJEGx6_Bos1dhaQyFBJ2rVGIeZRokyK-S1nV81wM4Hg6AqdQWoUwGH5uS_IAnnD62E6HW6PzA9MSpLK3codZguVEvXKHLcOM_StDW-RW11Le4iowZBVLYX1jnmyatXoAEisBUV3uzcaFAdeV09lwVLNLBv9kB0VP19vNkMCOQlQ-36tnbhEvgtLTYcQumCVLT_j1ursZPm5w ``` tn2>这样我们的kubeconfig就创建好了。 ## 本地连接 tn2>我们可以直接通过如下命令来连接到我们的集群中。 ```bash telepresence connect ``` ![](https://img.tnblog.net/arcimg/hb/a27cf919c14b4baab84407e2e89151db.png) tn2>测试访问`default`名称空间下的`kubernetes`服务。 ![](https://img.tnblog.net/arcimg/hb/8e8b4afc0e2f4321860822b4aaba3c78.png) tn2>当然我们还可以访问集群中的其他服务。 如果想使用我们指定用户的kubeconfig的话需要加`--kubeconfig`参数。 ```bash telepresence connect --kubeconfig ./config ``` tn2>然后我们想断开连接的话可以执行如下命令。 ```bash telepresence quit ``` ![](https://img.tnblog.net/arcimg/hb/5dfe613d04fd448cb95e760ee2d1dd50.png) ## 本机应用映射到集群中 tn2>本地的网站应用在9090开放的端口,集群中对应的myserver服务9090端口将会导入流量到本地。 ```bash telepresence --swap-deployment myserver --expose 9090 ``` tn>更多请参考:https://www.telepresence.io/docs/latest/install/migrate-from-legacy/
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739
👈{{preArticle.title}}
👉{{nextArticle.title}}
评价
{{titleitem}}
{{titleitem}}
{{item.content}}
{{titleitem}}
{{titleitem}}
{{item.content}}
尘叶心繁
这一世以无限游戏为使命!
博主信息
排名
6
文章
6
粉丝
16
评论
8
文章类别
.net后台框架
171篇
linux
17篇
linux中cve
1篇
windows中cve
0篇
资源分享
10篇
Win32
3篇
前端
28篇
传说中的c
4篇
Xamarin
9篇
docker
15篇
容器编排
101篇
grpc
4篇
Go
15篇
yaml模板
1篇
理论
2篇
更多
Sqlserver
4篇
云产品
39篇
git
3篇
Unity
1篇
考证
2篇
RabbitMq
23篇
Harbor
1篇
Ansible
8篇
Jenkins
17篇
Vue
1篇
Ids4
18篇
istio
1篇
架构
2篇
网络
7篇
windbg
4篇
AI
18篇
threejs
2篇
人物
1篇
嵌入式
3篇
python
13篇
HuggingFace
8篇
pytorch
9篇
opencv
6篇
Halcon
4篇
最新文章
最新评价
{{item.articleTitle}}
{{item.blogName}}
:
{{item.content}}
关于我们
ICP备案 :
渝ICP备18016597号-1
网站信息:
2018-2024
TNBLOG.NET
技术交流:
群号656732739
联系我们:
contact@tnblog.net
欢迎加群
欢迎加群交流技术