mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-21 18:11:22 +00:00
Enable local traffic detection using the interface options
This commit adds the framework for the new local detection modes BridgeInterface and InterfaceNamePrefix to work. Signed-off-by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
This commit is contained in:
@@ -14,6 +14,9 @@ conntrack:
|
||||
min: 131072
|
||||
tcpCloseWaitTimeout: 1h0m0s
|
||||
tcpEstablishedTimeout: 24h0m0s
|
||||
detectLocal:
|
||||
bridgeInterface: ""
|
||||
interfaceNamePrefix: ""
|
||||
detectLocalMode: ""
|
||||
enableProfiling: false
|
||||
healthzBindAddress: 0.0.0.0:10256
|
||||
|
@@ -14,6 +14,9 @@ conntrack:
|
||||
min: 131072
|
||||
tcpCloseWaitTimeout: 1h0m0s
|
||||
tcpEstablishedTimeout: 24h0m0s
|
||||
detectLocal:
|
||||
bridgeInterface: ""
|
||||
interfaceNamePrefix: ""
|
||||
detectLocalMode: ""
|
||||
enableProfiling: false
|
||||
healthzBindAddress: 0.0.0.0:10256
|
||||
|
@@ -107,6 +107,18 @@ type KubeProxyWinkernelConfiguration struct {
|
||||
ForwardHealthCheckVip bool
|
||||
}
|
||||
|
||||
// DetectLocalConfiguration contains optional settings related to DetectLocalMode option
|
||||
type DetectLocalConfiguration struct {
|
||||
// BridgeInterface is a string argument which represents a single bridge interface name.
|
||||
// Kube-proxy considers traffic as local if originating from this given bridge.
|
||||
// This argument should be set if DetectLocalMode is set to BridgeInterface.
|
||||
BridgeInterface string
|
||||
// InterfaceNamePrefix is a string argument which represents a single interface prefix name.
|
||||
// Kube-proxy considers traffic as local if originating from one or more interfaces which match
|
||||
// the given prefix. This argument should be set if DetectLocalMode is set to InterfaceNamePrefix.
|
||||
InterfaceNamePrefix string
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// KubeProxyConfiguration contains everything necessary to configure the
|
||||
@@ -174,6 +186,8 @@ type KubeProxyConfiguration struct {
|
||||
ShowHiddenMetricsForVersion string
|
||||
// DetectLocalMode determines mode to use for detecting local traffic, defaults to LocalModeClusterCIDR
|
||||
DetectLocalMode LocalMode
|
||||
// DetectLocal contains optional configuration settings related to DetectLocalMode.
|
||||
DetectLocal DetectLocalConfiguration
|
||||
}
|
||||
|
||||
// ProxyMode represents modes used by the Kubernetes proxy server. Currently, three modes of proxy are available in
|
||||
@@ -204,8 +218,10 @@ type LocalMode string
|
||||
|
||||
// Currently supported modes for LocalMode
|
||||
const (
|
||||
LocalModeClusterCIDR LocalMode = "ClusterCIDR"
|
||||
LocalModeNodeCIDR LocalMode = "NodeCIDR"
|
||||
LocalModeClusterCIDR LocalMode = "ClusterCIDR"
|
||||
LocalModeNodeCIDR LocalMode = "NodeCIDR"
|
||||
LocalModeBridgeInterface LocalMode = "BridgeInterface"
|
||||
LocalModeInterfaceNamePrefix LocalMode = "InterfaceNamePrefix"
|
||||
)
|
||||
|
||||
// IPVSSchedulerMethod is the algorithm for allocating TCP connections and
|
||||
|
@@ -39,6 +39,16 @@ func init() {
|
||||
// RegisterConversions adds conversion functions to the given scheme.
|
||||
// Public to allow building arbitrary schemes.
|
||||
func RegisterConversions(s *runtime.Scheme) error {
|
||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.DetectLocalConfiguration)(nil), (*config.DetectLocalConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1alpha1_DetectLocalConfiguration_To_config_DetectLocalConfiguration(a.(*v1alpha1.DetectLocalConfiguration), b.(*config.DetectLocalConfiguration), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*config.DetectLocalConfiguration)(nil), (*v1alpha1.DetectLocalConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_config_DetectLocalConfiguration_To_v1alpha1_DetectLocalConfiguration(a.(*config.DetectLocalConfiguration), b.(*v1alpha1.DetectLocalConfiguration), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.KubeProxyConfiguration)(nil), (*config.KubeProxyConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1alpha1_KubeProxyConfiguration_To_config_KubeProxyConfiguration(a.(*v1alpha1.KubeProxyConfiguration), b.(*config.KubeProxyConfiguration), scope)
|
||||
}); err != nil {
|
||||
@@ -92,6 +102,28 @@ func RegisterConversions(s *runtime.Scheme) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func autoConvert_v1alpha1_DetectLocalConfiguration_To_config_DetectLocalConfiguration(in *v1alpha1.DetectLocalConfiguration, out *config.DetectLocalConfiguration, s conversion.Scope) error {
|
||||
out.BridgeInterface = in.BridgeInterface
|
||||
out.InterfaceNamePrefix = in.InterfaceNamePrefix
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1alpha1_DetectLocalConfiguration_To_config_DetectLocalConfiguration is an autogenerated conversion function.
|
||||
func Convert_v1alpha1_DetectLocalConfiguration_To_config_DetectLocalConfiguration(in *v1alpha1.DetectLocalConfiguration, out *config.DetectLocalConfiguration, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_DetectLocalConfiguration_To_config_DetectLocalConfiguration(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_config_DetectLocalConfiguration_To_v1alpha1_DetectLocalConfiguration(in *config.DetectLocalConfiguration, out *v1alpha1.DetectLocalConfiguration, s conversion.Scope) error {
|
||||
out.BridgeInterface = in.BridgeInterface
|
||||
out.InterfaceNamePrefix = in.InterfaceNamePrefix
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_config_DetectLocalConfiguration_To_v1alpha1_DetectLocalConfiguration is an autogenerated conversion function.
|
||||
func Convert_config_DetectLocalConfiguration_To_v1alpha1_DetectLocalConfiguration(in *config.DetectLocalConfiguration, out *v1alpha1.DetectLocalConfiguration, s conversion.Scope) error {
|
||||
return autoConvert_config_DetectLocalConfiguration_To_v1alpha1_DetectLocalConfiguration(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1alpha1_KubeProxyConfiguration_To_config_KubeProxyConfiguration(in *v1alpha1.KubeProxyConfiguration, out *config.KubeProxyConfiguration, s conversion.Scope) error {
|
||||
out.FeatureGates = *(*map[string]bool)(unsafe.Pointer(&in.FeatureGates))
|
||||
out.BindAddress = in.BindAddress
|
||||
@@ -124,6 +156,9 @@ func autoConvert_v1alpha1_KubeProxyConfiguration_To_config_KubeProxyConfiguratio
|
||||
}
|
||||
out.ShowHiddenMetricsForVersion = in.ShowHiddenMetricsForVersion
|
||||
out.DetectLocalMode = config.LocalMode(in.DetectLocalMode)
|
||||
if err := Convert_v1alpha1_DetectLocalConfiguration_To_config_DetectLocalConfiguration(&in.DetectLocal, &out.DetectLocal, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -164,6 +199,9 @@ func autoConvert_config_KubeProxyConfiguration_To_v1alpha1_KubeProxyConfiguratio
|
||||
}
|
||||
out.ShowHiddenMetricsForVersion = in.ShowHiddenMetricsForVersion
|
||||
out.DetectLocalMode = v1alpha1.LocalMode(in.DetectLocalMode)
|
||||
if err := Convert_config_DetectLocalConfiguration_To_v1alpha1_DetectLocalConfiguration(&in.DetectLocal, &out.DetectLocal, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
17
pkg/proxy/apis/config/zz_generated.deepcopy.go
generated
17
pkg/proxy/apis/config/zz_generated.deepcopy.go
generated
@@ -48,6 +48,22 @@ func (in ConfigurationMap) DeepCopy() ConfigurationMap {
|
||||
return *out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DetectLocalConfiguration) DeepCopyInto(out *DetectLocalConfiguration) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DetectLocalConfiguration.
|
||||
func (in *DetectLocalConfiguration) DeepCopy() *DetectLocalConfiguration {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DetectLocalConfiguration)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *KubeProxyConfiguration) DeepCopyInto(out *KubeProxyConfiguration) {
|
||||
*out = *in
|
||||
@@ -76,6 +92,7 @@ func (in *KubeProxyConfiguration) DeepCopyInto(out *KubeProxyConfiguration) {
|
||||
copy(*out, *in)
|
||||
}
|
||||
out.Winkernel = in.Winkernel
|
||||
out.DetectLocal = in.DetectLocal
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user