Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows环境下,CIDR子网掩码32时,route路由规则失效 #447

Open
key9527 opened this issue Aug 28, 2023 · 2 comments
Open

windows环境下,CIDR子网掩码32时,route路由规则失效 #447

key9527 opened this issue Aug 28, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@key9527
Copy link

key9527 commented Aug 28, 2023

Describe the bug
当集群里的service cidr,经过kt过滤后,输出如10.102.250.70/32时,kt生成的route规则失效

Log
KT-LOG
PS C:\Users\PC> ktctl connect --context pro 5:16PM INF Using cluster context pro (aio-pro) 5:16PM INF KtConnect 0.3.7 start at 29112 (windows amd64) 5:16PM INF Fetching cluster time ... 5:16PM INF Using tun2socks mode 5:16PM INF Successful create config map kt-connect-shadow-auonm 5:16PM INF Deploying shadow pod kt-connect-shadow-auonm in namespace default 5:16PM INF Waiting for pod kt-connect-shadow-auonm ... 5:16PM INF Pod kt-connect-shadow-auonm is ready 5:16PM INF Port forward local:32947 -> pod kt-connect-shadow-auonm:22 established 5:16PM INF Socks proxy established 2023/08/28 17:16:20 Using existing driver 0.14 2023/08/28 17:16:20 Creating adapter 5:16PM INF Tun device KtConnectTunnel is ready 5:16PM INF Adding route to 10.109.0.0/16 5:16PM INF Adding route to 10.97.0.0/16 5:16PM INF Adding route to 10.107.0.0/16 5:16PM INF Adding route to 10.106.35.239/32 5:16PM INF Adding route to 10.108.0.0/16 5:16PM INF Adding route to 10.105.0.0/16 5:16PM INF Adding route to 10.99.0.0/16 5:16PM INF Adding route to 10.111.0.0/16 5:16PM INF Adding route to 10.104.0.0/16 5:16PM INF Adding route to 10.96.0.0/16 5:16PM INF Adding route to 10.103.0.0/16 5:16PM INF Adding route to 10.101.0.0/16 5:16PM INF Adding route to 10.98.0.0/16 5:16PM INF Adding route to 10.102.250.70/32 5:16PM INF Adding route to 10.100.0.0/16 5:16PM INF Adding route to 10.110.164.251/32 5:16PM INF Adding route to 10.244.0.0/16 5:16PM INF Route to tun device completed 5:16PM INF Setting up dns in hosts mode 5:16PM INF --------------------------------------------------------------- 5:16PM INF All looks good, now you can access to resources in the kubernetes cluster 5:16PM INF ---------------------------------------------------------------

ROUTE路由规则
`
IPv4 路由表

活动路由:
网络目标 网络掩码 网关 接口 跃点数
......
10.103.0.0 255.255.0.0 10.103.0.0 10.96.0.0 261
10.103.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.104.0.0 255.255.0.0 10.104.0.0 10.96.0.0 261
10.104.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.105.0.0 255.255.0.0 10.105.0.0 10.96.0.0 261
10.105.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.102.250.70 255.255.255.255 在链路上 10.96.0.0 6
10.106.35.239 255.255.255.255 在链路上 10.96.0.0 261
10.110.164.251 255.255.255.255 在链路上 10.96.0.0 261

10.111.0.0 255.255.0.0 10.111.0.0 10.96.0.0 261
10.111.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.244.0.0 255.255.0.0 10.244.0.0 10.96.0.0 261
10.244.0.0 255.255.255.255 在链路上 10.96.0.0 261
127.0.0.0 255.0.0.0 在链路上 127.0.0.1 331
127.0.0.1 255.255.255.255 在链路上 127.0.0.1 331
127.255.255.255 255.255.255.255 在链路上 127.0.0.1 331
172.16.60.0 255.255.255.0 在链路上 172.16.60.252 306
172.16.60.252 255.255.255.255 在链路上 172.16.60.252 306
172.16.60.255 255.255.255.255 在链路上 172.16.60.252 306
......
`

Environment (please complete the following information):

  • OS: [Windows 11]
  • Kubernetes [k8s 1.17.2]
  • KT Version [kt 0.3.7]

Additional context
临时解决办法,手动将路由规则改为:
10.102.250.70 255.255.255.255 10.102.0.0 10.96.0.0 6 10.106.35.239 255.255.255.255 10.106.0.0 10.96.0.0 261 10.110.164.251 255.255.255.255 10.110.0.0 10.96.0.0 261

@key9527 key9527 added the enhancement New feature or request label Aug 28, 2023
@key9527
Copy link
Author

key9527 commented Aug 28, 2023

上面日志格式有问题,这里重新附上日志

PS C:\Users\PC> ktctl connect --context pro
5:16PM INF Using cluster context pro (aio-pro)
5:16PM INF KtConnect 0.3.7 start at 29112 (windows amd64)
5:16PM INF Fetching cluster time ...
5:16PM INF Using tun2socks mode
5:16PM INF Successful create config map kt-connect-shadow-auonm
5:16PM INF Deploying shadow pod kt-connect-shadow-auonm in namespace default
5:16PM INF Waiting for pod kt-connect-shadow-auonm ...
5:16PM INF Pod kt-connect-shadow-auonm is ready
5:16PM INF Port forward local:32947 -> pod kt-connect-shadow-auonm:22 established
5:16PM INF Socks proxy established
2023/08/28 17:16:20 Using existing driver 0.14
2023/08/28 17:16:20 Creating adapter
5:16PM INF Tun device KtConnectTunnel is ready
5:16PM INF Adding route to 10.109.0.0/16
5:16PM INF Adding route to 10.97.0.0/16
5:16PM INF Adding route to 10.107.0.0/16
5:16PM INF Adding route to 10.106.35.239/32
5:16PM INF Adding route to 10.108.0.0/16
5:16PM INF Adding route to 10.105.0.0/16
5:16PM INF Adding route to 10.99.0.0/16
5:16PM INF Adding route to 10.111.0.0/16
5:16PM INF Adding route to 10.104.0.0/16
5:16PM INF Adding route to 10.96.0.0/16
5:16PM INF Adding route to 10.103.0.0/16
5:16PM INF Adding route to 10.101.0.0/16
5:16PM INF Adding route to 10.98.0.0/16
5:16PM INF Adding route to 10.102.250.70/32
5:16PM INF Adding route to 10.100.0.0/16
5:16PM INF Adding route to 10.110.164.251/32
5:16PM INF Adding route to 10.244.0.0/16
5:16PM INF Route to tun device completed
5:16PM INF Setting up dns in hosts mode
5:16PM INF ---------------------------------------------------------------
5:16PM INF All looks good, now you can access to resources in the kubernetes cluster
5:16PM INF ---------------------------------------------------------------

IPv4 路由表

活动路由:
网络目标 网络掩码 网关 接口 跃点数
0.0.0.0 0.0.0.0 172.16.60.1 172.16.60.252 50
10.96.0.0 255.255.0.0 10.96.0.0 10.96.0.0 261
10.96.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.97.0.0 255.255.0.0 10.97.0.0 10.96.0.0 261
10.97.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.98.0.0 255.255.0.0 10.98.0.0 10.96.0.0 261
10.98.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.99.0.0 255.255.0.0 10.99.0.0 10.96.0.0 261
10.99.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.100.0.0 255.255.0.0 10.100.0.0 10.96.0.0 261
10.100.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.101.0.0 255.255.0.0 10.101.0.0 10.96.0.0 261
10.101.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.102.250.70 255.255.255.255 在链路上 10.96.0.0 261
10.103.0.0 255.255.0.0 10.103.0.0 10.96.0.0 261
10.103.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.104.0.0 255.255.0.0 10.104.0.0 10.96.0.0 261
10.104.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.105.0.0 255.255.0.0 10.105.0.0 10.96.0.0 261
10.105.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.106.35.239 255.255.255.255 在链路上 10.96.0.0 261
10.107.0.0 255.255.0.0 10.107.0.0 10.96.0.0 261
10.107.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.108.0.0 255.255.0.0 10.108.0.0 10.96.0.0 261
10.108.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.109.0.0 255.255.0.0 10.109.0.0 10.96.0.0 261
10.109.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.110.164.251 255.255.255.255 在链路上 10.96.0.0 261
10.111.0.0 255.255.0.0 10.111.0.0 10.96.0.0 261
10.111.0.0 255.255.255.255 在链路上 10.96.0.0 261
10.244.0.0 255.255.0.0 10.244.0.0 10.96.0.0 261
10.244.0.0 255.255.255.255 在链路上 10.96.0.0 261

@crclz
Copy link

crclz commented Sep 10, 2023

@key9527 我也好像遇到了类似的问题。我找到一个可以永久解决问题,但不太优雅的办法:

例如我的mongo服务的ClusterIP是10.104.112.16,当我执行ktctl connect后,它会提示我“Adding route to 10.104.112.16/32”,我暂时不清楚为什么/32有问题,但是知道怎么解决。以下是解决方案:

再创建一个service

apiVersion: v1
kind: Service
metadata:
  name: inf-etcd-common2
  namespace: d2
spec:
  clusterIP: 10.104.112.17 # 注意,这里只需在mongo服务的ClusterIP10.104.112.14末尾变动一下,在与其他ip冲突的情况下,距离原本ip尽量近
  ports:
  - port: 2379
    targetPort: 2379
  selector:
    app: inf-etcd-common2

新服务创建后,结束ktctl,然后再ktctl connect,就会发现输出:

Adding route to 10.104.112.0/24

两个路由项被合并成了1个,避免了以/32结尾。经过测试,原本不能访问的mongo,变得可以访问了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants