sudo ktctl --namespace=default connect
Password:
2:21PM INF Connect Start At 284222:21PM INF Client address 192.168.51.191
2:21PM INF deploy shadow deployment kt-connect-daemon-ojbky in namespace default
2:21PM INF pod label: kt=kt-connect-daemon-ojbky
2:21PM INF pod: kt-connect-daemon-ojbky-6484749d95-2zqnl is running,but not ready
2:21PM INF pod: kt-connect-daemon-ojbky-6484749d95-2zqnl is running,but not ready
2:21PM INF pod: kt-connect-daemon-ojbky-6484749d95-2zqnl is running,but not ready
2:21PM INF Shadow pod: kt-connect-daemon-ojbky-6484749d95-2zqnl is ready.
2:21PM INF Fail to get pod cidr from node.Spec.PODCIDR, try to get with pod sample
Forwarding from 127.0.0.1:2222 -> 22Forwarding from [::1]:2222 -> 222:21PM INF port-forward start at pid: 28424Handling connection for2222Warning: Permanently added '[127.0.0.1]:2222'(ECDSA) to the list of known hosts.
client: Connected.
2:21PM INF vpn(sshuttle) start at pid: 284282:21PM INF KT proxy start successful
client: warning: closed channel 1 got cmd=TCP_STOP_SENDING len=0server: warning: closed channel 1 got cmd=TCP_EOF len=0
當 connection 建立好後可以在 remote 到建立了一個 tunnel 的 pod ,這個 pod 專門用來跟 local端進行 vpn/socks5 的連接方式(預設vpn)
1
2
3
4
kubectl get pod -A
NAMESPACE NAME READY STATUS RESTARTS AGE
default kt-connect-daemon-ojbky-6484749d95-2zqnl 1/1 Running 0 60s
...
kubectl get svc,deploy
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 24m
service/nginx ClusterIP 10.99.58.138 <none> 80/TCP 4m25s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/kt-connect-daemon-ojbky 1/1 11 2m48s
deployment.apps/nginx 1/1 11 4m34s
curl with nginx pod ip in localhost
我們先在本地 透過 pod ip 存取 nginx 服務 看看服務是否正常
1
2
3
4
5
6
curl 10.32.0.5:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
...
curl with nginx service ip
接著在本地透過 nginx service virtual ip 存取 nginx 服務 看看服務是否正常
1
2
3
4
5
6
curl 10.99.58.138:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
...
curl with nginx service DNS name
最後在本地透過 nginx cluster DNS 存取 nginx 服務 測試 服務是否正常。
1
2
3
4
5
6
7
8
curl nginx.default.svc.cluster.local
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {...
sudo ktctl exchange nginx --expose 80:80
2:37PM INF 'KT Connect' not runing, you can only access local app from cluster
2:37PM INF Client address 192.168.51.191
2:37PM INF deploy shadow deployment nginx-kt-rjulr in namespace default
2:37PM INF pod label: kt=nginx-kt-rjulr
2:37PM INF pod: nginx-kt-rjulr-7b478cd45d-c2xw5 is running,but not ready
2:37PM INF pod: nginx-kt-rjulr-7b478cd45d-c2xw5 is running,but not ready
2:37PM INF pod: nginx-kt-rjulr-7b478cd45d-c2xw5 is running,but not ready
2:37PM INF Shadow pod: nginx-kt-rjulr-7b478cd45d-c2xw5 is ready.
2:37PM INF create exchange shadow nginx-kt-rjulr in namespace default
2:37PM INF scale deployment nginx to 02:37PM INF * nginx (0 replicas) success
2:37PM INF remote 10.32.0.4 forward to local 80:80
Forwarding from 127.0.0.1:2204 -> 22Forwarding from [::1]:2204 -> 222:37PM INF exchange port forward to local start at pid: 309152:37PM INF redirect request from pod 10.32.0.4 22 to 127.0.0.1:2204 starting
Handling connection for2204Warning: Permanently added '[127.0.0.1]:2204'(ECDSA) to the list of known hosts.
2:37PM INF ssh remote port-forward start at pid: 30917
curl with nginx service in remote
在 remote 環境測試請求 nginx service 能不能將 traffic 導流到 localhost 上。