alibaba / kt-connect

A toolkit for Integrating with your kubernetes dev environment more efficiently
https://alibaba.github.io/kt-connect/#/
GNU General Public License v3.0
1.48k stars 231 forks source link

mesh模式,访问后跳转到svc-端口的错误 #361

Open CharkeyQK opened 1 year ago

CharkeyQK commented 1 year ago

Describe the bug A clear and concise description of what the bug is. 存在 namespace 为 demo-dev,有个 svc 为 demo-auth,通过 ke-connect 链接 和 kt-mesh 拦截指定 header (VERSION=charkey)的流量到本地。 会创建名为 demo-auth-kt-mesh-charkey、demo-auth-kt-stuntman 的两个svc; 经查看 demo-auth 的变更为

apiVersion: v1
kind: Service
metadata:
  annotations:
    kt-selector: '{"app":"demo-auth"}'
  creationTimestamp: "2021-09-02T03:00:19Z"
  labels:
    app: demo-auth
  name: demo-auth
  namespace: demo-dev
spec:
  clusterIP: 10.247.59.142
  ports:
  - name: server
    port: 80
    protocol: TCP
    targetPort: 8582
  selector:
    kt-role: router
    kt-target: FJvxDxuYiDdauFhgntDP
  sessionAffinity: None
  type: ClusterIP

demo-auth-kt-mesh-charkey 的 svc 为

apiVersion: v1
kind: Service
metadata:
  annotations:
    kt-last-heart-beat: "1663728272"
  labels:
    control-by: kt
  name: demo-auth-kt-mesh-charkey
  namespace: demo-dev
spec:
  clusterIP: 10.247.45.232
  ports:
  - name: kt-80
    port: 80
    protocol: TCP
    targetPort: 8582
  selector:
    kt-role: shadow-mesh
    kt-target: JudLkOzifUGecwQNKuoL
  sessionAffinity: None
  type: ClusterIP

demo-auth-kt-stuntman svc 为

apiVersion: v1
kind: Service
metadata:
  annotations:
    kt-last-heart-beat: "1663728380"
  labels:
    control-by: kt
  name: demo-auth-kt-stuntman
  namespace: demo-dev
spec:
  clusterIP: 10.247.92.158
  ports:
  - name: kt-80
    port: 80
    protocol: TCP
    targetPort: 8582
  selector:
    app: demo-auth
  sessionAffinity: None
  type: ClusterIP

demo-auth 是一个 springsecurity oauth 服务,访问 demo-dev 的环境 域名如 http://demo-auth.example.com/demo-auth, 会被重定向到 http://demo-auth-kt-stuntman-80/demo-auth/,如果带上 header 访问,将会被重定向到 http://demo-auth-kt-mesh-charkey-80/demo-auth/

问题点在于,为什么重定向后会跳转到 svc 的这个地址然后加上 -80? 80 是 svc 的端口

Log please add -d to debug log

kt-connect 和 kt-mesh 没有相关的log,请问哪边可以查看到更多log

Environment (please complete the following information):

Additional context Add any other context about the problem here.