mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Validate IPVSConfiguration only when IPVS mode is enable.
This commit is contained in:
parent
45db5e7260
commit
d7c1100d1f
@ -35,7 +35,9 @@ func Validate(config *kubeproxyconfig.KubeProxyConfiguration) field.ErrorList {
|
|||||||
newPath := field.NewPath("KubeProxyConfiguration")
|
newPath := field.NewPath("KubeProxyConfiguration")
|
||||||
|
|
||||||
allErrs = append(allErrs, validateKubeProxyIPTablesConfiguration(config.IPTables, newPath.Child("KubeProxyIPTablesConfiguration"))...)
|
allErrs = append(allErrs, validateKubeProxyIPTablesConfiguration(config.IPTables, newPath.Child("KubeProxyIPTablesConfiguration"))...)
|
||||||
|
if config.Mode == kubeproxyconfig.ProxyModeIPVS {
|
||||||
allErrs = append(allErrs, validateKubeProxyIPVSConfiguration(config.IPVS, newPath.Child("KubeProxyIPVSConfiguration"))...)
|
allErrs = append(allErrs, validateKubeProxyIPVSConfiguration(config.IPVS, newPath.Child("KubeProxyIPVSConfiguration"))...)
|
||||||
|
}
|
||||||
allErrs = append(allErrs, validateKubeProxyConntrackConfiguration(config.Conntrack, newPath.Child("KubeProxyConntrackConfiguration"))...)
|
allErrs = append(allErrs, validateKubeProxyConntrackConfiguration(config.Conntrack, newPath.Child("KubeProxyConntrackConfiguration"))...)
|
||||||
allErrs = append(allErrs, validateProxyMode(config.Mode, newPath.Child("Mode"))...)
|
allErrs = append(allErrs, validateProxyMode(config.Mode, newPath.Child("Mode"))...)
|
||||||
allErrs = append(allErrs, validateClientConnectionConfiguration(config.ClientConnection, newPath.Child("ClientConnection"))...)
|
allErrs = append(allErrs, validateClientConnectionConfiguration(config.ClientConnection, newPath.Child("ClientConnection"))...)
|
||||||
|
@ -42,6 +42,7 @@ func TestValidateKubeProxyConfiguration(t *testing.T) {
|
|||||||
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
||||||
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
||||||
},
|
},
|
||||||
|
Mode: kubeproxyconfig.ProxyModeIPVS,
|
||||||
IPVS: kubeproxyconfig.KubeProxyIPVSConfiguration{
|
IPVS: kubeproxyconfig.KubeProxyIPVSConfiguration{
|
||||||
SyncPeriod: metav1.Duration{Duration: 10 * time.Second},
|
SyncPeriod: metav1.Duration{Duration: 10 * time.Second},
|
||||||
MinSyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
MinSyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
||||||
@ -54,6 +55,26 @@ func TestValidateKubeProxyConfiguration(t *testing.T) {
|
|||||||
TCPCloseWaitTimeout: &metav1.Duration{Duration: 5 * time.Second},
|
TCPCloseWaitTimeout: &metav1.Duration{Duration: 5 * time.Second},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
BindAddress: "192.168.59.103",
|
||||||
|
HealthzBindAddress: "0.0.0.0:10256",
|
||||||
|
MetricsBindAddress: "127.0.0.1:10249",
|
||||||
|
ClusterCIDR: "192.168.59.0/24",
|
||||||
|
UDPIdleTimeout: metav1.Duration{Duration: 1 * time.Second},
|
||||||
|
ConfigSyncPeriod: metav1.Duration{Duration: 1 * time.Second},
|
||||||
|
IPTables: kubeproxyconfig.KubeProxyIPTablesConfiguration{
|
||||||
|
MasqueradeAll: true,
|
||||||
|
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
||||||
|
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
||||||
|
},
|
||||||
|
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
|
||||||
|
Max: pointer.Int32Ptr(2),
|
||||||
|
MaxPerCore: pointer.Int32Ptr(1),
|
||||||
|
Min: pointer.Int32Ptr(1),
|
||||||
|
TCPEstablishedTimeout: &metav1.Duration{Duration: 5 * time.Second},
|
||||||
|
TCPCloseWaitTimeout: &metav1.Duration{Duration: 5 * time.Second},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, successCase := range successCases {
|
for _, successCase := range successCases {
|
||||||
@ -80,10 +101,6 @@ func TestValidateKubeProxyConfiguration(t *testing.T) {
|
|||||||
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
||||||
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
||||||
},
|
},
|
||||||
IPVS: kubeproxyconfig.KubeProxyIPVSConfiguration{
|
|
||||||
SyncPeriod: metav1.Duration{Duration: 10 * time.Second},
|
|
||||||
MinSyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
|
||||||
},
|
|
||||||
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
|
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
|
||||||
Max: pointer.Int32Ptr(2),
|
Max: pointer.Int32Ptr(2),
|
||||||
MaxPerCore: pointer.Int32Ptr(1),
|
MaxPerCore: pointer.Int32Ptr(1),
|
||||||
@ -108,10 +125,6 @@ func TestValidateKubeProxyConfiguration(t *testing.T) {
|
|||||||
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
||||||
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
||||||
},
|
},
|
||||||
IPVS: kubeproxyconfig.KubeProxyIPVSConfiguration{
|
|
||||||
SyncPeriod: metav1.Duration{Duration: 10 * time.Second},
|
|
||||||
MinSyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
|
||||||
},
|
|
||||||
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
|
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
|
||||||
Max: pointer.Int32Ptr(2),
|
Max: pointer.Int32Ptr(2),
|
||||||
MaxPerCore: pointer.Int32Ptr(1),
|
MaxPerCore: pointer.Int32Ptr(1),
|
||||||
@ -136,10 +149,6 @@ func TestValidateKubeProxyConfiguration(t *testing.T) {
|
|||||||
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
||||||
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
||||||
},
|
},
|
||||||
IPVS: kubeproxyconfig.KubeProxyIPVSConfiguration{
|
|
||||||
SyncPeriod: metav1.Duration{Duration: 10 * time.Second},
|
|
||||||
MinSyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
|
||||||
},
|
|
||||||
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
|
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
|
||||||
Max: pointer.Int32Ptr(2),
|
Max: pointer.Int32Ptr(2),
|
||||||
MaxPerCore: pointer.Int32Ptr(1),
|
MaxPerCore: pointer.Int32Ptr(1),
|
||||||
@ -164,10 +173,6 @@ func TestValidateKubeProxyConfiguration(t *testing.T) {
|
|||||||
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
||||||
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
||||||
},
|
},
|
||||||
IPVS: kubeproxyconfig.KubeProxyIPVSConfiguration{
|
|
||||||
SyncPeriod: metav1.Duration{Duration: 10 * time.Second},
|
|
||||||
MinSyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
|
||||||
},
|
|
||||||
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
|
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
|
||||||
Max: pointer.Int32Ptr(2),
|
Max: pointer.Int32Ptr(2),
|
||||||
MaxPerCore: pointer.Int32Ptr(1),
|
MaxPerCore: pointer.Int32Ptr(1),
|
||||||
@ -192,10 +197,6 @@ func TestValidateKubeProxyConfiguration(t *testing.T) {
|
|||||||
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
||||||
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
||||||
},
|
},
|
||||||
IPVS: kubeproxyconfig.KubeProxyIPVSConfiguration{
|
|
||||||
SyncPeriod: metav1.Duration{Duration: 10 * time.Second},
|
|
||||||
MinSyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
|
||||||
},
|
|
||||||
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
|
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
|
||||||
Max: pointer.Int32Ptr(2),
|
Max: pointer.Int32Ptr(2),
|
||||||
MaxPerCore: pointer.Int32Ptr(1),
|
MaxPerCore: pointer.Int32Ptr(1),
|
||||||
@ -220,10 +221,31 @@ func TestValidateKubeProxyConfiguration(t *testing.T) {
|
|||||||
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
||||||
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
||||||
},
|
},
|
||||||
IPVS: kubeproxyconfig.KubeProxyIPVSConfiguration{
|
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
|
||||||
SyncPeriod: metav1.Duration{Duration: 10 * time.Second},
|
Max: pointer.Int32Ptr(2),
|
||||||
MinSyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
MaxPerCore: pointer.Int32Ptr(1),
|
||||||
|
Min: pointer.Int32Ptr(1),
|
||||||
|
TCPEstablishedTimeout: &metav1.Duration{Duration: 5 * time.Second},
|
||||||
|
TCPCloseWaitTimeout: &metav1.Duration{Duration: 5 * time.Second},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
msg: "must be greater than 0",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
config: kubeproxyconfig.KubeProxyConfiguration{
|
||||||
|
BindAddress: "192.168.59.103",
|
||||||
|
HealthzBindAddress: "0.0.0.0:10256",
|
||||||
|
MetricsBindAddress: "127.0.0.1:10249",
|
||||||
|
ClusterCIDR: "192.168.59.0/24",
|
||||||
|
UDPIdleTimeout: metav1.Duration{Duration: 1 * time.Second},
|
||||||
|
ConfigSyncPeriod: metav1.Duration{Duration: 1 * time.Second},
|
||||||
|
IPTables: kubeproxyconfig.KubeProxyIPTablesConfiguration{
|
||||||
|
MasqueradeAll: true,
|
||||||
|
SyncPeriod: metav1.Duration{Duration: 5 * time.Second},
|
||||||
|
MinSyncPeriod: metav1.Duration{Duration: 2 * time.Second},
|
||||||
|
},
|
||||||
|
// not specifying valid period in IPVS mode.
|
||||||
|
Mode: kubeproxyconfig.ProxyModeIPVS,
|
||||||
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
|
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{
|
||||||
Max: pointer.Int32Ptr(2),
|
Max: pointer.Int32Ptr(2),
|
||||||
MaxPerCore: pointer.Int32Ptr(1),
|
MaxPerCore: pointer.Int32Ptr(1),
|
||||||
|
Loading…
Reference in New Issue
Block a user