-
Notifications
You must be signed in to change notification settings - Fork 449
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
custom vpc pod support tcp http probe with tproxy method #3024
Conversation
38184a8
to
b8eae39
Compare
05e8aa5
to
69d0725
Compare
charts/values.yaml
Outdated
@@ -61,6 +61,7 @@ func: | |||
LOGICAL_GATEWAY: false | |||
ENABLE_BIND_LOCAL_IP: true | |||
U2O_INTERCONNECTION: false | |||
ENABLE_TPROXY: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
默认需要关闭,避免未知问题影响其他功能
dist/images/install.sh
Outdated
@@ -32,6 +32,7 @@ IFACE=${IFACE:-} | |||
# Note that the dpdk tunnel iface and tunnel ip cidr should be diffierent with Kubernetes api cidr, otherwise the route will be a problem. | |||
DPDK_TUNNEL_IFACE=${DPDK_TUNNEL_IFACE:-br-phy} | |||
ENABLE_BIND_LOCAL_IP=${ENABLE_BIND_LOCAL_IP:-true} | |||
ENABLE_TPROXY=${ENABLE_TPROXY:-true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1
pkg/daemon/config.go
Outdated
@@ -100,6 +101,7 @@ func ParseFlags() *Configuration { | |||
argEnableVerboseConnCheck = pflag.Bool("enable-verbose-conn-check", false, "enable TCP/UDP connectivity check listen port") | |||
argTCPConnectivityCheckPort = pflag.Int("tcp-conn-check-port", 8100, "TCP connectivity Check Port") | |||
argUDPConnectivityCheckPort = pflag.Int("udp-conn-check-port", 8101, "UDP connectivity Check Port") | |||
argEnableTProxy = pflag.Bool("enable-tproxy", true, "enable tproxy for vpc pod liveness or readiness probe") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
pkg/tproxy/tproxy_tcp_linux.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
代码参考哪里要写明来源
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1
pkg/ovs/ovs-vsctl.go
Outdated
} | ||
|
||
podNetNs := "" | ||
re := regexp.MustCompile(`pod_netns="([^"]+)"`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以用一个全局变量,避免频繁初始化 re 对象
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1
pkg/daemon/tproxy_linux.go
Outdated
} | ||
|
||
_ = ns.WithNetNSPath(podNS.Path(), func(_ ns.NetNS) error { | ||
// Packet 's src and dst IP are both PodIP in netns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Packet 's src and dst IP are both PodIP in netns | |
// Packet's src and dst IP are both PodIP in netns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1
What type of this PR
Examples of user facing changes:
Which issue(s) this PR fixes:
Fixes #2869
TPROXY 引流路线:
kubelet发出探测TCP或者HTTP报文
1)到OVN-OUTPUT链mangle表
2)然后策略路由到达10001 table
3)把流量引入到lo 口,从而让将流量重新走OVN-PREROUTING链 mangle表,因为-j tproxy动作只能适用在prerouting链,所以不在OUTPUT 直接把流量发给tproxy,而是得这么绕一圈
4)策略路由
到达tproxy后HTTP探测和TCP probe有区别
另外这个方案有个限制:
不同VPC 同样POD IP的POD不能在同一个节点,因为TPROXY根据流量来决定是否代发给POD ns,所以没有办法去区分同样IP情况下报文属于哪个VPC
WHAT
🤖 Generated by Copilot at 95c2a80
This pull request adds a new feature to enable transparent proxying of TCP traffic from kubelet to custom VPC pods using iptables and a tproxy listener. It also improves the CNI server's port binding logic and adds a new test case for pod probes in a custom VPC. It modifies several files in the
cmd
,pkg
,test
, andgo.mod
directories to implement and test this feature.🤖 Generated by Copilot at 95c2a80
HOW
🤖 Generated by Copilot at 95c2a80
cmd/daemon/cniserver.go
andpkg/daemon/config.go
(link,link,link,link)go.mod
(link)pkg/tproxy/tproxy_tcp.go
that provides a Listener type and a Conn type for transparent proxying of TCP connections (link)pkg/daemon/listen.go
that returns the address to listen on for the CNI server based on the environment variables (link,link)pkg/ovs/ovs-vsctl.go
that returns the pod network namespace associated with an interface (link,link)pkg/daemon/gateway_linux.go
and the util package inpkg/util/const.go
that represent the iptables marks, masks, tables, chains, and ports used for transparent proxying (link,link,link)pkg/daemon/gateway_linux.go
that updates the iptables rules for transparent proxying according to the pod IP, host IP, and probe ports (link)pkg/daemon/gateway_linux.go
that deduplicates and sorts the probe ports of a pod (link)pkg/daemon/gateway_linux.go
(link)pkg/daemon/controller.go
that starts three goroutines to handle the transparent proxying logic if the EnableTProxy configuration option is true, or calls the cleanTProxyConfig function to remove any existing iptables rules for transparent proxying if the option is false (link)test/e2e/kube-ovn/pod/pod.go
that tests the transparent proxying functionality for custom VPC pod liveness and readiness probes (link,link,link,link,link)test/e2e/kube-ovn/pod/pod.go
that provide core Kubernetes API types, integer and string utilities, and time-related functionality (link)test/e2e/kube-ovn/pod/pod.go
that hold a VpcClient object and a custom VPC name (link)test/e2e/kube-ovn/pod/pod.go
by calling the VpcClient method of the framework type (link)test/e2e/kube-ovn/pod/pod.go
that deletes the custom VPC with the vpcName variable by calling the DeleteSync method of the vpcClient object (link)test/e2e/kube-ovn/pod/pod.go
that creates a custom VPC and a subnet in that VPC, and then creates four pods with different combinations of HTTP and TCP liveness and readiness probes, checks the pod readiness status, and deletes the pods, the subnet, and the VPC after testing (link)test/e2e/framework/image.go
that represents the image name of the nginx:alpine container image, which is used for testing pod liveness and readiness probes (link)test/e2e/framework/pod.go
that returns a pointer to a corev1.Pod object by calling the PodInterface (link)cmd/daemon/cniserver.go
to optionally bind to the local pod IP if the environment variable ENABLE_BIND_LOCAL_IP is set to true (link)go.mod
to provide a logging framework for Kubernetes components (link)