https://rdc-incubator.github.io/kt-docs/#/
https://alibaba.github.io/kt-connect/#/zh-cn/
https://github.com/alibaba/kt-connect
https://my.oschina.net/u/4494662/blog/4667485
https://developer.aliyun.com/article/751321?scm=20140722.184.2.173
权限:
# permissions for ktctl command
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: kt:ns:dev
rules:
- apiGroups:
- ""
resources:
- pods
- pods/exec
- pods/portforward
- pods/proxy
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- configmaps
- services
- services/proxy
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- events
- namespaces/status
- pods/status
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- namespaces
- nodes
verbs:
- get
- list
- watch
- apiGroups:
- apps
resources:
- deployments
- deployments/rollback
- deployments/scale
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
- apiGroups:
- extensions
resources:
- deployments
- deployments/rollback
- deployments/scale
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
[root@liwm .kube]# ktctl connect --method=vpn
12:05AM INF Connect Start At 485
12:05AM INF Client address 192.168.61.150
12:05AM INF deploy shadow deployment kt-connect-daemon-hwvyz in namespace default
12:05AM INF pod label: kt=kt-connect-daemon-hwvyz
12:05AM INF pod: kt-connect-daemon-hwvyz-7c9c885f97-5vwdq is running,but not ready
12:05AM INF pod: kt-connect-daemon-hwvyz-7c9c885f97-5vwdq is running,but not ready
12:05AM INF Shadow pod: kt-connect-daemon-hwvyz-7c9c885f97-5vwdq is ready.
Forwarding from 127.0.0.1:2222 -> 22
Forwarding from [::1]:2222 -> 22
12:05AM INF port-forward start at pid: 500
Traceback (most recent call last):
File "/usr/bin/sshuttle", line 5, in <module>
from sshuttle.cmdline import main
File "/usr/lib/python2.7/site-packages/sshuttle/cmdline.py", line 5, in <module>
import sshuttle.client as client
File "/usr/lib/python2.7/site-packages/sshuttle/client.py", line 302
assert(not re.search(rb'[^-\w\.]', hostname))
^
SyntaxError: invalid syntax
12:05AM INF vpn(sshuttle) start at pid: 514
12:05AM INF KT proxy start successful
12:05AM INF vpn(sshuttle) finished
#
[root@UR-20210425NAMA home]# ktctl --debug --image=192.168.13.79:6278/base-image/kt-connect-shadow --namespace=ur-ks-test connect --method=socks5
10:17AM INF Connect Start At 3390
10:17AM INF Client address 10.0.51.172
10:17AM INF deploy shadow deployment kt-connect-daemon-baxis in namespace ur-ks-test
10:17AM INF pod label: kt=kt-connect-daemon-baxis
10:17AM INF pod: kt-connect-daemon-baxis-6bb69548c-kc96j is running,but not ready
10:17AM INF pod: kt-connect-daemon-baxis-6bb69548c-kc96j is running,but not ready
10:17AM INF pod: kt-connect-daemon-baxis-6bb69548c-kc96j is running,but not ready
10:17AM INF pod: kt-connect-daemon-baxis-6bb69548c-kc96j is running,but not ready
10:17AM INF Shadow pod: kt-connect-daemon-baxis-6bb69548c-kc96j is ready.
10:17AM DBG Child, os.Args = [ktctl --debug --image=192.168.13.79:6278/base-image/kt-connect-shadow --namespace=ur-ks-test connect --method=socks5]
10:17AM DBG Child, cmd.Args = [kubectl --kubeconfig=/root/.kube/config -n ur-ks-test port-forward kt-connect-daemon-baxis-6bb69548c-kc96j 2222:22]
Forwarding from 127.0.0.1:2222 -> 22
Forwarding from [::1]:2222 -> 22
10:17AM INF port-forward start at pid: 3411
10:17AM INF ==============================================================
10:17AM INF Start SOCKS5 Proxy: export http_proxy=socks5://127.0.0.1:2223
10:17AM INF ==============================================================
10:17AM DBG Child, os.Args = [ktctl --debug --image=192.168.13.79:6278/base-image/kt-connect-shadow --namespace=ur-ks-test connect --method=socks5]
10:17AM DBG Child, cmd.Args = [ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -i /root/.kt_id_rsa -D 2223 root@127.0.0.1 -p2222 sh loop.sh]
Handling connection for 2222
Warning: Permanently added '[127.0.0.1]:2222' (ECDSA) to the list of known hosts.
10:17AM INF vpn(ssh) start at pid: 3432
10:17AM INF KT proxy start successful