kube-proxy: internal config: refactor ClusterCIDR
Refactor ClusterCIDR for internal configuration of kube-proxy adhering to the v1alpha2 version specifications as detailed in https://kep.k8s.io/784. Signed-off-by: Daman Arora <aroradaman@gmail.com>
This commit is contained in:
@@ -87,6 +87,7 @@ type Options struct {
|
||||
iptablesMinSyncPeriod time.Duration
|
||||
ipvsSyncPeriod time.Duration
|
||||
ipvsMinSyncPeriod time.Duration
|
||||
clusterCIDRs string
|
||||
}
|
||||
|
||||
// AddFlags adds flags to fs and binds them to options.
|
||||
@@ -143,7 +144,7 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.Var(&o.config.DetectLocalMode, "detect-local-mode", "Mode to use to detect local traffic. This parameter is ignored if a config file is specified by --config.")
|
||||
fs.StringVar(&o.config.DetectLocal.BridgeInterface, "pod-bridge-interface", o.config.DetectLocal.BridgeInterface, "A bridge interface name. When --detect-local-mode is set to BridgeInterface, kube-proxy will consider traffic to be local if it originates from this bridge.")
|
||||
fs.StringVar(&o.config.DetectLocal.InterfaceNamePrefix, "pod-interface-name-prefix", o.config.DetectLocal.InterfaceNamePrefix, "An interface name prefix. When --detect-local-mode is set to InterfaceNamePrefix, kube-proxy will consider traffic to be local if it originates from any interface whose name begins with this prefix.")
|
||||
fs.StringVar(&o.config.ClusterCIDR, "cluster-cidr", o.config.ClusterCIDR, "The CIDR range of the pods in the cluster. (For dual-stack clusters, this can be a comma-separated dual-stack pair of CIDR ranges.). When --detect-local-mode is set to ClusterCIDR, kube-proxy will consider traffic to be local if its source IP is in this range. (Otherwise it is not used.) "+
|
||||
fs.StringVar(&o.clusterCIDRs, "cluster-cidr", strings.Join(o.config.DetectLocal.ClusterCIDRs, ","), "The CIDR range of the pods in the cluster. (For dual-stack clusters, this can be a comma-separated dual-stack pair of CIDR ranges.). When --detect-local-mode is set to ClusterCIDR, kube-proxy will consider traffic to be local if its source IP is in this range. (Otherwise it is not used.) "+
|
||||
"This parameter is ignored if a config file is specified by --config.")
|
||||
|
||||
fs.StringSliceVar(&o.config.NodePortAddresses, "nodeport-addresses", o.config.NodePortAddresses,
|
||||
@@ -326,6 +327,9 @@ func (o *Options) processV1Alpha1Flags(fs *pflag.FlagSet) {
|
||||
if fs.Changed("ipvs-min-sync-period") && o.config.Mode == kubeproxyconfig.ProxyModeIPVS {
|
||||
o.config.MinSyncPeriod.Duration = o.ipvsMinSyncPeriod
|
||||
}
|
||||
if fs.Changed("cluster-cidr") {
|
||||
o.config.DetectLocal.ClusterCIDRs = strings.Split(o.clusterCIDRs, ",")
|
||||
}
|
||||
}
|
||||
|
||||
// Validate validates all the required options.
|
||||
|
||||
@@ -20,6 +20,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -194,7 +196,6 @@ nodePortAddresses:
|
||||
Kubeconfig: "/path/to/kubeconfig",
|
||||
QPS: 7,
|
||||
},
|
||||
ClusterCIDR: tc.clusterCIDR,
|
||||
MinSyncPeriod: metav1.Duration{Duration: 10 * time.Second},
|
||||
SyncPeriod: metav1.Duration{Duration: 60 * time.Second},
|
||||
ConfigSyncPeriod: metav1.Duration{Duration: 15 * time.Second},
|
||||
@@ -228,6 +229,7 @@ nodePortAddresses:
|
||||
DetectLocalMode: kubeproxyconfig.LocalModeClusterCIDR,
|
||||
DetectLocal: kubeproxyconfig.DetectLocalConfiguration{
|
||||
BridgeInterface: "cbr0",
|
||||
ClusterCIDRs: strings.Split(tc.clusterCIDR, ","),
|
||||
InterfaceNamePrefix: "veth",
|
||||
},
|
||||
Logging: logsapi.LoggingConfiguration{
|
||||
@@ -444,6 +446,15 @@ func TestProcessV1Alpha1Flags(t *testing.T) {
|
||||
config.MinSyncPeriod == metav1.Duration{Duration: 7 * time.Second}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "cluster cidr",
|
||||
flags: []string{
|
||||
"--cluster-cidr=2002:0:0:1234::/64,10.0.0.0/14",
|
||||
},
|
||||
validate: func(config *kubeproxyconfig.KubeProxyConfiguration) bool {
|
||||
return reflect.DeepEqual(config.DetectLocal.ClusterCIDRs, []string{"2002:0:0:1234::/64", "10.0.0.0/14"})
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
@@ -271,8 +270,7 @@ func checkBadConfig(s *ProxyServer) error {
|
||||
// we can at least take note of whether there is any explicitly-dual-stack
|
||||
// configuration.
|
||||
anyDualStackConfig := false
|
||||
clusterCIDRs := strings.Split(s.Config.ClusterCIDR, ",")
|
||||
for _, config := range [][]string{clusterCIDRs, s.Config.NodePortAddresses, s.Config.IPVS.ExcludeCIDRs, s.podCIDRs} {
|
||||
for _, config := range [][]string{s.Config.DetectLocal.ClusterCIDRs, s.Config.NodePortAddresses, s.Config.IPVS.ExcludeCIDRs, s.podCIDRs} {
|
||||
if dual, _ := netutils.IsDualStackCIDRStrings(config); dual {
|
||||
anyDualStackConfig = true
|
||||
break
|
||||
@@ -314,14 +312,11 @@ func checkBadIPConfig(s *ProxyServer, dualStackSupported bool) (err error, fatal
|
||||
clusterType = fmt.Sprintf("%s-only", s.PrimaryIPFamily)
|
||||
}
|
||||
|
||||
if s.Config.ClusterCIDR != "" {
|
||||
clusterCIDRs := strings.Split(s.Config.ClusterCIDR, ",")
|
||||
if badCIDRs(clusterCIDRs, badFamily) {
|
||||
errors = append(errors, fmt.Errorf("cluster is %s but clusterCIDRs contains only IPv%s addresses", clusterType, badFamily))
|
||||
if s.Config.DetectLocalMode == kubeproxyconfig.LocalModeClusterCIDR && !dualStackSupported {
|
||||
// This has always been a fatal error
|
||||
fatal = true
|
||||
}
|
||||
if badCIDRs(s.Config.DetectLocal.ClusterCIDRs, badFamily) {
|
||||
errors = append(errors, fmt.Errorf("cluster is %s but clusterCIDRs contains only IPv%s addresses", clusterType, badFamily))
|
||||
if s.Config.DetectLocalMode == kubeproxyconfig.LocalModeClusterCIDR && !dualStackSupported {
|
||||
// This has always been a fatal error
|
||||
fatal = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
goruntime "runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/cadvisor/machine"
|
||||
@@ -477,12 +476,11 @@ func getLocalDetectors(logger klog.Logger, primaryIPFamily v1.IPFamily, config *
|
||||
|
||||
switch config.DetectLocalMode {
|
||||
case proxyconfigapi.LocalModeClusterCIDR:
|
||||
clusterCIDRs := strings.Split(strings.TrimSpace(config.ClusterCIDR), ",")
|
||||
for family, cidrs := range proxyutil.MapCIDRsByIPFamily(clusterCIDRs) {
|
||||
for family, cidrs := range proxyutil.MapCIDRsByIPFamily(config.DetectLocal.ClusterCIDRs) {
|
||||
localDetectors[family] = proxyutil.NewDetectLocalByCIDR(cidrs[0].String())
|
||||
}
|
||||
if !localDetectors[primaryIPFamily].IsImplemented() {
|
||||
logger.Info("Detect-local-mode set to ClusterCIDR, but no cluster CIDR specified for primary IP family", "ipFamily", primaryIPFamily, "clusterCIDR", config.ClusterCIDR)
|
||||
logger.Info("Detect-local-mode set to ClusterCIDR, but no cluster CIDR specified for primary IP family", "ipFamily", primaryIPFamily, "clusterCIDRs", config.DetectLocal.ClusterCIDRs)
|
||||
}
|
||||
|
||||
case proxyconfigapi.LocalModeNodeCIDR:
|
||||
|
||||
@@ -121,7 +121,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeClusterCIDR, single-stack IPv4 cluster",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeClusterCIDR,
|
||||
ClusterCIDR: "10.0.0.0/14",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"10.0.0.0/14"},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv4Protocol,
|
||||
expected: map[v1.IPFamily]proxyutil.LocalTrafficDetector{
|
||||
@@ -133,7 +135,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeClusterCIDR, single-stack IPv6 cluster",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeClusterCIDR,
|
||||
ClusterCIDR: "2002:0:0:1234::/64",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"2002:0:0:1234::/64"},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv6Protocol,
|
||||
expected: map[v1.IPFamily]proxyutil.LocalTrafficDetector{
|
||||
@@ -145,7 +149,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeClusterCIDR, single-stack IPv6 cluster with single-stack IPv4 config",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeClusterCIDR,
|
||||
ClusterCIDR: "10.0.0.0/14",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"10.0.0.0/14"},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv6Protocol,
|
||||
// This will output a warning that there is no IPv6 CIDR but it
|
||||
@@ -159,7 +165,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeClusterCIDR, single-stack IPv4 cluster with single-stack IPv6 config",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeClusterCIDR,
|
||||
ClusterCIDR: "2002:0:0:1234::/64",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"2002:0:0:1234::/64"},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv4Protocol,
|
||||
// This will output a warning that there is no IPv4 CIDR but it
|
||||
@@ -173,7 +181,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeClusterCIDR, dual-stack IPv4-primary cluster",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeClusterCIDR,
|
||||
ClusterCIDR: "10.0.0.0/14,2002:0:0:1234::/64",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"10.0.0.0/14", "2002:0:0:1234::/64"},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv4Protocol,
|
||||
expected: map[v1.IPFamily]proxyutil.LocalTrafficDetector{
|
||||
@@ -185,7 +195,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeClusterCIDR, dual-stack IPv6-primary cluster",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeClusterCIDR,
|
||||
ClusterCIDR: "2002:0:0:1234::/64,10.0.0.0/14",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"2002:0:0:1234::/64", "10.0.0.0/14"},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv6Protocol,
|
||||
expected: map[v1.IPFamily]proxyutil.LocalTrafficDetector{
|
||||
@@ -197,7 +209,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeClusterCIDR, IPv4-primary kube-proxy / IPv6-primary config",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeClusterCIDR,
|
||||
ClusterCIDR: "2002:0:0:1234::/64,10.0.0.0/14",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"2002:0:0:1234::/64", "10.0.0.0/14"},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv4Protocol,
|
||||
expected: map[v1.IPFamily]proxyutil.LocalTrafficDetector{
|
||||
@@ -209,7 +223,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeClusterCIDR, no ClusterCIDR",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeClusterCIDR,
|
||||
ClusterCIDR: "",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{""},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv4Protocol,
|
||||
expected: map[v1.IPFamily]proxyutil.LocalTrafficDetector{
|
||||
@@ -222,7 +238,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeNodeCIDR, single-stack IPv4 cluster",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeNodeCIDR,
|
||||
ClusterCIDR: "10.0.0.0/14",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"10.0.0.0/14"},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv4Protocol,
|
||||
nodePodCIDRs: []string{"10.0.0.0/24"},
|
||||
@@ -235,7 +253,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeNodeCIDR, single-stack IPv6 cluster",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeNodeCIDR,
|
||||
ClusterCIDR: "2002:0:0:1234::/64",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"2002:0:0:1234::/64"},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv6Protocol,
|
||||
nodePodCIDRs: []string{"2002::1234:abcd:ffff:0:0/96"},
|
||||
@@ -248,7 +268,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeNodeCIDR, single-stack IPv6 cluster with single-stack IPv4 config",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeNodeCIDR,
|
||||
ClusterCIDR: "10.0.0.0/14",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"10.0.0.0/14"},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv6Protocol,
|
||||
nodePodCIDRs: []string{"10.0.0.0/24"},
|
||||
@@ -263,7 +285,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeNodeCIDR, single-stack IPv4 cluster with single-stack IPv6 config",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeNodeCIDR,
|
||||
ClusterCIDR: "2002:0:0:1234::/64",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"2002:0:0:1234::/64"},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv4Protocol,
|
||||
nodePodCIDRs: []string{"2002::1234:abcd:ffff:0:0/96"},
|
||||
@@ -278,7 +302,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeNodeCIDR, dual-stack IPv4-primary cluster",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeNodeCIDR,
|
||||
ClusterCIDR: "10.0.0.0/14,2002:0:0:1234::/64",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"10.0.0.0/14", "2002:0:0:1234::/64"},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv4Protocol,
|
||||
nodePodCIDRs: []string{"10.0.0.0/24", "2002::1234:abcd:ffff:0:0/96"},
|
||||
@@ -291,7 +317,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeNodeCIDR, dual-stack IPv6-primary cluster",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeNodeCIDR,
|
||||
ClusterCIDR: "2002:0:0:1234::/64,10.0.0.0/14",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"2002:0:0:1234::/64", "10.0.0.0/14"},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv6Protocol,
|
||||
nodePodCIDRs: []string{"2002::1234:abcd:ffff:0:0/96", "10.0.0.0/24"},
|
||||
@@ -304,7 +332,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeNodeCIDR, IPv6-primary kube-proxy / IPv4-primary config",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeNodeCIDR,
|
||||
ClusterCIDR: "10.0.0.0/14,2002:0:0:1234::/64",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"10.0.0.0/14", "2002:0:0:1234::/64"},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv6Protocol,
|
||||
nodePodCIDRs: []string{"10.0.0.0/24", "2002::1234:abcd:ffff:0:0/96"},
|
||||
@@ -317,7 +347,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeNodeCIDR, no PodCIDRs",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeNodeCIDR,
|
||||
ClusterCIDR: "",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{""},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv4Protocol,
|
||||
nodePodCIDRs: []string{},
|
||||
@@ -331,7 +363,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "unknown LocalMode",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalMode("abcd"),
|
||||
ClusterCIDR: "10.0.0.0/14",
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"10.0.0.0/14"},
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv4Protocol,
|
||||
expected: map[v1.IPFamily]proxyutil.LocalTrafficDetector{
|
||||
@@ -344,7 +378,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeBridgeInterface",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeBridgeInterface,
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{BridgeInterface: "eth"},
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
BridgeInterface: "eth",
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv4Protocol,
|
||||
expected: map[v1.IPFamily]proxyutil.LocalTrafficDetector{
|
||||
@@ -356,7 +392,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeBridgeInterface, strange bridge name",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeBridgeInterface,
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{BridgeInterface: "1234567890123456789"},
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
BridgeInterface: "1234567890123456789",
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv4Protocol,
|
||||
expected: map[v1.IPFamily]proxyutil.LocalTrafficDetector{
|
||||
@@ -369,7 +407,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeInterfaceNamePrefix",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeInterfaceNamePrefix,
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{InterfaceNamePrefix: "eth"},
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
InterfaceNamePrefix: "eth",
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv4Protocol,
|
||||
expected: map[v1.IPFamily]proxyutil.LocalTrafficDetector{
|
||||
@@ -381,7 +421,9 @@ func Test_getLocalDetectors(t *testing.T) {
|
||||
name: "LocalModeInterfaceNamePrefix, strange interface name",
|
||||
config: &proxyconfigapi.KubeProxyConfiguration{
|
||||
DetectLocalMode: proxyconfigapi.LocalModeInterfaceNamePrefix,
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{InterfaceNamePrefix: "1234567890123456789"},
|
||||
DetectLocal: proxyconfigapi.DetectLocalConfiguration{
|
||||
InterfaceNamePrefix: "1234567890123456789",
|
||||
},
|
||||
},
|
||||
primaryIPFamily: v1.IPv4Protocol,
|
||||
expected: map[v1.IPFamily]proxyutil.LocalTrafficDetector{
|
||||
|
||||
@@ -305,7 +305,9 @@ func Test_checkBadConfig(t *testing.T) {
|
||||
name: "single-stack NodePortAddresses with single-stack config",
|
||||
proxy: &ProxyServer{
|
||||
Config: &kubeproxyconfig.KubeProxyConfiguration{
|
||||
ClusterCIDR: "10.0.0.0/8",
|
||||
DetectLocal: kubeproxyconfig.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"10.0.0.0/8"},
|
||||
},
|
||||
NodePortAddresses: []string{"192.168.0.0/24"},
|
||||
},
|
||||
PrimaryIPFamily: v1.IPv4Protocol,
|
||||
@@ -316,7 +318,9 @@ func Test_checkBadConfig(t *testing.T) {
|
||||
name: "dual-stack NodePortAddresses with dual-stack config",
|
||||
proxy: &ProxyServer{
|
||||
Config: &kubeproxyconfig.KubeProxyConfiguration{
|
||||
ClusterCIDR: "10.0.0.0/8,fd09::/64",
|
||||
DetectLocal: kubeproxyconfig.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"10.0.0.0/8", "fd09::/64"},
|
||||
},
|
||||
NodePortAddresses: []string{"192.168.0.0/24", "fd03::/64"},
|
||||
},
|
||||
PrimaryIPFamily: v1.IPv4Protocol,
|
||||
@@ -337,7 +341,9 @@ func Test_checkBadConfig(t *testing.T) {
|
||||
name: "single-stack NodePortAddresses with dual-stack config",
|
||||
proxy: &ProxyServer{
|
||||
Config: &kubeproxyconfig.KubeProxyConfiguration{
|
||||
ClusterCIDR: "10.0.0.0/8,fd09::/64",
|
||||
DetectLocal: kubeproxyconfig.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"10.0.0.0/8", "fd09::/64"},
|
||||
},
|
||||
NodePortAddresses: []string{"192.168.0.0/24"},
|
||||
},
|
||||
PrimaryIPFamily: v1.IPv4Protocol,
|
||||
@@ -348,7 +354,9 @@ func Test_checkBadConfig(t *testing.T) {
|
||||
name: "wrong-single-stack NodePortAddresses",
|
||||
proxy: &ProxyServer{
|
||||
Config: &kubeproxyconfig.KubeProxyConfiguration{
|
||||
ClusterCIDR: "fd09::/64",
|
||||
DetectLocal: kubeproxyconfig.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"fd09::/64"},
|
||||
},
|
||||
NodePortAddresses: []string{"192.168.0.0/24"},
|
||||
},
|
||||
PrimaryIPFamily: v1.IPv6Protocol,
|
||||
@@ -392,7 +400,9 @@ func Test_checkBadIPConfig(t *testing.T) {
|
||||
name: "ok single-stack clusterCIDR",
|
||||
proxy: &ProxyServer{
|
||||
Config: &kubeproxyconfig.KubeProxyConfiguration{
|
||||
ClusterCIDR: "10.0.0.0/8",
|
||||
DetectLocal: kubeproxyconfig.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"10.0.0.0/8"},
|
||||
},
|
||||
},
|
||||
PrimaryIPFamily: v1.IPv4Protocol,
|
||||
},
|
||||
@@ -403,7 +413,9 @@ func Test_checkBadIPConfig(t *testing.T) {
|
||||
name: "ok dual-stack clusterCIDR",
|
||||
proxy: &ProxyServer{
|
||||
Config: &kubeproxyconfig.KubeProxyConfiguration{
|
||||
ClusterCIDR: "10.0.0.0/8,fd01:2345::/64",
|
||||
DetectLocal: kubeproxyconfig.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"10.0.0.0/8", "fd01:2345::/64"},
|
||||
},
|
||||
},
|
||||
PrimaryIPFamily: v1.IPv4Protocol,
|
||||
},
|
||||
@@ -414,7 +426,9 @@ func Test_checkBadIPConfig(t *testing.T) {
|
||||
name: "ok reversed dual-stack clusterCIDR",
|
||||
proxy: &ProxyServer{
|
||||
Config: &kubeproxyconfig.KubeProxyConfiguration{
|
||||
ClusterCIDR: "fd01:2345::/64,10.0.0.0/8",
|
||||
DetectLocal: kubeproxyconfig.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"fd01:2345::/64", "10.0.0.0/8"},
|
||||
},
|
||||
},
|
||||
PrimaryIPFamily: v1.IPv4Protocol,
|
||||
},
|
||||
@@ -425,7 +439,9 @@ func Test_checkBadIPConfig(t *testing.T) {
|
||||
name: "wrong-family clusterCIDR",
|
||||
proxy: &ProxyServer{
|
||||
Config: &kubeproxyconfig.KubeProxyConfiguration{
|
||||
ClusterCIDR: "fd01:2345::/64",
|
||||
DetectLocal: kubeproxyconfig.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"fd01:2345::/64"},
|
||||
},
|
||||
},
|
||||
PrimaryIPFamily: v1.IPv4Protocol,
|
||||
},
|
||||
@@ -438,7 +454,9 @@ func Test_checkBadIPConfig(t *testing.T) {
|
||||
name: "wrong-family clusterCIDR when using ClusterCIDR LocalDetector",
|
||||
proxy: &ProxyServer{
|
||||
Config: &kubeproxyconfig.KubeProxyConfiguration{
|
||||
ClusterCIDR: "fd01:2345::/64",
|
||||
DetectLocal: kubeproxyconfig.DetectLocalConfiguration{
|
||||
ClusterCIDRs: []string{"fd01:2345::/64"},
|
||||
},
|
||||
DetectLocalMode: kubeproxyconfig.LocalModeClusterCIDR,
|
||||
},
|
||||
PrimaryIPFamily: v1.IPv4Protocol,
|
||||
|
||||
Reference in New Issue
Block a user